Implement and Tune KNN Classifier
Leaf Classification Task: K-Nearest Neighbors Implementation
This task involves a three-class leaf classification problem using two provided CSV files:
train.csv: Contains three numeric feature columns (feature_0,feature_1,feature_2) and a class label column.unlabeled.csv: Contains the same three numeric feature columns but lacks class labels.
Your objective is to implement a K-nearest neighbors (KNN) classifier from scratch, train it on the labeled data, and use it to predict labels for the unlabeled dataset. All work should be presented in a Jupyter notebook.
Requirements:
- Data Loading and Inspection: Load and thoroughly inspect the
train.csvdataset. - Data Splitting: Split the labeled data into distinct training and testing sets.
- KNN Implementation: Implement the K-nearest neighbors classifier from scratch. While standard data-processing libraries (e.g., NumPy, Pandas) are permitted for data manipulation, the core KNN prediction logic (distance calculation, neighbor selection, voting) must be your own custom code.
- Model Training and Evaluation: Train your custom KNN classifier on the training set and evaluate its accuracy on the held-out test set.
- Hyperparameter Tuning: Systematically tune hyperparameters, with a particular focus on optimizing the value of
k, to improve the model's accuracy. Cross-validation may be employed for this step. - Prediction on Unlabeled Data: Utilize your final, tuned model to predict class labels for the
unlabeled.csvdataset. - Output Generation: Write these predictions to a new output CSV file.
AI interview prep
Core dilemma
Balancing the computational efficiency of a custom K-Nearest Neighbors implementation against achieving robust model performance and generalization, especially when considering scalability and the impact of hyperparameter choices.
3 tradeoffs and 3 stress tests locked
Interview prep
Unlock the interviewer X-Ray rubric, tradeoff matrix, stress tests, clarifying questions, and key concepts.
Implement and Tune KNN Classifier
Leaf Classification Task: K-Nearest Neighbors Implementation
This task involves a three-class leaf classification problem using two provided CSV files:
train.csv: Contains three numeric feature columns (feature_0,feature_1,feature_2) and a class label column.unlabeled.csv: Contains the same three numeric feature columns but lacks class labels.
Your objective is to implement a K-nearest neighbors (KNN) classifier from scratch, train it on the labeled data, and use it to predict labels for the unlabeled dataset. All work should be presented in a Jupyter notebook.
Requirements:
- Data Loading and Inspection: Load and thoroughly inspect the
train.csvdataset. - Data Splitting: Split the labeled data into distinct training and testing sets.
- KNN Implementation: Implement the K-nearest neighbors classifier from scratch. While standard data-processing libraries (e.g., NumPy, Pandas) are permitted for data manipulation, the core KNN prediction logic (distance calculation, neighbor selection, voting) must be your own custom code.
- Model Training and Evaluation: Train your custom KNN classifier on the training set and evaluate its accuracy on the held-out test set.
- Hyperparameter Tuning: Systematically tune hyperparameters, with a particular focus on optimizing the value of
k, to improve the model's accuracy. Cross-validation may be employed for this step. - Prediction on Unlabeled Data: Utilize your final, tuned model to predict class labels for the
unlabeled.csvdataset. - Output Generation: Write these predictions to a new output CSV file.