DWM Pr8)

Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

Pr_8:-

import numpy as np
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.svm import SVC
from sklearn.metrics import classification_report, confusion_matrix
from sklearn.datasets import load_iris

# Load the Iris dataset


iris = load_iris()
X = iris.data # Features
y = iris.target # Target labels

# Split the data 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)

# Create SVM classifier


svm = SVC(kernel='linear') # You can also try 'rbf', 'poly', etc.

# Fit the classifier to the training data


svm.fit(X_train, y_train)

# Make predictions on the test data


y_pred = svm.predict(X_test)

# Print confusion matrix and classification report


print(confusion_matrix(y_test, y_pred))
print(classification_report(y_test, y_pred))

Output:-

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy