SlideShare a Scribd company logo
3. 資料與特徵
43
機器學習=資料+演算法
1. 沒有資料什麼都不能做
2. 有資料但品質不好 (Dirty Data), 可能造成Garbage
In Garbage Out
簡介
44
綱要
資料去那收集
資料清洗 (去蕪存菁)
特徵選擇
特徵距離的計算
資料標準化
資料集分割
1. 自行收集: 做問卷調查、設置感測器收集、..
2. 使用Open Data : 政府或研究機構的開放資料
• https://data.gov.tw
• Kaggle.com
• UCI Machine Learning Repository
3. 各家公司提供的API
• Facebook Graph API, YouTube Data API
4. 網頁爬蟲程式
5. 直接向廠商購買
資料去那收集?
46
1. 資料不完整
2. 資料格式不一致
3. 資料無效
4. 資料重複
資料可能發生的問題
47
Dirty Data
Data Cleaning 資料清洗 (去蕪存菁)
48
1.) 插值法
2.) 插值平均值或中位數
3.) 插值空值
Data Cleaning (cont.)
49
4.) 將名目值量化
5.) 移除異常資料 (remove outlier)
three-sigma rule.
68%數值分布在距離平均值有
1個標準差之內的範圍
資料的特徵 (或稱為屬性) 是否都是有用?!
能減少不必要或無用的特徵進入模型, 可以提升
準確度並且可以降低模型的計算量以提升預測反
應速度.
如何檢驗特徵與目標(target)或特徵與特徵之間之
間的關聯性?
特徵選擇
50
可以衡量兩變數x和y的「線性」相依程度
皮爾森相關係數(Pearson correlation coefficient)
51
=
52
1.) 完全正相關為
即 所有 點會全部落在
45度的直線上
2. ) 某特徵與目標的| | 愈高,
表示此特徵對於目標有較大影響力
實作練習
53
資料間的相似程度 (Similarity)即計算它們的特徵
距離
Distance Metrics:
特徵距離的計算
54
2.) Euclidean Distance:
1.) Manhattan Distance:
x = (x1, x2, x3,..., xn) and y = (y1, y2, y3,…, yn)
n-number of features xi and yi are the features of
vectors x and y respectively, in the two dimensional
vector space.
3.) Cosine Distance:
x1 x2 x3 x4 x5 x6
D1 2 3 4 2 1 15
D2 1 2 2 4 3 51
D3 1 4 5 2 2 35
分別計算 Euclidean Distance
55
d(D1,D2)=
d(D2,D3)=
d(D1,D3)=
 
 
 
距離會被值域較大的特徵所決定
Min-Max Normalization
• Re-scaling the range of a vector to make all elements lie
between 0 and 1
Z-score Standardization
• Subtract the mean and divide by the standard deviation
Feature re-scaling
56
將每個特徵值的尺度轉成一致
~(0,1)
Min-Max Normalization使用時機,
資料的上下界通常是己知的固定值
Example
57
x1 x2 x3 x4 x5 x6
D1 1 0
D2 0 1
D3 0 0.5556
x1 x2 x3 x4 x5 x6
D1 2 3 4 2 1 15
D2 1 2 2 4 3 51
D3 1 4 5 2 2 35
After Min-Max Normalization
距離不會被值域特別大的特徵影響太多
Cosine Similarity
Ch0-58
The Cosine metric is a measurement of orientation
and not magnitude
• Cosine不看magnitude(強度),只在乎2個向量是否具有相
同方向 (且不一定要有相同向量空間).而Euclidean是要是
相同向量空間且magnitude會影響計算的距離.
• Cosine Similarity 常用在文章分類, 因為文章出現關鍵詞
種類愈多比較重要,而不是某一個個關鍵詞出現很多次
(因為很有可能出現的很多次, 其實只是這篇文章寫得比
較長而已)
Use Euclidean Distance or Cosine Similarity ?
59
Numpy: Inner Product/Dot Product
>>> a = np.array([5, 6, 7])
>>> b = np.array([6, 6, 6])
>>> a.dot(b) #向量內積 inner product=>純數
108
>>> np.dot(a,b)
108
>>> c = np.array([[1,2,3],[4,5,6],[7,8,9]]) #二維陣列
>>> c.dot(a) #二維陣列的每行與㇐維向量計算內積
array([ 38, 92, 146])
>>> c[0].dot(a) #兩個㇐維向量計算內積
38
>>> c[1].dot(a)
92
>>> c[2].dot(a)
146
60
Python 實作
61
值愈大, 角度愈小 , 表示很有相關
值愈小, 角度愈大 , 表示愈不相關

More Related Content

PPTX
언리얼을 활용한 오브젝트 풀링
PPTX
이펙트 쉐이더 1강 - Shader 기초 개념
PDF
Unite2019 HLOD를 활용한 대규모 씬 제작 방법
PDF
End-to-End Object Detection with Transformers
PDF
Getting Started with Jetson Nano
PPTX
언리얼 애니메이션.pptx
PDF
PR-214: FlowNet: Learning Optical Flow with Convolutional Networks
PDF
[NDC07] 게임 개발에서의 클라이언트 보안 - 송창규
언리얼을 활용한 오브젝트 풀링
이펙트 쉐이더 1강 - Shader 기초 개념
Unite2019 HLOD를 활용한 대규모 씬 제작 방법
End-to-End Object Detection with Transformers
Getting Started with Jetson Nano
언리얼 애니메이션.pptx
PR-214: FlowNet: Learning Optical Flow with Convolutional Networks
[NDC07] 게임 개발에서의 클라이언트 보안 - 송창규

What's hot (20)

PDF
Transfer Learning (20230516)
 
PDF
5.MLP(Multi-Layer Perceptron)
PDF
Mask R-CNN
PDF
Introduction to Few shot learning
PDF
Tracking Emails
PPTX
CNN 초보자가 만드는 초보자 가이드 (VGG 약간 포함)
PPTX
Mobile_Forensics- General Introduction & Software.pptx
PPTX
오래된 프로젝트에 Jenkins 적용해보기
PPTX
Recast Detour.pptx
PDF
Real-time object detection coz YOLO!
PPTX
Cyber forensic 1
PPTX
Faster R-CNN
PDF
AWS와 Docker Swarm을 이용한 쉽고 빠른 컨테이너 오케스트레이션 - AWS Summit Seoul 2017
PDF
NDC2017 언리얼엔진4 디버깅 101 - 게임 기획자, 프로그래머가 버그와 만났을 때 사용할 수 있는 지침들
PPT
Malware forensics
PDF
210110 deformable detr
PPT
Windows forensic artifacts
PDF
게임서버프로그래밍 #7 - 패킷핸들링 및 암호화
PDF
Android와 Flutter 앱 개발의 큰 차이점 5가지
PPTX
Role of Forensic Triage In Cyber Security Trends 2021
Transfer Learning (20230516)
 
5.MLP(Multi-Layer Perceptron)
Mask R-CNN
Introduction to Few shot learning
Tracking Emails
CNN 초보자가 만드는 초보자 가이드 (VGG 약간 포함)
Mobile_Forensics- General Introduction & Software.pptx
오래된 프로젝트에 Jenkins 적용해보기
Recast Detour.pptx
Real-time object detection coz YOLO!
Cyber forensic 1
Faster R-CNN
AWS와 Docker Swarm을 이용한 쉽고 빠른 컨테이너 오케스트레이션 - AWS Summit Seoul 2017
NDC2017 언리얼엔진4 디버깅 101 - 게임 기획자, 프로그래머가 버그와 만났을 때 사용할 수 있는 지침들
Malware forensics
210110 deformable detr
Windows forensic artifacts
게임서버프로그래밍 #7 - 패킷핸들링 및 암호화
Android와 Flutter 앱 개발의 큰 차이점 5가지
Role of Forensic Triage In Cyber Security Trends 2021
Ad

More from 艾鍗科技 (20)

PPTX
AI 技術浪潮, 什麼是機器學習? 什麼是深度學習, 什麼是生成式AI, AI 能力認證
PDF
TinyML - 4 speech recognition
PPTX
Appendix 1 Goolge colab
PPTX
Project-IOT於餐館系統的應用
PPTX
02 IoT implementation
PPTX
Tiny ML for spark Fun Edge
PDF
Openvino ncs2
PDF
Step motor
PDF
2. 機器學習簡介
PPTX
心率血氧檢測與運動促進
PPTX
利用音樂&情境燈幫助放鬆
PPTX
IoT感測器驅動程式 在樹莓派上實作
PPTX
無線聲控遙控車
PPT
最佳光源的研究和實作
PPTX
無線監控網路攝影機與控制自走車
PPTX
Reinforcement Learning
PPTX
Linux Device Tree
PPTX
人臉辨識考勤系統
PPTX
智慧家庭Smart Home
PPT
智能健身
AI 技術浪潮, 什麼是機器學習? 什麼是深度學習, 什麼是生成式AI, AI 能力認證
TinyML - 4 speech recognition
Appendix 1 Goolge colab
Project-IOT於餐館系統的應用
02 IoT implementation
Tiny ML for spark Fun Edge
Openvino ncs2
Step motor
2. 機器學習簡介
心率血氧檢測與運動促進
利用音樂&情境燈幫助放鬆
IoT感測器驅動程式 在樹莓派上實作
無線聲控遙控車
最佳光源的研究和實作
無線監控網路攝影機與控制自走車
Reinforcement Learning
Linux Device Tree
人臉辨識考勤系統
智慧家庭Smart Home
智能健身
Ad

3. data features