नॉन-स्केल्ड डेटा पर KNN
scikit-learn वर्कफ़्लो में standardization जोड़ने से पहले, आप बिना डेटा को standardize किए wine डेटासेट पर K-nearest neighbors मॉडल की accuracy देखेंगे.
knn मॉडल और X व y डेटा व लेबल सेट पहले से बनाए जा चुके हैं.
यह अभ्यास पाठ्यक्रम का हिस्सा है
Python में Machine Learning के लिए Preprocessing
अभ्यास निर्देश
- डेटासेट को training और test सेट में बाँटें.
- प्रशिक्षण डेटा पर
knnमॉडल को फिट करें. - अपने प्रशिक्षित
knnमॉडल की test सेट accuracy प्रिंट करें.
इंटरैक्टिव व्यावहारिक अभ्यास
इस अभ्यास को इस नमूना कोड को पूरा करके आज़माएँ।
# Split the dataset and labels into training and test sets
X_train, X_test, y_train, y_test = ____(____, ____, stratify=y, random_state=42)
# Fit the k-nearest neighbors model to the training data
____
# Score the model on the test data
print(____.____(____, ____))