樹心幽徑

« 20191018用python的pip模組裝pyinstaller用以製作windows系統下的可執行檔(EXE) | Main | 20191021製作純文字格式的影像檔並安裝GIMP來顯示 »

20191021用python執行k近鄰分類、k-平均聚類、標註傳播
2019/10/21,09:09

REF : NTU ccCLUB Python 入門

(1)安裝pip

python -m pip install --upgrade pip

(2) 用pip 裝numpy 陣列模組

C:\Users\USER\AppData\Local\Programs\Python\Python37\Scripts\pip3.7.exe  install numpy
:

Successfully installed numpy-1.17.3

(3)用pip裝matplotlib

C:\Users\USER\AppData\Local\Programs\Python\Python37\Scripts\pip3.7.exe  install matplotlib

:

Installing collected packages: six, cycler, kiwisolver, python-dateutil, pyparsing, matplotlib
Successfully installed cycler-0.10.0 kiwisolver-1.1.0 matplotlib-3.1.1 pyparsing-2.4.2 python-dateutil-2.8.0 six-1.12.0

(4)用pip裝sklearn

C:\Users\USER\AppData\Local\Programs\Python\Python37\Scripts\pip3.7.exe  install sklearn

:

Successfully installed joblib-0.14.0 scikit-learn-0.21.3 scipy-1.3.1 sklearn-0.0

(5-0)自https://scikit-learn.org下載k近鄰分類模擬程式

(5-1)將上方程式碼拷入記事本並存為d:\knbc.py

(6-1)執行 python knbc.py結果如下:

alt

 

 

(7-1)編寫如下程式碼並存為D:\kmean.py
下載 (448 bytes) | created 28 十月, 2019
(7-2)執行 python kmean.py結果如下:
k=2
alt


k=3
alt

(8-1)標註傳播 https://scikit-learn.org/stable/modules/label_propagation.html#label-propagation

(8-2) 程式碼 knn.py
下載 (2 KB) | created 28 十月, 2019


(8-3)執行 python knn.py結果如下:
alt

迴響

 
Accessible and Valid XHTML 1.0 Strict and CSS Powered by LifeType