python實點云分割k-means(sklearn)詳解
本文實例為大家分享了Python實點云分割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ù)估計流程estimator = KMeans(n_clusters = 10)estimator.fit(data_new)y_pred = estimator.predict(data_new)#也可以不預(yù)測#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()
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持好吧啦網(wǎng)。
相關(guān)文章:
1. 使用Python webdriver圖書館搶座自動預(yù)約的正確方法2. Python字符串到字節(jié)的轉(zhuǎn)換。雙反斜杠問題3. python 使用事件對象asyncio.Event來同步協(xié)程的操作4. Python 合并拼接字符串的方法5. Python sublime安裝及配置過程詳解6. Python3 json模塊之編碼解碼方法講解7. Linux刪除系統(tǒng)自帶版本Python過程詳解8. Java Long類型對比分析9. ASP.NET MVC使用jQuery ui的progressbar實現(xiàn)進(jìn)度條10. ASP基礎(chǔ)知識VBScript基本元素講解

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