Hello Good People,
I have some label data and I am using the classification ML model (SVM, kNN) to train and test the dataset.
My input features are look likes:
(442, 443, 0.608923884514436), (444, 443, 0.6418604651162789)
The label is look likes:
0, 1
Then I used sklearn
to train and test (after splitting the dataset 80% for train and 20% for the test). Code sample is given below:
classifiers = [
SVC(),
KNeighborsClassifier(n_neighbors=5)]
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
trainingData = X_train
trainingScores = y_train
for item in classifiers:
print(item)
clf = item
clf.fit(trainingData, trainingScores)
y_pred = clf.predict(X_test)
print("Accuracy Scor:")
print(accuracy_score(y_pred, y_test))
print("Confusion Matrix:")
print(confusion_matrix(y_pred, y_test))
print("Classification Report:")
print(classification_report(y_pred, y_test))
The SVC Accuracy Score: 0.6639580602883355
The kNN Accuracy Score: 0.7171690694626475
I can guess, that the model is predicting some data correctly. Now, my question is,
- How can I save the prediction data including the label given by the model in a CSV file.
- Is it possible to use the
cross-validation
concept here? For example, if I want to apply 5 cross-validations. Then, how can I do that?
Though I am not sure, I am asking a freaking question or not (I am new in the ML fields).
Any kind of answer is appreciable.