From 063761e60c4db7bcd6fedb14b13c3ecb8fb7cdb3 Mon Sep 17 00:00:00 2001 From: David Rotermund <54365609+davrot@users.noreply.github.com> Date: Wed, 7 Feb 2024 15:21:46 +0100 Subject: [PATCH] Update README.md Signed-off-by: David Rotermund <54365609+davrot@users.noreply.github.com> --- scikit-learn/svm/README.md | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/scikit-learn/svm/README.md b/scikit-learn/svm/README.md index a1941a7..c9849ad 100644 --- a/scikit-learn/svm/README.md +++ b/scikit-learn/svm/README.md @@ -99,8 +99,22 @@ np.save("label_test.npy", label_test) ## Train and test ```python +import numpy as np +import sklearn.svm # type:ignore + +data_train = np.load("data_train.npy") +data_test = np.load("data_test.npy") +label_train = np.load("label_train.npy") +label_test = np.load("label_test.npy") + +svm = sklearn.svm.SVC() + +svm.fit(X=data_train, y=label_train) +prediction = svm.predict(X=data_test) + +performance = 100.0 * (prediction == label_test).sum() / prediction.shape[0] + +print(f"Performance correct: {performance}%") # -> Performance correct: 95.4% ``` -```shell -```