Dhanashree ML Report
Dhanashree ML Report
Code:
import pandas as pd
data = {
'target': ['A', 'A', 'A', 'A', 'A', 'B', 'B', 'B', 'B', 'B']
}
df = pd.DataFrame(data)
X = df[['feature1', 'feature2']]
y = df['target']
knn
y_pred = knn.predict(X_test)
print(f"Accuracy: {accuracy}")
cm = confusion_matrix(y_test, y_pred)
print(f"Confusion Matrix:\n{cm}")
plt.figure(figsize=(8, 6))
plt.xlabel('Feature 1')
plt.ylabel('Feature 2')
plt.title('KNN Classification')
plt.show()
Output :
Conclusion:
I able to know about the KNN is valuable tool in machine learining due to its
interpretability and effectiveness, especially when used with carefully
preprocessed data.