python實(shí)點(diǎn)云分割k-means(sklearn)詳解
本文實(shí)例為大家分享了Python實(shí)點(diǎn)云分割k-means(sklearn),供大家參考,具體內(nèi)容如下


植物葉片分割
import numpy as npimport matplotlib.pyplot as pltimport pandas as pdfrom sklearn.cluster import KMeansfrom sklearn.preprocessing import StandardScalerfrom mpl_toolkits.mplot3d import Axes3Ddata = pd.read_csv('jiaaobo1.txt',sep = ' ')data1 = data.iloc[:,0:3]#標(biāo)準(zhǔn)化transfer = StandardScaler()data_new = transfer.fit_transform(data1)data_new#預(yù)估計(jì)流程estimator = KMeans(n_clusters = 10)estimator.fit(data_new)y_pred = estimator.predict(data_new)#也可以不預(yù)測(cè)#cluster = KMeans(n_clusters = 9).fit(data_new)#y_pred = cluster.labels_s#質(zhì)心 #centroid = cluster.cluster_centers_#centroid.shapefig = plt.figure()ax = Axes3D(fig)for i in range(9): ax.scatter3D(data_new[y_pred == i,0],data_new[y_pred == i,1],data_new[y_pred == i,2],marker = '.')ax.view_init(elev = 60,azim = 30)ax.set_zlabel(’Z’)ax.set_ylabel(’Y’)ax.set_xlabel(’X’)plt.show()
以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持好吧啦網(wǎng)。
相關(guān)文章:
1. Java如何基于反射機(jī)制獲取不同的類(lèi)2. php模擬實(shí)現(xiàn)斗地主發(fā)牌3. asp判斷某個(gè)文件是否存在的函數(shù)4. IntelliJ IDEA安裝插件的方法步驟5. 理解PHP5中static和const關(guān)鍵字6. 在IDEA中實(shí)現(xiàn)同時(shí)運(yùn)行2個(gè)相同的java程序7. Android table布局開(kāi)發(fā)實(shí)現(xiàn)簡(jiǎn)單計(jì)算器8. ASP.NET泛型三之使用協(xié)變和逆變實(shí)現(xiàn)類(lèi)型轉(zhuǎn)換9. Vuex localStorage的具體使用10. .NET Core Web APi類(lèi)庫(kù)內(nèi)嵌運(yùn)行的方法

網(wǎng)公網(wǎng)安備