df_features = df.drop(labels=["species"], axis=1) df_target = df.filter(items=["species"])
Now, we are splitting the dataset into training and test set. Please note that the shuffle=True parameter indicates that the dataset is shuffled before the split. And the random_state=1 parameter controls the random number generator that is used for shuffling.
X_train, X_test, y_train, y_test = train_test_split(df_features, df_target["species"], shuffle=True, random_state=1)
Now, we are initializing the classifier using the SVC class from the sklearn.svm module. By default, the SVC classifier is a multiclass classifier that uses one-vs-rest (‘ovr’) decision function of shape and a radial basis function kernel.
The fit() method is used to learn from the dataset. And the predict() method is used to predict the target labels on the test set.
classifier = SVC() classifier.fit(X_train, y_train) y_test_pred = classifier.predict(X_test)
We can now compare y_test_pred and y_test and measure the performance of the module. We are here using the accuracy score (What is the accuracy score in machine learning?) to measure the performance of the model.
The output of the above program will be:
Accuracy Score: 0.9736842105263158








































0 Comments