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 pip 常用命令匯總2. jsp實現(xiàn)局部刷新頁面、異步加載頁面的方法3. AJAX原理以及axios、fetch區(qū)別實例詳解4. 純CSS實現(xiàn)鼠標(biāo)放上去改變文字內(nèi)容5. asp讀取xml文件和記數(shù)6. 使用css實現(xiàn)全兼容tooltip提示框7. Python的flask接收前臺的ajax的post數(shù)據(jù)和get數(shù)據(jù)的方法8. 關(guān)于Intellij idea 報錯:Error : java 不支持發(fā)行版本5的問題9. Hadoop 使用IntelliJ IDEA 進行遠程調(diào)試代碼的配置方法10. 本站用的rss輸出
