# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3.7.5 64-bit
#     name: python37564bit3ec481eb2fd14d788a8a4fb6d3db89d5
# ---

import numpy as np
import pandas as pd

# Importing data

data=pd.read_csv('Social_Network_Ads.csv')
data.head()

# Checking for null values

data.isnull().sum()

# Data Splitting

from sklearn.model_selection import train_test_split
x=data.iloc[:,:-1].values
y=data.iloc[:,-1].values.reshape(-1,1)
x_train,x_test,y_train,y_test=train_test_split(x,y,test_size=0.2,random_state=0)

# Feature Scaling

from sklearn.preprocessing import StandardScaler
sc=StandardScaler()
x_train=sc.fit_transform(x_train)
x_test=sc.transform(x_test)

# SCV model

from sklearn.svm import SVC
svc=SVC(kernel='rbf',random_state=0)
svc.fit(x_train,y_train)

y_pred=svc.predict(x_test)

# + tags=[]
from sklearn.metrics import accuracy_score,confusion_matrix
print(confusion_matrix(y_test,y_pred))
accuracy_score(y_test,y_pred)
# -

# K-Fold Cross Validation

# + tags=[]
from sklearn.model_selection import cross_val_score
k_fold=cross_val_score(estimator=svc,X=x_train,y=y_train,cv=10,n_jobs=-1)
print('Mean Acuracy:',k_fold.mean())


StarcoderdataJupyterScriptsDedupFiltered