Problem 1: Basic KNN Classification
Easypython
Learn the Concept: K-Nearest NeighborsProblem Description
Write a Python program that trains a KNN classifier with k=3 on a small labeled dataset, and predicts the class for a new data point.
Input
A small labeled dataset and one new data point.
Output
The predicted class for the new data point.
Constraints
- At least 6 labeled training examples.
Example Input
textX=[[1,60],[2,65],[8,95],[9,98]], y=[0,0,1,1], new=[[7,90]]
Example Output
textPrediction: [1]
Concepts Covered
KNeighborsClassifier, .fit(), .predict().
Related Problems
- Problem 2: Compare Different Values of kEasy · pythonSolve Problem
- Problem 3: Scale Features Before Applying KNNEasy · pythonSolve Problem
- Problem 4: Manual Euclidean Distance CalculatorEasy · pythonSolve Problem