ML_5.ipynb - Colab
ML_5.ipynb - Colab
import numpy as np
import matplotlib.pyplot as plt
df = pd.read_csv('Social_Network_Ads.csv')
df.head()
df.shape
(400, 5)
x = df.iloc[:,[2,3]]
y = df.iloc[:,4]
x.head()
Age EstimatedSalary
0 19 19000
1 35 20000
2 26 43000
3 27 57000
4 19 76000
y.head()
Purchased
0 0
1 0
2 0
3 0
4 0
dtype: int64
▾ SVC i ?
SVC(kernel='linear', random_state=0)
y_pred = classifier.predict(x_test)
array([[66, 2],
[ 8, 24]])
print("ACCURACY", accuracy_score(y_test,y_pred))
ACCURACY 0.9
plt.figure(figsize=(6, 4))
sns.heatmap(cm, annot=True, fmt='d', cmap='Blues',
xticklabels=['Predicted 0', 'Predicted 1'],
yticklabels=['Actual 0', 'Actual 1'])
plt.title('Confusion Matrix')
plt.xlabel('Predicted Label')
plt.ylabel('True Label')
plt.show()