TIL | Clustering์ด๋ž€?

[ AI / ML ] ๋จธ์‹ ๋Ÿฌ๋‹ - ๊ตฐ์ง‘ํ™” (Clustering)

๐Ÿ‘ฉ๐Ÿปโ€๐Ÿ’ป K-MOOC ์‹ค์Šต์œผ๋กœ ๋ฐฐ์šฐ๋Š” ๋จธ์‹ ๋Ÿฌ๋‹ ๊ฐ•์˜

๐Ÿ“™ ํ•ด๋‹น ํฌ์ŠคํŠธ๋Š” K-MOOC ๊ฐ•์˜ ๋‚ด์šฉ๊ณผ ์ถ”๊ฐ€๋กœ ๋‹ค๋ฅธ ์ž๋ฃŒ๋“ค์„ ์ฐพ์•„ ๋‚ด์šฉ์„ ์ž‘์„ฑํ•˜์˜€์œผ๋ฉฐ, ์ด๋ก  ๋ฐ ๊ฐœ๋…์— ๋Œ€ํ•ด ๊ณต๋ถ€ํ•˜๊ณ  ์˜ˆ์ œ ์‹ค์Šต๋„ ์ง„ํ–‰ํ•œ ํ›„ ๋‚ด์šฉ์„ ์ •๋ฆฌํ•˜์˜€๋‹ค.

[ AI ] ์ธ๊ณต์ง€๋Šฅ๊ณผ ๋จธ์‹ ๋Ÿฌ๋‹, ๊ทธ๋ฆฌ๊ณ  ๋”ฅ๋Ÿฌ๋‹์™€ ๊ฐ™์€ ๋‚  ์ž‘์„ฑ๋œ ํฌ์ŠคํŠธ์ด๋‹ค.


1. ๊ตฐ์ง‘ํ™” Clustering

์œ ์‚ฌํ•œ ์†์„ฑ๋“ค์„ ๊ฐ–๋Š” ๊ด€์ธก์น˜๋ฅผ ๋ฌถ์–ด ์ „์ฒด ๋ฐ์ดํ„ฐ๋ฅผ ๋ช‡ ๊ฐœ์˜ ๊ตฐ์ง‘ (๊ทธ๋ฃน) ์œผ๋กœ ๋‚˜๋ˆ„๋Š” ๊ฒƒ์„ ๊ตฐ์ง‘ํ™”๋ผ ํ•œ๋‹ค.

  • ๊ตฐ์ง‘ํ™” ๊ธฐ์ค€
    • ๊ตฐ์ง‘ ๋‚ด ์œ ์‚ฌ๋„ ์ตœ๋Œ€ํ™”
      • ๋™์ผํ•œ ๊ตฐ์ง‘์— ์†ํ•œ ๊ด€์ธก์น˜๋“ค์€ ์„œ๋กœ ์œ ์‚ฌํ• ์ˆ˜๋ก ์ข‹์Œ
    • ๊ตฐ์ง‘ ๊ฐ„ ์œ ์‚ฌ๋„ ์ตœ์†Œํ™”
      • ์ƒ์ดํ•œ ๊ตฐ์ง‘์— ์†ํ•œ ๊ด€์ธก์น˜๋“ค์€ ์„œ๋กœ ๋‹ค๋ฅผ์ˆ˜๋ก ์ข‹์Œ

2. ๋ถ„๋ฅ˜์™€ ๊ตฐ์ง‘ํ™”๋Š” ์–ด๋–ป๊ฒŒ ๋‹ค๋ฅผ๊นŒ?

  • ๋ถ„๋ฅ˜ Classification
    • ์‚ฌ์ „ ์ •์˜๋œ ๋ฒ”์ฃผ๊ฐ€ ์žˆ๋Š” labeled data๋กœ๋ถ€ํ„ฐ ์˜ˆ์ธก ๋ชจ๋ธ์„ ํ•™์Šตํ•˜๋Š” ๋ฌธ์ œ
    • Supervised Learning (์ง€๋„ ํ•™์Šต)
  • ๊ตฐ์ง‘ํ™” Clustering
    • ์‚ฌ์ „ ์ •์˜๋œ ๋ฒ”์ฃผ๊ฐ€ ์—†๋Š” unlabeled data์—์„œ ์ตœ์ ์˜ ๊ทธ๋ฃน์„ ์ฐพ์•„๋‚˜๊ฐ€๋Š” ๋ฌธ์ œ
    • Unsupervised Learning (๋น„์ง€๋„ ํ•™์Šต)

3. ๊ตฐ์ง‘ํ™” ํ™œ์šฉ Application

๊ตฐ์ง‘ํ™”๋Š” ํŠนํžˆ ์„ธ๋ถ„ํ™” Segmentation์—์„œ ํ™œ์šฉ๋œ๋‹ค.

  • E-commerce
    • ์˜จ๋ผ์ธ ์‡ผํ•‘๋ชฐ
      • ๊ณ ๊ฐ ํŠน์ • ์œ ํ˜•์œผ๋กœ ๋ถ„๋ฅ˜ โžก๏ธ ๋งž์ถค ์„œ๋น„์Šค ์ œ๊ณต
      • ์ƒˆ๋กœ์šด ๊ณ ๊ฐ ์œ ํ˜• ๋ฐœ๊ฒฌ โžก๏ธ ๋งˆ์ผ€ํŒ… ์ „๋žต์— ํ™œ์šฉ
  • ์œ ์‚ฌ ๋ฌธ์„œ ๊ตฐ์ง‘ํ™”

  • ์„œ์šธ์‹œ ์˜ค์กด ๋†๋„์˜ ํŒจํ„ด ๊ตฐ์ง‘ํ™” (25๊ฐœ ๊ตฌ)

  • Tracking
    • ์ด๋ฏธ์ง€ / ์˜์ƒ
  • Anomaly detection
    • ์ด์ƒ๊ฒ€์ถœ
    • ์ œ์กฐ / ๋ฌผ๋ฅ˜ ๋ถ„์•ผ
    • ๋ฐ˜๋„์ฒด ์›จ์ดํผ์˜ fail bit map ๊ตฐ์ง‘ํ™”

4. ๊ตฐ์ง‘ํ™” ์•Œ๊ณ ๋ฆฌ์ฆ˜ Clustering Algorithm

  • K-Means (Centroid)
  • Hierarchical
  • DBSCAN (๋ฐ€๋„)

โœ”๏ธ K-Means (Centroid)

K-Means๋Š” ๊ตฐ์ง‘ ์ค‘์‹ฌ์  Centroid ๊ธฐ๋ฐ˜์˜ ํด๋Ÿฌ์Šคํ„ฐ๋ง ์ค‘ ํ•˜๋‚˜๋กœ, ์ผ๋ฐ˜์ ์œผ๋กœ ๊ฐ€์žฅ ์‰ฝ๊ณ  ๋งŽ์ด ์‚ฌ์šฉ๋˜๋Š” ์•Œ๊ณ ๋ฆฌ์ฆ˜์ด๋‹ค.

์˜ˆ๋ฅผ ๋“ค์–ด, A,B,C,D,E,F ์™€ ๊ฐ™์ด 5๊ฐœ์˜ ๋ฐ์ดํ„ฐ ์„ธํŠธ๊ฐ€ ์ฃผ์–ด์ง€๊ณ  2๊ฐœ์˜ ๊ตฐ์ง‘์„ ํ˜•์„ฑ์‹œํ‚ค๊ณ  ์‹ถ๋‹ค.


  1. ๋จผ์ € ์ž„์˜์˜ 2๊ฐœ ๊ฒ€์€์  Centroid๋ฅผ ๋งŒ๋“ ๋‹ค.
  2. ๊ฐ A,B,C,D,E ๋ฐ์ดํ„ฐ๋Š” 2๊ฐœ์˜ Centroid์™€์˜ ๊ฑฐ๋ฆฌ๋ฅผ ํ™•์ธํ•œ ๋‹ค์Œ, ๊ฐ€๊นŒ์šด Centroid์— ์†Œ์†์ด ๋œ๋‹ค.
  3. ์†Œ์†์ด ๊ฒฐ์ •๋˜๋ฉด ๊ฐ ๋ฐ์ดํ„ฐ์˜ ์ค‘์‹ฌ ๊ณต๊ฐ„์œผ๋กœ Centrod๋“ค์ด ์ด๋™ํ•œ๋‹ค.
  4. ๋‹ค์‹œ A,B,C,D,E ๋ฐ์ดํ„ฐ๋“ค์€ ๊ฐ Centroid์™€ ๊ฑฐ๋ฆฌ๋ฅผ ๊ณ„์‚ฐํ•˜์—ฌ ๊ฐ€๊นŒ์šด Centroid์— ์†Œ์†์ด ๋œ๋‹ค.(3๋ฒˆ์งธ๊ทธ๋ฆผ)
  5. C๋ฐ์ดํ„ฐ๋Š” ์ „๊ณผ ๋‹ค๋ฅด๊ฒŒ ๋‹ค๋ฅธ Centroid์— ์†Œ์†์ด ๋œ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค.(4๋ฒˆ์งธ ๊ทธ๋ฆผ)
  6. ๊ฐ Centroid๋Š” ๋‹ค์‹œ ์ž์‹ ์˜ ์†ํ•œ ๋ฐ์ดํ„ฐ๋“ค์˜ ์ค‘์‹ฌ์œผ๋กœ ์ด๋™ํ•˜๊ฒŒ ๋˜๊ณ , ๋”์ด์ƒ ๊ฐ ๋ฐ์ดํ„ฐ๋“ค์ด Centroid ์†Œ์†์ด ๋ณ€๊ฒฝ๋˜์ง€ ์•Š๋Š”๋‹ค๋ฉด ์ข…๋ฃŒ๋œ๋‹ค. (Elbow point)

์žฅ์ 

  • ์ผ๋ฐ˜์ ์œผ๋กœ ๊ฐ€์žฅ ๋งŽ์ด ํ™œ์šฉ๋˜๋Š” ์•Œ๊ณ ๋ฆฌ์ฆ˜์œผ๋กœ, ๊ฐ€์žฅ ์‰ฝ๊ณ  ๊ฐ„๊ฒฐํ•˜๋‹ค.
  • ๋Œ€์šฉ๋Ÿ‰ ๋ฐ์ดํ„ฐ์—์„œ๋„ ํ™œ์šฉ์ด ๊ฐ€๋Šฅํ•˜๋‹ค.

๋‹จ์ 

  • ๊ฑฐ๋ฆฌ๊ธฐ๋ฐ˜ ์•Œ๊ณ ๋ฆฌ์ฆ˜์œผ๋กœ ์†์„ฑ ๊ฐœ์ˆ˜๊ฐ€ ๋งŽ์œผ๋ฉด ๊ตฐ์ง‘ํ™” ์ •ํ™•๋„๊ฐ€ ๋–จ์–ด์ง€๋ฉฐ, PCA๋กœ ์ฐจ์› ์ถ•์†Œ๋ฅผ ์ง„ํ–‰ํ•  ์ˆ˜ ์žˆ๋‹ค.
  • ๋ฐ˜๋ณตํšŸ์ˆ˜๊ฐ€ ๋งŽ์•„์งˆ ๊ฒฝ์šฐ ์ˆ˜ํ–‰์‹œ๊ฐ„์ด ๋Š๋ ค์ง€๊ณ , ์ด์ƒ์น˜ (outlier) ์— ๋ฏผ๊ฐํ•˜๋‹ค.

โœ”๏ธ Hierarchical Clustering

๊ณ„์ธต์  ๊ตฐ์ง‘ํ™” Hierarchical Clustering ๋Š” ์—ฌ๋Ÿฌ๊ฐœ์˜ ๊ตฐ์ง‘ ์ค‘์—์„œ ๊ฐ€์žฅ ์œ ์‚ฌ๋„๊ฐ€ ๋†’์€ ํ˜น์€ ๊ฑฐ๋ฆฌ๊ฐ€ ๊ฐ€๊นŒ์šด ๊ตฐ์ง‘ ๋‘ ๊ฐœ๋ฅผ ์„ ํƒํ•˜์—ฌ ํ•˜๋‚˜๋กœ ํ•ฉ์น˜๋ฉด์„œ ๊ตฐ์ง‘ ๊ฐœ์ˆ˜๋ฅผ ์ค„์—ฌ ๊ฐ€๋Š” ๋ฐฉ๋ฒ•์„ ๋งํ•œ๋‹ค. ๋‹ค๋ฅธ ๋ง๋กœ ํ•ฉ์ฒด ๊ตฐ์ง‘ํ™”(agglomerative clustering)์ด๋ผ๊ณ  ๋ถˆ๋ฆฌ๊ธฐ๋„ ํ•œ๋‹ค.

๐Ÿค” ๊ตฐ์ง‘๊ฐ„์˜ ๊ฑฐ๋ฆฌ ์ธก์ •

๊ณ„์ธก์ • ๊ตฐ์ง‘ํ™”๋ฅผ ํ•˜๋ ค๋ฉด ์šฐ์„  ๋ชจ๋“  ๊ตฐ์ง‘ ๊ฐ„์— ๊ฑฐ๋ฆฌ๋ฅผ ์ธก์ •ํ•ด์•ผ ํ•œ๋‹ค. ๊ตฐ์ง‘ ๊ฐ„์˜ ๊ฑฐ๋ฆฌ๋ฅผ ์ธก์ •ํ•˜๋Š” ๋ฐฉ๋ฒ•์—๋Š” ๊ณ„์ธต์  ๋ฐฉ๋ฒ•์— ์˜์กดํ•˜์ง€ ์•Š๋Š” ๋น„๊ณ„์ธต์  ๋ฐฉ๋ฒ•๊ณผ ์ด๋ฏธ ์ด์ „ ๋‹จ๊ณ„์—์„œ ๊ณ„์ธต์  ๋ฐฉ๋ฒ•์œผ๋กœ ๊ตฐ์ง‘์ด ํ•ฉ์ณ์ง„ ์ ์ธ ์žˆ๋‹ค๋Š” ๊ฐ€์ •์„ ํ•˜๋Š” ๊ณ„์ธต์  ๋ฐฉ๋ฒ• ๋‘ ๊ฐ€์ง€๊ฐ€ ์žˆ๋‹ค.

1. ๋น„๊ณ„์ธต์  ๊ฑฐ๋ฆฌ ์ธก์ •๋ฒ•

๋น„๊ณ„์ธต์  ๊ฑฐ๋ฆฌ ์ธก์ •๋ฒ•์€ ๊ณ„์ธต์  ๊ตฐ์ง‘ํ™”๊ฐ€ ์•„๋‹ˆ๋”๋ผ๋„ ๋ชจ๋“  ๊ฒฝ์šฐ์— ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” ๊ฑฐ๋ฆฌ ์ธก์ • ๋ฐฉ๋ฒ•์ด๋‹ค. ์ค‘์‹ฌ / ๋‹จ์ผ / ์™„์ „ / ํ‰๊ท  ๊ฑฐ๋ฆฌ ๋“ฑ์ด ์žˆ๊ณ , ๊ณ„์ธต์  ๊ฑฐ๋ฆฌ ์ธก์ •๋ฒ•์— ๋น„ํ•ด ๊ณ„์‚ฐ๋Ÿ‰์ด ๋งŽ์€ ๋‹จ์ ์ด ์žˆ๋‹ค.

2. ๊ณ„์ธต์  ๊ฑฐ๋ฆฌ ์ธก์ •๋ฒ•

๊ณ„์ธต์  ๊ฑฐ๋ฆฌ ์ธก์ •๋ฒ•์€ ๊ณ„์ธต์  ๊ตฐ์ง‘ํ™”์—์„œ๋งŒ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” ๋ฐฉ๋ฒ•์ด๋‹ค. ์ฆ‰, ์ด์ „ ๋‹จ๊ณ„์—์„œ ์ด๋ฏธ ์–ด๋–ค ๋‘ ๊ฐœ์˜ ๊ตฐ์ง‘์ด ํ•˜๋‚˜๋กœ ํ•ฉ์ณ์ง„ ์ ์ด ์žˆ๋‹ค๊ณ  ๊ฐ€์ •ํ•˜์—ฌ ์ด ์ •๋ณด๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ์ธก์ •๋ฒ•์ด๋‹ค. ๋น„๊ณ„์ธต์  ๊ฑฐ๋ฆฌ ์ธก์ •๋ฒ•์— ๋น„ํ•ด ๊ณ„์‚ฐ๋Ÿ‰์ด ์ ์–ด ํšจ์œจ์ ์ด๋‹ค.

โœ”๏ธ DBSCAN Density-Based Spatial Clustering of Applications with Noise

K-Means ๊ตฐ์ง‘ํ™” ๋ฐฉ๋ฒ•์€ ๋‹จ์ˆœํ•˜๊ณ  ๊ฐ•๋ ฅํ•œ ๋ฐฉ๋ฒ•์ด์ง€๋งŒ ๊ตฐ์ง‘์˜ ๋ชจ์–‘์ด ์›ํ˜•์ด ์•„๋‹Œ ๊ฒฝ์šฐ์—๋Š” ์ž˜ ๋™์ž‘ํ•˜์ง€ ์•Š์œผ๋ฉฐ, ์‚ฌ์šฉ์ž๊ฐ€ ๊ตฐ์ง‘์˜ ๊ฐœ์ˆ˜๋ฅผ ์ง€์ •ํ•ด์ฃผ์–ด์•ผ ํ•œ๋‹ค๋Š” ๋‹จ์ ์ด ์žˆ๋‹ค.

DBSCAN ๊ตฐ์ง‘ํ™” ๋ฐฉ๋ฒ•์€ ๋ฐ์ดํ„ฐ๊ฐ€ ๋ฐ€์ง‘ํ•œ ์ •๋„ ์ฆ‰ ๋ฐ€๋„๋ฅผ ์ด์šฉํ•œ๋‹ค. DBSCAN ๊ตฐ์ง‘ํ™”๋Š” ๊ตฐ์ง‘์˜ ํ˜•ํƒœ์— ๊ตฌ์• ๋ฐ›์ง€ ์•Š์œผ๋ฉฐ ๊ตฐ์ง‘์˜ ๊ฐฏ์ˆ˜๋ฅผ ์‚ฌ์šฉ์ž๊ฐ€ ์ง€์ •ํ•  ํ•„์š”๊ฐ€ ์—†๋‹ค. ๋””๋น„์Šค์บ” ๊ตฐ์ง‘ํ™” ๋ฐฉ๋ฒ•์—์„œ๋Š” ์ดˆ๊ธฐ ๋ฐ์ดํ„ฐ๋กœ๋ถ€ํ„ฐ ๊ทผ์ ‘ํ•œ ๋ฐ์ดํ„ฐ๋ฅผ ์ฐพ์•„๋‚˜๊ฐ€๋Š” ๋ฐฉ๋ฒ•์œผ๋กœ ๊ตฐ์ง‘์„ ํ™•์žฅํ•œ๋‹ค.

5. ๊ตฐ์ง‘ํ™” ๊ฒฐ๊ณผ ์ธก์ • ๋ฐ ํ‰๊ฐ€

  • SSE Sum of Squared Error
    • ์ˆ˜์‹
    • ๊ทธ๋ž˜ํ”„
  • Silhouette

    โžก๏ธ

    • a(i)
      • ๊ด€์ธก์น˜ i๋กœ๋ถ€ํ„ฐ ๊ฐ™์€ ๊ตฐ์ง‘ ๋‚ด์— ์žˆ๋Š” ๋ชจ๋“  ๋‹ค๋ฅธ ๊ฐœ์ฒด๋“ค ์‚ฌ์ด์˜ ํ‰๊ท  ๊ฑฐ๋ฆฌ
    • b(i)
      • ๊ด€์ธก์น˜ i๋กœ๋ถ€ํ„ฐ ๋‹ค๋ฅธ ๊ตฐ์ง‘ ๋‚ด์— ์žˆ๋Š” ๊ฐœ์ฒด๋“ค ์‚ฌ์ด์˜ ํ‰๊ท  ๊ฑฐ๋ฆฌ ์ค‘ ์ตœ์†Ÿ๊ฐ’
    • ์ผ๋ฐ˜์ ์œผ๋กœ 0.5๋ณด๋‹ค ํฌ๋ฉด ๊ตฐ์ง‘ ๊ฒฐ๊ณผ๊ฐ€ ํƒ€๋‹นํ•˜๋‹ค๊ณ  ๋ณผ ์ˆ˜ ์žˆ์Œ


๐Ÿ’ป ์‹ค์Šต ์˜ˆ์ œ ์ฝ”๋“œ

๋‹ค์Œ์€ ๋ช‡ ๊ฐ€์ง€ ์˜ˆ์ œ ๋ฐ์ดํ„ฐ์— ๋Œ€ํ•ด ์œ„์—์„œ ๋‚˜์—ดํ•œ ๊ตฐ์ง‘ํ™” ๋ฐฉ๋ฒ•์„ ์ ์šฉํ•œ ๊ฒฐ๊ณผ์ด๋‹ค. ๊ฐ™์€ ์ƒ‰์ƒ์˜ ๋ฐ์ดํ„ฐ๋Š” ๊ฐ™์€ ๊ตฐ์ง‘๋กœ ๋ถ„๋ฅ˜๋œ ๊ฒƒ์ด๋‹ค. ๊ทธ๋ฆผ์—์„œ๋„ ๋ณผ ์ˆ˜ ์žˆ์ง€๋งŒ ๊ฐ ๊ตฐ์ง‘ํ™” ๋ฐฉ๋ฒ•๋งˆ๋‹ค ํŠน์„ฑ์ด ๋‹ค๋ฅด๋ฏ€๋กœ ์›ํ•˜๋Š” ๋ชฉ์ ๊ณผ ๋ฐ์ดํ„ฐ ์œ ํ˜•์— ๋งž๊ฒŒ ์‚ฌ์šฉํ•ด์•ผ ํ•œ๋‹ค.

from sklearn.datasets import *
from sklearn.cluster import *
from sklearn.preprocessing import StandardScaler
from sklearn.utils._testing import ignore_warnings

np.random.seed(0)
n_samples = 1500
blobs = make_blobs(n_samples=n_samples, random_state=8)
X, y = make_blobs(n_samples=n_samples, random_state=170)
anisotropic = (np.dot(X, [[0.6, -0.6], [-0.4, 0.8]]), y)
varied = make_blobs(n_samples=n_samples, cluster_std=[1.0, 2.5, 0.5], random_state=170)
noisy_circles = make_circles(n_samples=n_samples, factor=.5, noise=.05)
noisy_moons = make_moons(n_samples=n_samples, noise=.05)
no_structure = np.random.rand(n_samples, 2), None
datasets = {
    "๊ฐ™์€ ํฌ๊ธฐ์˜ ์›ํ˜•": blobs, 
    "๊ฐ™์€ ํฌ๊ธฐ์˜ ํƒ€์›ํ˜•": anisotropic, 
    "๋‹ค๋ฅธ ํฌ๊ธฐ์˜ ์›ํ˜•": varied, 
    "์ดˆ์Šน๋‹ฌ": noisy_moons, 
    "๋™์‹ฌ์›": noisy_circles, 
    "๋น„๊ตฌ์กฐํ™”": no_structure
}

plt.figure(figsize=(11, 11))
plot_num = 1
for i, (data_name, (X, y)) in enumerate(datasets.items()):
    if data_name in ["์ดˆ์Šน๋‹ฌ", "๋™์‹ฌ์›"]:
        n_clusters = 2
    else:
        n_clusters = 3

    X = StandardScaler().fit_transform(X)

    two_means = MiniBatchKMeans(n_clusters=n_clusters)
    dbscan = DBSCAN(eps=0.15)
    spectral = SpectralClustering(n_clusters=n_clusters, affinity="nearest_neighbors")
    ward = AgglomerativeClustering(n_clusters=n_clusters)
    affinity_propagation = AffinityPropagation(damping=0.9, preference=-200)
    clustering_algorithms = (
        ('K-Means', two_means),
        ('DBSCAN', dbscan),
        ('Hierarchical Clustering', ward),
        ('Affinity Propagation', affinity_propagation),
        ('Spectral Clustering', spectral),
    )

    for j, (name, algorithm) in enumerate(clustering_algorithms):
        with ignore_warnings(category=UserWarning):
            algorithm.fit(X)
        if hasattr(algorithm, 'labels_'):
            y_pred = algorithm.labels_.astype(np.int)
        else:
            y_pred = algorithm.predict(X)
        plt.subplot(len(datasets), len(clustering_algorithms), plot_num)
        if i == 0:
            plt.title(name)
        if j == 0:
            plt.ylabel(data_name)
        colors = plt.cm.tab10(np.arange(20, dtype=int))
        plt.scatter(X[:, 0], X[:, 1], s=5, color=colors[y_pred])
        plt.xlim(-2.5, 2.5)
        plt.ylim(-2.5, 2.5)
        plt.xticks(())
        plt.yticks(())
        plot_num += 1

plt.tight_layout()
plt.show()

๋งˆ๋ฌด๋ฆฌํ•˜๋ฉด์„œ..

๋‹ค์Œ ํฌ์ŠคํŠธ์—์„œ ๋งŒ๋‚˜์š” ๐Ÿ™Œ

๋‹ค์Œ ํฌ์ŠคํŠธ์—์„œ๋Š” ํ•ด๋‹น ๋‚ด์šฉ์„ ๋ฐ”ํƒ•์œผ๋กœ ์‹ค์Šต์„ ํ•ด๋ณผ ์˜ˆ์ •์ด๋‹ค.



์ฐธ๊ณ 

K-MOOC ์‹ค์Šต์œผ๋กœ ๋ฐฐ์šฐ๋Š” ๋จธ์‹ ๋Ÿฌ๋‹

๊ตฐ์ง‘ํ™”

K-Means ๊ตฐ์ง‘ํ™”

๊ณ„์ธต์  ๊ตฐ์ง‘ํ™”

DBSCAN ๊ตฐ์ง‘ํ™”

 

Related Posts



๐Ÿ’™ You need to log in to GitHub to write comments. ๐Ÿ’™
If you can't see comments, please refresh page(F5).