Modelling and Simulation Sample Model 5
Modelling and Simulation Sample Model 5
Modelling and Simulation Sample Model 5
iris = datasets.load_iris()
X = iris.data
y = iris.target
svm_model = SVC(kernel='linear') # You can use other kernels like 'rbf', 'poly', etc.
svm_model.fit(X_train, y_train)
y_pred = svm_model.predict(X_test)
# Calculate accuracy
iris = datasets.load_iris()
X = iris.data
y = iris.target
svm_model = SVC(kernel='linear') # You can use other kernels like 'rbf', 'poly', etc.
svm_model.fit(X_train, y_train)
y_pred = svm_model.predict(X_test)
# Calculate accuracy
iris = datasets.load_iris()
X = iris.data
y = iris.target
svm_model = SVC(kernel='linear') # You can use other kernels like 'rbf', 'poly', etc.
svm_model.fit(X_train, y_train)
y_pred = svm_model.predict(X_test)
# Calculate accuracy
iris = datasets.load_iris()
X = iris.data
y = iris.target
svm_model = SVC(kernel='linear') # You can use other kernels like 'rbf', 'poly', etc.
svm_model.fit(X_train, y_train)
y_pred = svm_model.predict(X_test)
# Calculate accuracy
iris = datasets.load_iris()
X = iris.data
y = iris.target
svm_model = SVC(kernel='linear') # You can use other kernels like 'rbf', 'poly', etc.
# Train the model on the training data
svm_model.fit(X_train, y_train)
y_pred = svm_model.predict(X_test)
# Calculate accuracy
iris = datasets.load_iris()
X = iris.data
y = iris.target
svm_model = SVC(kernel='linear') # You can use other kernels like 'rbf', 'poly', etc.
svm_model.fit(X_train, y_train)
# Make predictions on the test data
y_pred = svm_model.predict(X_test)
# Calculate accuracy
iris = datasets.load_iris()
X = iris.data
y = iris.target
svm_model = SVC(kernel='linear') # You can use other kernels like 'rbf', 'poly', etc.
svm_model.fit(X_train, y_train)
y_pred = svm_model.predict(X_test)
# Calculate accuracy
accuracy = accuracy_score(y_test, y_pred)
print(f"Accuracy: {accuracy:.2f}")