Texnologiyalari universiteti fan: Ma’lumotlarning intelektual tahlili amaliy ish №3



Download 127,78 Kb.
Sana21.01.2022
Hajmi127,78 Kb.
#396592
Bog'liq
amaliy


O‘ZBEKISTON RESPUBLIKASI AXBOROT TEXNOLOGIYALARI VA

KOMMUNIKATSIYALARINI RIVOJLANTIRISH VAZIRLIGI

MUHAMMAD AL-XORAZMIY NOMIDAGI TOSHKENT AXBOROT

TEXNOLOGIYALARI UNIVERSITETI



Fan: Ma’lumotlarning intelektual tahlili

AMALIY ISH № 3

Guruh: 211-18 KI

Bajardi:Jumanazarov Maxmud

Tekshirdi: Xusanov O'rol



import numpy as np

import pandas as pd

import seaborn as sns

import matplotlib.pyplot as plt

from sklearn.cluster import KMeans

df=pd.read_csv("Mall_Customers.csv")

df.head()

import matplotlib.pyplot as plot

from sklearn.model_selection import train_test_split

from sklearn.metrics import confusion_matrix

plt.scatter(df['Annual Income (k$)'],df["Spending Score (1-100)"])

plt.show()



x=df.iloc[:,3:]

wcss=[]

for i in range(1,11):

kmeans=KMeans(n_clusters=i,init="k-means++",random_state=0)

kmeans.fit(x)

wcss.append(kmeans.inertia_)

plt.plot(range(1,11),wcss)

plt.show()



kmeans = KMeans(5)

kmeans.fit(x)

identified_clusters = kmeans.fit_predict(x)

identified_clusters



data_with_clusters = x.copy()

data_with_clusters['Cluster'] = identified_clusters

data_with_clusters



plt.scatter(data_with_clusters["Annual Income (k$)"],data_with_clusters["Spending Score (1-100)"],c=data_with_clusters['Cluster'],cmap='rainbow')

plt.show



data_with_clusters.to_csv('k-means.csv', index=False)

x = data_with_clusters[['Annual Income (k$)', 'Spending Score (1-100)']]

y = data_with_clusters['Cluster']

from sklearn.neighbors import KNeighborsClassifier

model = KNeighborsClassifier(n_neighbors=3)

X_train, X_test, y_train, y_test = train_test_split(x, y, test_size=0.33, random_state=42)

# Train the model using the training sets

model.fit(X_train,y_train)

#Predict Output

predicted= model.predict([[0,2]]) # 0:Overcast, 2:Mild

print(predicted)

import seaborn as sns

sns.scatterplot(data=data_with_clusters, x="Annual Income (k$)", y="Spending Score (1-100)", hue="Cluster", palette='rainbow')



predicted= model.predict([[0,2]])

#manashu joyida o'zizni ma'lumotlarizdan kelib chiqib qiymatlar yozing. [0,2] ni o'rniga [80,100] va hz.

preds = model.predict(X_test)

confuse = confusion_matrix(y_test, preds)

import seaborn as sns

import matplotlib.pyplot as plt

fig = sns.heatmap(confuse, annot=True)

plt.xlabel('Actual')

plt.ylabel('Predcited')

plt.show()


Download 127,78 Kb.

Do'stlaringiz bilan baham:




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish