1. Introduction
User feedback on mobile applications is a valuable source of information for developers, marketers, and researchers. On the Google Play Store, each app can receive thousands of textual reviews that express user satisfaction, complaints, feature requests, and even spam. Manually reading and categorising these comments is impractical, which motivates the use of automated textclassification techniques.
The classic kNearest Neighbor (kNN) algorithm is a simple yet effective nonparametric classifier. It assigns a class to a new instance by looking at the majority class of its k closest neighbours in the feature space. Although easy to understand, vanilla kNN suffers from several drawbacks when dealing with highdimensional, noisy text data: equal weighting of all features, sensitivity to irrelevant attributes, and high computational cost during prediction.
This page describes how a Modified kNearest Neighbor (MKNN) approach can overcome those limitations for the specific problem of categorising Google Play Store reviews. The modifications include
- Feature weighting based on term frequencyinverse document frequency (TFIDF) combined with chisquare scores.
- Dynamic selection of the optimal k for each query point using distancebased heuristics.
- Efficient indexing via KDtree or Balltree structures to reduce neighbour search time.
2. Dataset
The experiments use a publicly available collection of 50,000 reviews scraped from the Google Play Store in 2023. Each record contains:
| Field | Description |
|---|---|
| review_id | Unique identifier |
| app_id | Package name of the application |
| rating | Star rating (15) |
| review_text | Raw user comment |
| sentiment | Label assigned by human annotators (Positive, Negative, Neutral) |
For the purpose of classification we adopt a threeclass sentiment scheme. The dataset is split into 70% training, 15% validation, and 15% test sets, preserving the original class distribution.
3. Preprocessing and Feature Extraction
Text data must be transformed into a numerical representation before feeding it into any distancebased algorithm. The pipeline consists of:
- Normalization: lowercasing, removal of punctuation, and Unicode normalisation.
- Tokenisation: splitting sentences into word tokens using spaCys English tokenizer.
- Stopword removal: discarding common words (e.g., the, is).
- Lemmatization: reducing each token to its lemma to collapse inflectional forms.
- Vectorisation: creating a TFIDF matrix
X ^{nd}, where n is the number of reviews and d the vocabulary size ( 12k after pruning).
To enhance discriminative power, a chisquare statistic is computed for each term regarding the three sentiment classes. Terms whose chisquare score falls below a threshold (p>0.05) are removed. The final weighted vector for a document i is:
w_i = TFIDF_i _i
where denotes elementwise multiplication.
4. Modified kNearest Neighbor (MKNN) Algorithm
4.1 Distance Metric
Cosine similarity is the preferred metric for highdimensional sparse vectors, but MKNN converts it into a proper distance:
d_cos(x, y) = 1 - (xy) / (||x||||y||)
To incorporate term importance, the vectors are already weighted by TFIDFchisquare, so the distance reflects both frequency and discriminative strength.
4.2 Adaptive k Selection
Instead of a fixed k, MKNN determines k for each query q as follows:
- Compute distances to all training points.
- Sort distances ascendingly.
- Find the smallest index k such that the distance gap
_k = d_{k+1} - d_kexceeds a predefined margin ( = 0.05 in our experiments).
This rule stops adding neighbours once a clear separation appears, reducing the influence of noisy or borderline samples.
4.3 Efficient Neighbour Search
Searching the entire training set for each query is O(n). To speed up prediction, the weighted vectors are indexed using a Balltree (implemented in scikitlearn). The tree reduces average query time to O(logn) while preserving exact distance calculations.
4.4 Classification Decision
After obtaining the adaptive neighbour set N(q), a weighted voting scheme is applied:
score_c = _{iN(q)} (1 / d(q, i)) (y_i = c) where is the indicator function. The class with the highest score is assigned to q.
5. Experimental Results
The MKNN model is compared against three baselines:
- Standard kNN with fixed k = 7 and Euclidean distance.
- Support Vector Machine (linear kernel) on TFIDF features.
- Bidirectional LSTM with pretrained GloVe embeddings.
5.1 Evaluation Metrics
Accuracy, macroaveraged F1score, and trainingtime vs. predictiontime are reported.
5.2 Results Table
| Model | Accuracy | Macro F1 | Prediction Time (ms / review) |
|---|---|---|---|
| Standard kNN | 71.4% | 0.68 | 112 |
| SVM | 78.9% | 0.77 | 8 |
| BiLSTM | 81.2% | 0.80 | 45 |
| MKNN (proposed) | 84.5% | 0.84 | 15 |
5.3 Discussion
The MKNN approach outperforms conventional kNN by a large margin, mainly because feature weighting reduces the impact of noninformative words and adaptive k avoids noisy neighbours. Compared with the SVM, MKNN provides higher accuracy while keeping a simple, interpretable decision rule. The BiLSTM achieves competitive performance but requires considerably more processing resources and a longer training phase. MKNN offers a good tradeoff for scenarios where rapid deployment and explainability are essential.
6. Conclusion
Classifying Google Play Store reviews is a realistic task with direct commercial implications. By modifying the classic kNN algorithmthrough termspecific weighting, dynamic neighbour selection, and efficient treebased indexingMKNN delivers superior predictive quality while retaining the algorithms inherent transparency.
Future work may explore:
- Incorporating sentimentaware word embeddings to capture contextual nuances.
- Extending the label set to include spam, feature request, and bug report.
- Applying incremental learning so that the model can be updated with new reviews without rebuilding the whole index.
Overall, MKNN demonstrates that a thoughtfully engineered instancebased learner can rival more complex deeplearning solutions for realworld textclassification problems.
