淡路地区 海岸ゾーン Park-PFI事業 事業概要淡路花博2010 淡路会場※の 来場者数78万人 平成15年4月 第2期開園 (6.2ha) 芝生広場、 移ろいの庭
連淡水阿嬤都聽得懂的機器學習入門 scikit-learn
-
Upload
cicilia-lee -
Category
Engineering
-
view
2.773 -
download
4
Transcript of 連淡水阿嬤都聽得懂的機器學習入門 scikit-learn
給門外漢的機器學習入門描述 程度
Level 1 不知道什麼是機器學習 門外漢 (O)Level 2 知道機器學習是 AI 的子學門Level 3 會使用機器學習套件解問題 初學者Level 4 會選擇適合的機器學習演算法與調參數Level 5 知道機器學習演算法的數學原理 專家Level 6 會設計新的機器學習演算法
2Cicilia Lee @ PyCon TW 2016
大綱1. 什麼是機器學習?2. 機器學習的分類3. 機器學習流程4. Scikit-learn 範例5. Scikit Learn 數字辨識步驟6. 前處理7. 選擇機器學習演算法 3
Cicilia Lee @ PyCon TW 2016
什麼是機器學習? 我們有大量的樣本資料 (sample data) ,讓機器自動從中學習出規則,用來預測其他未知的資料。 機器學習是基於機率、統計、逼近論等數學理論的研究。 機器學習可應用於電腦視覺、自然語言處理、語音和手寫識別和機器人等領域。
Cicilia Lee @ PyCon TW 20164
機器學習的分類 Supervised Learning 監督式學習
訓練集的目標是人為標註的。Classification 分類 : 預測類別Regression 回歸 : 預測變量
Unsupervised Learning 非監督式學習訓練集沒有人為標註的目標。Clustering 分群
5Cicilia Lee @ PyCon TW 2016
Scikit Learn 數字辨識範例
這個範例用來展示 scikit-learn 如何用 SVM演算法來達成手寫的數字辨識 http://scikit-learn.org/stable/auto_examples/classificati
on/plot_digits_classification.html
Cicilia Lee @ PyCon TW 20167
Scikit Learn 數字辨識步驟1. Load data2. Set a classifier3. Learn a model4. Predict the result5. Evaluate
Cicilia Lee @ PyCon TW 20168
Scikit Learn 數字辨識 (1/3)# Import datasets, classifiers and performance metricsfrom sklearn import datasets, svm, metrics
### 1. Load data# The digits datasetdigits = datasets.load_digits()# To apply a classifier on this data, we need to flatten the image, to# turn the data in a (samples, feature) matrix:n_samples = len(digits.images)data = digits.images.reshape((n_samples, -1)) 9
Cicilia Lee @ PyCon TW 2016
Scikit Learn 數字辨識 (2/3)### 2. Set a classifier# Create a classifier: a support vector classifierclassifier = svm.SVC(gamma=0.001)
### 3. Learn a model# We learn the digits on the first half of the digitsclassifier.fit(data[:n_samples / 2], digits.target[:n_samples / 2])
10Cicilia Lee @ PyCon TW 2016
Scikit Learn 數字辨識 (3/3)### 4. Predict the result# Now predict the value of the digit on the second half:expected = digits.target[n_samples / 2:] predicted = classifier.predict(data[n_samples / 2:])
### 5. Evaluateprint("Classification report for classifier %s:\n%s\n" % (classifier, metrics.classification_report(expected, predicted)))print("Confusion matrix:\n%s" % metrics.confusion_matrix(expected, predicted))
11Cicilia Lee @ PyCon TW 2016
Script output (1/2) Classification report for classifier SVC(C=1.0, cache_size=200, class_weight=None, coef0=0.0, decision_function_shape=None, degree=3, gamma=0.001, kernel='rbf', max_iter=-1, probability=False, random_state=None, shrinking=True, tol=0.001, verbose=False): precision recall f1-score support 0 1.00 0.99 0.99 88 1 0.99 0.97 0.98 91 2 0.99 0.99 0.99 86 3 0.98 0.87 0.92 91 4 0.99 0.96 0.97 92 5 0.95 0.97 0.96 91 6 0.99 0.99 0.99 91 7 0.96 0.99 0.97 89 8 0.94 1.00 0.97 88 9 0.93 0.98 0.95 92
avg / total 0.97 0.97 0.97 899 12Cicilia Lee @ PyCon TW 2016
Script output (2/2)Confusion matrix:[[87 0 0 0 1 0 0 0 0 0] [ 0 88 1 0 0 0 0 0 1 1] [ 0 0 85 1 0 0 0 0 0 0] [ 0 0 0 79 0 3 0 4 5 0] [ 0 0 0 0 88 0 0 0 0 4] [ 0 0 0 0 0 88 1 0 0 2] [ 0 1 0 0 0 0 90 0 0 0] [ 0 0 0 0 0 1 0 88 0 0] [ 0 0 0 0 0 0 0 0 88 0] [ 0 0 0 1 0 1 0 0 0 90]] 13
Cicilia Lee @ PyCon TW 2016
前處理1. Clean data2. Feature extraction3. Convert category and string to
number4. Sparse data5. Feature selection
14Cicilia Lee @ PyCon TW 2016
選擇機器學習演算法
15Cicilia Lee @ PyCon TW 2016
複習1. 什麼是機器學習?2. 機器學習的分類3. 機器學習流程4. Scikit-learn 範例5. Scikit Learn 數字辨識步驟6. 前處理7. 選擇機器學習演算法 16
Cicilia Lee @ PyCon TW 2016
Thank you Reference
Scikit-learn 官網:http://scikit-learn.org/stable/index.html
Scikit-learn 數字範例http://scikit-learn.org/stable/auto_examples/classification/plot_digits_classification.html
選擇機器學習演算法http://scikit-learn.org/stable/tutorial/machine_learning_map/index.html
林軒田教授的機器學習教學影片https://www.youtube.com/playlist?list=PLXVfgk9fNX2I7tB6oIINGBmW50rrmFTqf Cicilia Lee @ PyCon TW 2016
17