Downloads · 30 days
0
JashuXo/smart-knn
smart-knn is a machine learning model from JashuXo. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as mit.
SmartKNN is a weighted and interpretable extension of classical K-Nearest Neighbours (KNN), designed for real-world tabular machine learning. It automatically learns feature importance, filters weak features, handles…
Downloads · 30 days
0
Access
Public
Updated Nov 26, 2025
Repo size
—
Likes
1
Public
Click a slice to open those files.
.md4.2 KB · 74%
From the Hugging Face model README
SmartKNN is a weighted and interpretable extension of classical K-Nearest Neighbours (KNN), designed for real-world tabular machine learning. It automatically learns feature importance, filters weak features, handles missing values, normalizes inputs internally, and consistently achieves higher accuracy and robustness than classical KNN — while maintaining a simple scikit-learn-style API.
Model Description SmartKNN improves classical KNN by learning feature weights and applying a weighted Euclidean distance for neighbour selection. It performs normalization, NaN/Inf cleaning, median imputation, outlier clipping, and feature filtering internally. It exposes feature importance for transparency and explainability.
Developed by: Jashwanth Thatipamula
Model type: Weighted KNN for tabular ML
License: MIT
Language(s): Not language-dependent (numerical tabular ML)
Finetuned from model: Not applicable (original algorithm)
Model Sources
Repository: https://github.com/thatipamula-jashwanth/smart-knn
Paper (DOI): https://doi.org/10.5281/zenodo.17713746
Demo: Coming soon
Direct Use
• Regression on tabular datasets
• Classification on tabular datasets
• Interpretable ML where feature importance matters
• Real-world ML pipelines with missing values and noisy features
Downstream Use
• Research on distance-metric learning
• Explainable ML baselines
• AutoML components for tabular data
Out-of-Scope Use
• NLP, image or audio modelling
• Deep learning / GPU models
• Raw categorical datasets without encoding
• Instance-based prediction can be slower than tree-based models on large datasets
• Low performance on categorical-only datasets without encoding
• Requires storing full training set for inference
Recommendations Users should numerically encode categorical features before fitting SmartKNN.
pip install smart-knn
import pandas as pd from smart_knn import SmartKNN
df = pd.read_csv("data.csv") X = df.drop("target", axis=1) y = df["target"]
model = SmartKNN(k=5) model.fit(X, y)
sample = X.iloc[0] pred = model.predict(sample) print(pred)
Training Data SmartKNN is not pretrained and does not ship with training data; users train on their own dataset.
Preprocessing Performed automatically: • Normalization • NaN / Inf cleaning • Median imputation • Outlier clipping • Feature filtering via learned weights
Training Hyperparameters
• k = number of neighbors
• weight_threshold = drop features below learned importance
Testing Data Evaluated across 35 regression and 20 classification public tabular datasets.
Regression: R², MSE
Classification: Accuracy
• Regression: SmartKNN outperformed classical KNN on 90%+ datasets
• Classification: SmartKNN beat classical KNN on 60% of datasets
SmartKNN delivers higher accuracy, greater robustness to noise, and better interpretability than classical KNN while preserving its simplicity.
SmartKNN requires no GPU and has minimal energy usage.
Hardware Type: CPU
Hours used: Minimal
Carbon Emitted: Negligible
Model Architecture and Objective
• Instance-based learner
• Weighted Euclidean distance metric
• Learned feature weights (MSE + MI + Random Forest)
Compute Infrastructure
• Runs efficiently on CPU systems
• Implemented using NumPy
@software{smartknn2025, author = {Jashwanth Thatipamula}, title = {SmartKNN: An Interpretable Weighted Distance Framework for K-Nearest Neighbours}, year = {2025}, publisher = {Zenodo}, doi = {10.5281/zenodo.17713746}, url = {https://doi.org/10.5281/zenodo.17713746} }
Jashwanth Thatipamula
Model Card Contact Contact via GitHub issues: https://github.com/thatipamula-jashwanth/smart-knn