More actions
No edit summary |
(Repair batch-0005 pages from live compare) |
||
| (2 intermediate revisions by one other user not shown) | |||
| Line 6: | Line 6: | ||
=== 코드 === | === 코드 === | ||
==== | ==== sklearn ==== | ||
from sklearn import cluster | from sklearn import cluster | ||
clst = cluster.KMeans() | clst = cluster.KMeans() | ||
clst.fit( | clst.fit([[0],[1],[2],[3], [1000], [1004], [1010], [2000], [100000], [12345], [23456], [66666]]) | ||
clst.predict( | clst.predict([[11], [3000], [99999]]) | ||
# result | # result | ||
# array( | # array([5, 6, 1], dtype=int32) | ||
=== tensorflow === | |||
* [https://www.tensorflow.org/versions/r0.10/api_docs/python/math_ops.html#unsorted_segment_sum unsorted_segment_sum] | |||
== 다음 시간에는 == | == 다음 시간에는 == | ||
Latest revision as of 00:44, 27 March 2026
내용
- sklearn의 k-means
- tensorflow로 k-means algorithm 구현하기
코드
sklearn
from sklearn import cluster clst = cluster.KMeans() clst.fit([[0],[1],[2],[3], [1000], [1004], [1010], [2000], [100000], [12345], [23456], [66666]]) clst.predict([[11], [3000], [99999]]) # result # array([5, 6, 1], dtype=int32)