31 lines
759 B
Python
31 lines
759 B
Python
# Import statements
|
|
from sklearn.svm import SVC
|
|
from sklearn.metrics import accuracy_score
|
|
import pandas as pd
|
|
import numpy as np
|
|
import matplotlib.pyplot as plt
|
|
|
|
# Read the data.
|
|
data = np.asarray(pd.read_csv('data.csv', header=None))
|
|
# Assign the features to the variable X, and the labels to the variable y.
|
|
X = data[:, 0:2]
|
|
y = data[:, 2]
|
|
|
|
|
|
# TODO: Create the model and assign it to the variable model.
|
|
# Find the right parameters for this model to achieve 100% accuracy
|
|
# on the dataset.
|
|
|
|
model = SVC(kernel='rbf', gamma=27)
|
|
|
|
# TODO: Fit the model.
|
|
|
|
model.fit(X, y)
|
|
|
|
# TODO: Make predictions. Store them in the variable y_pred.
|
|
|
|
y_pred = model.predict(X)
|
|
|
|
# TODO: Calculate the accuracy and assign it to the variable acc.
|
|
acc = accuracy_score(y, y_pred)
|