Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
1.2 kB
5
Indexable
Never
import numpy as np
import matplotlib.pyplot as plt
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler

ds = pd.read_csv("/content/IRIS.csv")
print(ds)

x = ds.drop('species', axis=1)
y = ds['species']

x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.2)

from sklearn.svm import SVC

svm_classifier = SVC(kernel='poly')

svm_classifier.fit(x_train, y_train)

y_pred = svm_classifier.predict(x_test)


from sklearn.metrics import accuracy_score

accuracy = accuracy_score(y_test, y_pred)
print("Accuracy:", accuracy)

x = ds.drop('species', axis=1)
y = ds['species']

x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.2)

from sklearn.svm import SVC

svm_classifier = SVC(kernel='rbf')

svm_classifier.fit(x_train, y_train)

y_pred = svm_classifier.predict(x_test)
accuracy = accuracy_score(y_test, y_pred)
print("Accuracy:", accuracy)

from sklearn.metrics import confusion_matrix

cm = confusion_matrix(y_test, y_pred)
print("Confusion Matrix:")
print(cm)

from sklearn.metrics import classification_report
report = classification_report(y_test, y_pred)
print("Classification Report:")
print(report)
Leave a Comment