Machine Learning and Deep Learning Laboratory 1 Python clustering report



Download 421,78 Kb.
Pdf ko'rish
Sana13.07.2022
Hajmi421,78 Kb.
#784768
Bog'liq
Laboratory 1 Python clustering report



Machine Learning and Deep Learning 
 
Laboratory 1 
Python clustering report 
 
 
 
 
 
 
 
 
WSB University
Laura Rakhimberdina ID 45069
Sabahaddin Mirzayev ID 44926 
Botirjon Yokubjonov ID 44699 
Ida Godwin Ogah ID 45086 
Students of the third semester - 
Master’s degree 
 
Computer Science 

 International 
 
 
Python clustering 
 


1.
Generate an example set of points on a plane (10,000 points), and then 
present it graphically 
pd.options.display.max_columns = 30 
X, y_true = make_blobs(n_samples=1000, centers=3, cluster_std=0.99, 
random_state=3042019) 
df = pd.DataFrame(X, columns = ['f1', 'f2']) 
df.head() 
sns.lmplot(data=df, x='f1', y='f2', fit_reg=False, scatter_kws={"color": 
"#eb6c6a"}).set(title = 'Random Data Set') 
plt.show() 


2. Using the k-means algorithm, on the basis of the generated data set, present 
the operation of the clustering algorithm. How were the individual points 
divided? 
kmeans = KMeans(n_clusters=3) 
kmeans.fit(df) 
y_kmeans = kmeans.predict(df) 
df['sklearn_cluster'] = y_kmeans 
sklearn_centers = kmeans.cluster_centers_ 
sns.lmplot(data=df, x='f1', y='f2', fit_reg=False, hue = 'sklearn_cluster', palette = 
['#eb6c6a', '#6aeb6c', '#6c6aeb']).set(title='Detected groups') 
plt.scatter(sklearn_centers[:, 0], sklearn_centers[:, 1], c='black', s=100, 
alpha=0.5) 
plt.show() 


3. Present the code that allows you to import data into DataFrames from an 
excel file 
customer_data_file = 'C:/Users/msebo/OneDrive/Desktop/NWSP2.xlsx' 
customers = pd.read_excel(customer_data_file, 
sheet_name='Arkusz1', 
header=0, 
index_col=False, 
keep_default_na=True 

customers.head() 


4. Run the clustering algorithm on real data


5. Show the relationship between the clusters obtained and the values of the 
coefficients in the job column. 
kmeansCl = KMeans(n_clusters=3) 
kmeansCl.fit(customers) 
y_kmeans = kmeansCl.predict(customers) 
customers['sklearn_cluster'] = y_kmeans 
sklearn_centers = kmeansCl.cluster_centers_ 
sns.lmplot(data=customers, x='Job', y='Nwsp', fit_reg=False, hue = 
'sklearn_cluster', palette = ['#eb6c6a', '#6aeb6c', '#6c6ceb', '#ebdc6a', 
'#6aebec', '#6cfaeb', '#eb6a6a', '#6beb6c', '#6ffaeb', '#eb6cba', '#6aae6c', 
'#6c6ffb']).set(title='Wizualizacja grup') 
plt.scatter(sklearn_centers[:, 0], sklearn_centers[:, 1], c='black', s=100, 
alpha=0.5) 
plt.show() 

Download 421,78 Kb.

Do'stlaringiz bilan baham:




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©www.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