from sklearn.neighbors import KNeighborsClassifier
from sklearn.metrics import accuracy_score,confusion_matrix
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np

data=pd.read_csv("Immunotherapy.csv")

X=data.iloc[:,:-1].values
y=data.iloc[:,-1].values

#Splitting the data

from sklearn.model_selection import train_test_split
X_train,X_test,y_train,y_test=train_test_split(X,y,test_size=0.2)

#Scaling the data

from sklearn.preprocessing import StandardScaler
sc=StandardScaler()
train=sc.fit_transform(X_train)
test=sc.transform(X_test)

#Using KNN

from sklearn.neighbors import KNeighborsClassifier
knn=KNeighborsClassifier(n_neighbors=3)
knn.fit(train,y_train)
y_pred=knn.predict(test)
print(y_pred)

#Accuracy_matrix

from sklearn.metrics import accuracy_score,confusion_matrix
print(accuracy_score(y_pred,y_test))

21cc12ca4126a5c8b33abda4dc23281a9203926e
<mask token>

<mask token>
knn.fit(train, y_train)
<mask token>
print(y_pred)
<mask token>
print(accuracy_score(y_pred, y_test))

<mask token>
data = pd.read_csv('Immunotherapy.csv')
X = data.iloc[:, :-1].values
y = data.iloc[:, -1].values
<mask token>
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)
<mask token>
sc = StandardScaler()
train = sc.fit_transform(X_train)
test = sc.transform(X_test)
<mask token>
knn = KNeighborsClassifier(n_neighbors=3)
knn.fit(train, y_train)
y_pred = knn.predict(test)
print(y_pred)
<mask token>
print(accuracy_score(y_pred, y_test))

from sklearn.neighbors import KNeighborsClassifier
from sklearn.metrics import accuracy_score, confusion_matrix
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
data = pd.read_csv('Immunotherapy.csv')
X = data.iloc[:, :-1].values
y = data.iloc[:, -1].values
from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)
from sklearn.preprocessing import StandardScaler
sc = StandardScaler()
train = sc.fit_transform(X_train)
test = sc.transform(X_test)
from sklearn.neighbors import KNeighborsClassifier
knn = KNeighborsClassifier(n_neighbors=3)
knn.fit(train, y_train)
y_pred = knn.predict(test)
print(y_pred)
from sklearn.metrics import accuracy_score, confusion_matrix
print(accuracy_score(y_pred, y_test))

from sklearn.neighbors import KNeighborsClassifier
from sklearn.metrics import accuracy_score,confusion_matrix
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np

data=pd.read_csv("Immunotherapy.csv")

X=data.iloc[:,:-1].values
y=data.iloc[:,-1].values

#Splitting the data

from sklearn.model_selection import train_test_split
X_train,X_test,y_train,y_test=train_test_split(X,y,test_size=0.2)

#Scaling the data

from sklearn.preprocessing import StandardScaler
sc=StandardScaler()
train=sc.fit_transform(X_train)
test=sc.transform(X_test)

#Using KNN

from sklearn.neighbors import KNeighborsClassifier
knn=KNeighborsClassifier(n_neighbors=3)
knn.fit(train,y_train)
y_pred=knn.predict(test)
print(y_pred)

#Accuracy_matrix

from sklearn.metrics import accuracy_score,confusion_matrix
print(accuracy_score(y_pred,y_test))
