We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2
import numpy as np
import matplotlib.pyplot as plt
from sklearn import datasets from sklearn.model_selection import train_test_split from sklearn.svm import SVC from sklearn.metrics import accuracy_score, classification_report, confusion_matrix, ConfusionMatrixDisplay
# Load the Iris dataset
iris = datasets.load_iris() X = iris.data y = iris.target
# Split the dataset into training and testing sets
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
# Define the kernels and their associated hyperparameters to try
# Iterate over each kernel and hyperparameter combination
for kernel in kernels: for C in C_values: for gamma in gamma_values: # Initialize the SVM classifier with current parameters model = SVC(kernel=kernel, C=C, gamma=gamma, random_state=42)