NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
import seaborn as sn
from sklearn.tree import DecisionTreeClassifier
from sklearn import tree
from sklearn.model_selection import train_test_split
from sklearn.neighbors import KNeighborsClassifier
from sklearn.metrics import confusion_matrix
from sklearn.metrics import accuracy_score
from sklearn.metrics import classification_report
from sklearn import neighbors, datasets, preprocessing

a=pd.read_csv('C:\Users\kuru\Desktop\car_data.csv')



print(a)#Excell tablosu ekrana yazıldı.


a.head(30)

a.shape

xpoint=np.array(a[['Age','AnnualSalary']])
ypoint=np.array(a[['Purchased','User ID']])

plt.scatter(xpoint,ypoint, color='yellow')

a.value_counts('Gender')

a.value_counts("Age")

a.info

x= a.iloc[:, [2,3]].values
print(x)

y=a.iloc[:,4].values
print(y)

d={'Male':1,'Female':2}
a['Gender']=a['Gender'].map(d)

train,test = train_test_split(a, test_size=0.25, random_state=1)
x_train = train[['Age','AnnualSalary']]
y_train = train['Purchased']
x_test = test[['Age','AnnualSalary']]
y_test = test['Purchased']

scaler = preprocessing.StandardScaler().fit(x_train)
x_train = scaler.transform(x_train)
x_test = scaler.transform(x_test)

knn = neighbors.KNeighborsClassifier(n_neighbors=3)
knn.fit(x_train, y_train)
y_pred = knn.predict(x_test)

print(accuracy_score(y_test, y_pred))
#print(classification_report(y_test, y_pred))
#print(confusion_matrix(y_test, y_pred))

siniflandirma_model =KNeighborsClassifier(n_neighbors=5, metric='minkowski', p=2 )
siniflandirma_model.fit(x_train,y_train)

siniflandirma= KNeighborsClassifier(n_neighbors=5, metric='minkowski', p=2 )
siniflandirma.fit(x_train, y_train)

print(siniflandirma.predict([[30,10000]]))

train,test = train_test_split(a, test_size=0.25, random_state=1)
x_train = train[['Age','Gender']]
y_train = train['Purchased']
x_test = test[['Age','Gender']]
y_test = test['Purchased']

siniflandirma= KNeighborsClassifier(n_neighbors=5, metric='minkowski', p=2 )
siniflandirma.fit(x_train, y_train)

siniflandirma_accuracy = accuracy_score(y_test, tree_model.predict(x_test), normalize=True, sample_weight=None)
cm = confusion_matrix(Y_test,siniflandirma_model.predict(X_test))
siniflandirma_accuracy

print(siniflandirma.predict([[30,1]]))

sn.scatterplot(data=a, x="Age", y="AnnualSalary", hue="Purchased") #yaş ve yıllık maaşa göre alım çizelgesi

from sklearn.neighbors import NearestNeighbors

deneme = NearestNeighbors(n_neighbors=1,radius=1,algorithm='auto', leaf_size=30, metric='minkowski', p=2, metric_params=None, n_jobs=None)

dizi=np.array(a[['Age','AnnualSalary','Purchased']])

deneme.fit(dizi)

plt.scatter(dizi["Age"],dizi["AnnualSalary"],c="blue")
plt.show()

print(dizi)

print(deneme.kneighbors([[10., 40000., 0.]],return_distance=False))

print(deneme.kneighbors([[10., 40000., 0.]],return_distance=True))

t=deneme.kneighbors_graph([[10., 40000., 0.]])#csr formatında dizi olusturuluyor.
t.toarray()

print(t)

     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.