SlideShare uma empresa Scribd logo
1 de 45
Baixar para ler offline
15/8/12 NCKU TienYang
kaggle-預測未來腳踏⾞車租借數量
supervised learning
unsupervised learning
supervised learning unsupervised learning
classification v.s clustering
• Data is not labeled
• Group pointed that are “close” to each other
• Unsupervised learning
• Labeled data points
• Want a “rule” that assigns labels to new points
• Supervised learning
supervised learning v.s unsupervised learning
classification v.s clustering
supervised learning v.s unsupervised learning
classification v.s clustering
此演算法在2007年IEEE統計排名前⼗十名資料採
礦演算法之⼀一,以⽬目前來說是廣泛使⽤用、︑、⾮非
常有效⽽而且是易於掌握的演算法。︒。
此演算法在2007年IEEE統計排名前⼗十名資料採
礦演算法之⼀一,以⽬目前來說是廣泛使⽤用、︑、⾮非
常有效⽽而且是易於掌握的演算法。︒。


⾝身⾼高 體重 label
A 180 90 ⼤大隻
B 175 85 ⼤大隻
C 160 45 ⼩小⽀支
D 165 50 ⼩小⽀支
A
⾝身⾼高
體重
B
C
D
⼤大隻
⼩小⽀支
資料
現在加⼊入了⼀一個
⾝身⾼高190 體重100 他會
是哪⼀一類?
A
⾝身⾼高
體重
B
C
D
⼤大隻
⼩小⽀支
E
⾝身⾼高 體重 label
A 180 90 ⼤大隻
B 175 85 ⼤大隻
C 160 45 ⼩小⽀支
D 165 50 ⼩小⽀支
A
⾝身⾼高
體重
B
C
D
⼤大隻
⼩小⽀支
⽤用膝蓋想都知道 是屬於⼤大隻 !
E
E
1. 先找k個最近鄰居
2. 鄰居決定分類
Euclidean distance
⾝身⾼高 體重 label
A 180 90 ⼤大隻
B 175 85 ⼤大隻
C 160 45 ⼩小⽀支
D 165 50 ⼩小⽀支
E ⾝身⾼高190 體重100
AE 和 的距離
( 190 - 180 )2 + ( 100 -90 )2
200
Euclidean distance
誰最近呢?
⾝身⾼高 體重 label
A 180 90 ⼤大隻
B 175 85 ⼤大隻
C 160 45 ⼩小⽀支
D 165 50 ⼩小⽀支
E 和⼤大夥的距離
200
450
3925
3125
E A和 最近,所以A是⼤大隻
那E也是⼤大隻
Brute Force
N samples in D dimensions
N = 4 D = 2
⾝身⾼高 體重 label
A 180 90 ⼤大隻
B 175 85 ⼤大隻
C 160 45 ⼩小⽀支
D 165 50 ⼩小⽀支
找出所有距離 N*D
找出最近的點 N
時間複雜度
O [ DN2 ]
K-D Tree
⾝身⾼高 體重 label
A 180 90 ⼤大隻
B 175 85 ⼤大隻
C 160 45 ⼩小⽀支
D 165 50 ⼩小⽀支
165
180
175160
190
K-D Tree
⾝身⾼高 體重 label
A 180 90 ⼤大隻
B 175 85 ⼤大隻
C 160 45 ⼩小⽀支
D 165 50 ⼩小⽀支
165,50
180,90
175,85
160,45
190,100
⽐比⾝身⾼高
⽐比體重
時間複雜度
O [ DN logN ]
Where KD trees partition data along
Cartesian axes, ball trees partition data
in a series of nesting hyper-spheres.
A房⼦子:200坪,⽤用10年,10元的畫
B房⼦子:50坪,⽤用10年,10萬元的畫
C房⼦子:199坪,⽤用10年,9萬元的畫
A房⼦子:200坪,⽤用10年,10元的畫
B房⼦子:50坪,⽤用10年,100000元的畫
C房⼦子:199坪,⽤用10年,90000元的畫
C房⼦子離B房⼦子⽐比較近,所以B,C的房價⼀一樣
A房⼦子:200坪,⽤用10年,10元的畫
B房⼦子:50坪,⽤用10年,10萬元的畫
C房⼦子:199坪,⽤用10年,9萬元的畫
C房⼦子離B房⼦子⽐比較近,所以B,C的房價⼀一樣
聽你在放屁,A,C的房價要差不多才對,因為坪數差不多
Euclidean distance 的缺點,不同維度會等同看待
可以解決不同維度會等同看待的問題
Mahalanobis distance
旋轉座標軸
?
我覺得雖然?
有四票,但是他離藍⾊色真的太近了
這樣很不公平
weights:距離的反⽐比
?1
10
10
10
10
score: 1/1
score: (1/10)*4 =2/5
?
You must predict the total count of bikes
rented during each hour
datetime hourly date + timestamp
season
1 = spring, 2 = summer, 3 = fall, 4 =
winter
weather
1: Clear, Few clouds, Partly cloudy,
Partly cloudy
2: Mist + Cloudy, Mist + Broken
temp temperature in Celsius
humidity relative humidity
windspeed wind speed
holiday
whether the day is considered a
holiday
workingday
whether the day is neither a
weekend nor holiday
資料分析
資料探勘&機器學習地表最強
https://github.com/wy36101299/knn-Bike-Sharing-Demand
scikit-learn
http://scikit-learn.org/stable/modules/neighbors.html
[Machine Learning] kNN分類演算法« Big O(1)
http://enginebai.logdown.com/posts/241676/knn
pandas: powerful Python data analysis toolkit
http://pandas.pydata.org/pandas-docs/stable/

Mais conteúdo relacionado

Mais procurados

公平性を保証したAI/機械学習
アルゴリズムの最新理論
公平性を保証したAI/機械学習
アルゴリズムの最新理論公平性を保証したAI/機械学習
アルゴリズムの最新理論
公平性を保証したAI/機械学習
アルゴリズムの最新理論Kazuto Fukuchi
 
Counterfaual Machine Learning(CFML)のサーベイ
Counterfaual Machine Learning(CFML)のサーベイCounterfaual Machine Learning(CFML)のサーベイ
Counterfaual Machine Learning(CFML)のサーベイARISE analytics
 
友人関係と感染症伝搬をネットワークで理解する
友人関係と感染症伝搬をネットワークで理解する友人関係と感染症伝搬をネットワークで理解する
友人関係と感染症伝搬をネットワークで理解するtm1966
 
統計勉強会 分割表とカイ二乗検定
統計勉強会 分割表とカイ二乗検定統計勉強会 分割表とカイ二乗検定
統計勉強会 分割表とカイ二乗検定Satoshi Nagayasu
 
グラフィカル Lasso を用いた異常検知
グラフィカル Lasso を用いた異常検知グラフィカル Lasso を用いた異常検知
グラフィカル Lasso を用いた異常検知Yuya Takashina
 
[DL輪読会]Randomized Prior Functions for Deep Reinforcement Learning
[DL輪読会]Randomized Prior Functions for Deep Reinforcement Learning[DL輪読会]Randomized Prior Functions for Deep Reinforcement Learning
[DL輪読会]Randomized Prior Functions for Deep Reinforcement LearningDeep Learning JP
 
基底変換、固有値・固有ベクトル、そしてその先
基底変換、固有値・固有ベクトル、そしてその先基底変換、固有値・固有ベクトル、そしてその先
基底変換、固有値・固有ベクトル、そしてその先Taketo Sano
 
強化学習その1
強化学習その1強化学習その1
強化学習その1nishio
 
強化学習その2
強化学習その2強化学習その2
強化学習その2nishio
 
Reinforcement Learning @ NeurIPS2018
Reinforcement Learning @ NeurIPS2018Reinforcement Learning @ NeurIPS2018
Reinforcement Learning @ NeurIPS2018佑 甲野
 
【DL輪読会】Patches Are All You Need? (ConvMixer)
【DL輪読会】Patches Are All You Need? (ConvMixer)【DL輪読会】Patches Are All You Need? (ConvMixer)
【DL輪読会】Patches Are All You Need? (ConvMixer)Deep Learning JP
 
TorchDataチュートリアル解説
TorchDataチュートリアル解説TorchDataチュートリアル解説
TorchDataチュートリアル解説西岡 賢一郎
 
古典的ゲームAIを用いたAlphaGo解説
古典的ゲームAIを用いたAlphaGo解説古典的ゲームAIを用いたAlphaGo解説
古典的ゲームAIを用いたAlphaGo解説suckgeun lee
 
最適輸送入門
最適輸送入門最適輸送入門
最適輸送入門joisino
 
DeepLearning 14章 自己符号化器
DeepLearning 14章 自己符号化器DeepLearning 14章 自己符号化器
DeepLearning 14章 自己符号化器hirono kawashima
 

Mais procurados (20)

公平性を保証したAI/機械学習
アルゴリズムの最新理論
公平性を保証したAI/機械学習
アルゴリズムの最新理論公平性を保証したAI/機械学習
アルゴリズムの最新理論
公平性を保証したAI/機械学習
アルゴリズムの最新理論
 
Relative attributes
Relative attributesRelative attributes
Relative attributes
 
Counterfaual Machine Learning(CFML)のサーベイ
Counterfaual Machine Learning(CFML)のサーベイCounterfaual Machine Learning(CFML)のサーベイ
Counterfaual Machine Learning(CFML)のサーベイ
 
RAPiD
RAPiDRAPiD
RAPiD
 
友人関係と感染症伝搬をネットワークで理解する
友人関係と感染症伝搬をネットワークで理解する友人関係と感染症伝搬をネットワークで理解する
友人関係と感染症伝搬をネットワークで理解する
 
統計勉強会 分割表とカイ二乗検定
統計勉強会 分割表とカイ二乗検定統計勉強会 分割表とカイ二乗検定
統計勉強会 分割表とカイ二乗検定
 
グラフィカル Lasso を用いた異常検知
グラフィカル Lasso を用いた異常検知グラフィカル Lasso を用いた異常検知
グラフィカル Lasso を用いた異常検知
 
[DL輪読会]Randomized Prior Functions for Deep Reinforcement Learning
[DL輪読会]Randomized Prior Functions for Deep Reinforcement Learning[DL輪読会]Randomized Prior Functions for Deep Reinforcement Learning
[DL輪読会]Randomized Prior Functions for Deep Reinforcement Learning
 
基底変換、固有値・固有ベクトル、そしてその先
基底変換、固有値・固有ベクトル、そしてその先基底変換、固有値・固有ベクトル、そしてその先
基底変換、固有値・固有ベクトル、そしてその先
 
強化学習その1
強化学習その1強化学習その1
強化学習その1
 
強化学習その2
強化学習その2強化学習その2
強化学習その2
 
Reinforcement Learning @ NeurIPS2018
Reinforcement Learning @ NeurIPS2018Reinforcement Learning @ NeurIPS2018
Reinforcement Learning @ NeurIPS2018
 
【DL輪読会】Patches Are All You Need? (ConvMixer)
【DL輪読会】Patches Are All You Need? (ConvMixer)【DL輪読会】Patches Are All You Need? (ConvMixer)
【DL輪読会】Patches Are All You Need? (ConvMixer)
 
TorchDataチュートリアル解説
TorchDataチュートリアル解説TorchDataチュートリアル解説
TorchDataチュートリアル解説
 
古典的ゲームAIを用いたAlphaGo解説
古典的ゲームAIを用いたAlphaGo解説古典的ゲームAIを用いたAlphaGo解説
古典的ゲームAIを用いたAlphaGo解説
 
最適輸送入門
最適輸送入門最適輸送入門
最適輸送入門
 
Group normalization
Group normalizationGroup normalization
Group normalization
 
ゼロから始める転移学習
ゼロから始める転移学習ゼロから始める転移学習
ゼロから始める転移学習
 
DeepLearning 14章 自己符号化器
DeepLearning 14章 自己符号化器DeepLearning 14章 自己符号化器
DeepLearning 14章 自己符号化器
 
Chokudai search
Chokudai searchChokudai search
Chokudai search
 

Mais de Tien-Yang (Aiden) Wu (14)

Hidden markov model
Hidden markov modelHidden markov model
Hidden markov model
 
Scalable machine learning
Scalable machine learningScalable machine learning
Scalable machine learning
 
Scalable sentiment classification for big data analysis using naive bayes cla...
Scalable sentiment classification for big data analysis using naive bayes cla...Scalable sentiment classification for big data analysis using naive bayes cla...
Scalable sentiment classification for big data analysis using naive bayes cla...
 
Collaborative filtering
Collaborative filteringCollaborative filtering
Collaborative filtering
 
Collaborative Filtering Recommendation Algorithm based on Hadoop
Collaborative Filtering Recommendation Algorithm based on HadoopCollaborative Filtering Recommendation Algorithm based on Hadoop
Collaborative Filtering Recommendation Algorithm based on Hadoop
 
Parallel-kmeans
Parallel-kmeansParallel-kmeans
Parallel-kmeans
 
K means
K meansK means
K means
 
RDD
RDDRDD
RDD
 
Semantic ui教學
Semantic ui教學Semantic ui教學
Semantic ui教學
 
響應式網頁教學
響應式網頁教學響應式網頁教學
響應式網頁教學
 
NoSQL & JSON
NoSQL & JSONNoSQL & JSON
NoSQL & JSON
 
Weebly上手教學
Weebly上手教學Weebly上手教學
Weebly上手教學
 
簡易爬蟲製作和Pttcrawler
簡易爬蟲製作和Pttcrawler簡易爬蟲製作和Pttcrawler
簡易爬蟲製作和Pttcrawler
 
Python簡介和多版本虛擬環境架設
Python簡介和多版本虛擬環境架設Python簡介和多版本虛擬環境架設
Python簡介和多版本虛擬環境架設
 

沒有想像中簡單的簡單分類器 Knn