To install Scikit-learn on Windows , You should intall numpy, scipy and matplotlib, first, it seems a little bit tedious. One convenient way to install those 3 commonly used packages, I suggest, is just go to this site. http://www.lfd.uci.edu/~gohlke/pythonlibs/
Find 2 exe files
- Scipy-stack: Scipy‑stack‑14.8.27.win32‑py3.4.exe
- Scikit-learn: scikit‑learn‑0.15.2.win32‑py3.4.exe
After installation, just check it in Python
>>> import sklearn
Here are some pre-jobs I have done after 2 days study. Just for your reference. Enjoy it.
By the way, if you want to construct a real-time system, you need use the camera to capture a real image. You can use pygame module, which can be found here.
- pygame: pygame‑1.9.2a0.win32‑py3.4.exe
以上程式 rySklearn001.py 會呼叫 fetch_mldata 函式,
The above python program will call fetch_mldata function,
這個函式 存於 C:\Python34\Lib\site-packages\sklearn\datasets\mldata.py
它會自動來以下網站
http://mldata.org/repository/data/download/matlab/mnist-original/
擷取這個檔案,
mnist-original.mat
放在本程式所在的檔案夾之中。
執行以下 python 指令(本程式所提供),
就可看到隨機出現的某張影像。
0 894 0.0
:
以下開始從基礎開始學一下 sklearn 模組。
An introduction to machine learning with scikit-learn
I have found some programs good for beginner.
You should be able to run them and study them first.
(1)
plot_iris_dataset.py
http://scikit-learn.org/stable/auto_examples/datasets/plot_iris_dataset.html
(2)
plot_digits_classification.py
http://scikit-learn.org/stable/auto_examples/plot_digits_classification.html#example-plot-digits-classification-py
(3)
plot_digits_last_image.py
http://scikit-learn.org/stable/auto_examples/datasets/plot_digits_last_image.html#example-datasets-plot-digits-last-image-py
(4)
plot_random_dataset.py
http://scikit-learn.org/stable/auto_examples/datasets/plot_random_dataset.html#example-datasets-plot-random-dataset-py
針對 MNist,完成初步的 Pattern Recognition 任務,
先用 Sklearn 裡面的 Perceptron 來做。
再加碼用 SVM。
Perceptron 得到 65% 正確率。
SVM 得到 100% 正確率!!我們接下來要研究 SVM 的理論。
最後這張是 multi-layer perceptron (back-propagation 的結果。 accuracy= 81%
這個 mlp 是在 github 上找到的,特別針對sklearn寫的。原版程式經 ry 抓了幾隻蟲後暫可執行。
沒有留言:
張貼留言