반응형
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
Tags
- 머신러닝
- mglearn
- postorder
- 결합전문기관
- java역사
- inorder
- 웹 용어
- web
- 재귀함수
- html
- web 개발
- 자료구조
- CES 2O21 참가
- web 용어
- web 사진
- pycharm
- C언어
- Keras
- paragraph
- 대이터
- 데이터전문기관
- tensorflow
- classification
- KNeighborsClassifier
- broscoding
- CES 2O21 참여
- discrete_scatter
- vscode
- cudnn
- bccard
Archives
- Today
- Total
bro's coding
sklearn.cluster.KMeans.basic 본문
반응형
from sklearn.datasets import make_blobs
X,y=make_blobs()
for i in range(3):
print((y==i).sum())
'''
34
33
33
'''
plt.scatter(X[:,0],X[:,1],c=y)
plt.colorbar()
from sklearn.cluster import KMeans
model=KMeans(n_clusters=3) # n_clusters : 중점 갯수
model.fit(X) # X만 넣는다!
model.cluster_centers_
plt.scatter(X[:,0],X[:,1],c=model.labels_)
# 중심점 마크
plt.scatter(model.cluster_centers_[:,0],model.cluster_centers_[:,1],marker='*',c='r',s=300)
# 영역 표시
mglearn.plots.plot_2d_classification(model,X,alpha=0.3)
from sklearn.cluster import KMeans
model=KMeans(3)
model.fit(X) # X만 넣는다!
model.cluster_centers_
plt.scatter(X[:,0],X[:,1],c=model.labels_)
plt.scatter(model.cluster_centers_[:,0],model.cluster_centers_[:,1],marker='*',c='r',s=300)
mglearn.plots.plot_2d_classification(model,X,alpha=0.3)
display(model.transform(X),model.predict(X))# transform : 중심점 까지의 거리
'''
array([[13.1395785 , 0.24441747, 12.93107807],
[ 1.24476312, 11.8946356 , 3.64065633],
[ 3.93281954, 14.27283331, 1.85963563],
[ 0.86826948, 13.79232761, 4.78691746],
[12.19839786, 0.79179981, 11.900444 ],
[ 0.85032111, 12.09127817, 4.43272814],
[ 0.74801688, 12.22610181, 4.06763823],
[ 1.53987261, 13.74024499, 5.90971491],
[13.55726898, 0.66143542, 13.21203988],
[ 5.77892447, 13.28118039, 1.40254065],
[ 1.47445946, 12.31750781, 5.616153 ],
[14.11663652, 1.73626965, 13.39914618],
[ 3.20976975, 13.02395216, 1.30082577],
[ 0.94099476, 13.54543164, 3.90769078],
[13.4451396 , 0.57216951, 13.09297854],
[ 0.67047812, 13.19370096, 5.07727131],
[13.53754998, 1.10875141, 12.95517197],
[11.93795783, 0.99842198, 11.79851714],
[ 4.70331488, 12.44912832, 0.39841944],
[ 1.3479096 , 13.02760796, 3.12355376],
[ 3.97848245, 13.64733134, 1.16059489],
[ 4.15068695, 13.75765789, 1.18719323],
[13.26302325, 0.52100224, 12.86994648],
[ 0.15451023, 12.78702005, 4.32888415],
[ 3.68763911, 12.07403621, 0.94421051],
[14.15076162, 1.22009214, 13.83573113],
[ 4.3333709 , 11.51342929, 1.18289806],
[ 0.88988607, 13.81600123, 4.60344751],
[ 5.14994398, 14.06658039, 1.42798557],
[13.9113235 , 2.32161228, 12.92572567],
[ 4.66736322, 12.46363295, 0.36002921],
[14.05700621, 1.60188962, 14.12619927],
[12.9199164 , 1.1753674 , 12.28117506],
[ 0.90854529, 13.77556526, 4.99430253],
[ 1.83153184, 11.29316936, 3.59907177],
[ 0.6615936 , 13.24934434, 5.05674802],
[ 1.38165953, 12.29503611, 3.12050121],
[ 4.61391825, 12.83203901, 0.23027138],
[11.11241297, 2.8396683 , 11.77459475],
[14.72109328, 2.40651955, 14.89871097],
[12.11159098, 0.90270088, 11.79165815],
[ 5.99160213, 12.58299041, 1.6150798 ],
[ 5.89087643, 14.11377325, 1.8188432 ],
[ 1.33388704, 12.40306401, 5.51414892],
[ 0.78486691, 12.48257482, 3.70586598],
[ 0.18456153, 13.03820309, 4.58496794],
[11.54693593, 1.79126194, 11.80148513],
[11.09300502, 2.11633968, 11.35780657],
[14.7761337 , 2.00983522, 14.69435716],
[11.68683332, 2.61151872, 10.70633694],
[ 4.15943242, 13.6192585 , 1.03750557],
[ 0.88972509, 12.19103031, 3.82909591],
[14.05991018, 1.33324837, 13.52752267],
[ 1.13983308, 13.69524774, 3.84115446],
[ 2.76419683, 13.67903287, 2.15266044],
[ 0.89790728, 12.99001059, 5.29727624],
[ 5.78066765, 11.43123287, 1.89543155],
[ 4.81852882, 12.64152206, 0.41747657],
[ 3.83185437, 11.66145239, 1.19796087],
[ 4.69465912, 13.78944714, 1.09784143],
[ 4.53983004, 12.54507917, 0.20472964],
[ 1.11694924, 12.63798096, 5.40512231],
[13.06638496, 1.19678034, 12.41651431],
[11.46851705, 1.48999754, 11.22466301],
[ 5.54233717, 10.56527755, 2.35016202],
[ 3.96840212, 13.25040358, 0.78360653],
[ 1.72411522, 14.654542 , 5.04410753],
[13.08196779, 0.41397642, 12.70377997],
[12.87111589, 0.7330359 , 12.8826692 ],
[ 3.61864591, 11.6126529 , 1.37238614],
[ 5.6672612 , 13.13670337, 1.27176044],
[ 5.1905471 , 12.36631896, 0.87897729],
[ 0.62858682, 12.3343187 , 4.51107188],
[12.6698218 , 0.68680746, 12.66293779],
[ 0.90775632, 13.39746586, 5.29117099],
[ 4.08231986, 12.73098145, 0.34022922],
[ 0.20041788, 13.07890629, 4.31748158],
[ 5.76242501, 13.36840992, 1.40807559],
[13.24183605, 0.67371841, 13.18448298],
[ 4.25882432, 12.40013298, 0.31984422],
[ 1.07139782, 13.76437708, 5.31199797],
[13.62340461, 0.97704267, 13.11671375],
[ 1.35333277, 13.48520093, 3.3849091 ],
[ 1.75391502, 11.17925548, 4.44708414],
[ 5.41291423, 9.88460312, 2.86848477],
[ 1.42184382, 13.24952709, 3.15210546],
[14.04358536, 1.11493787, 13.71988018],
[ 4.28020524, 12.25431867, 0.44984284],
[11.52137966, 1.40991869, 11.38518227],
[ 1.3868576 , 13.96530555, 3.88986284],
[ 0.5420255 , 13.1615625 , 4.94650441],
[12.48183821, 0.48624983, 12.20597743],
[ 3.1319276 , 12.16125857, 1.38526929],
[ 2.8592216 , 11.5774871 , 2.02427048],
[11.0055059 , 2.27557361, 11.33704986],
[13.34032066, 0.70881503, 13.27045229],
[13.69416599, 1.48016393, 13.82848457],
[13.48443459, 0.56385386, 13.17785174],
[ 5.51843645, 15.13015331, 2.45122629],
[ 0.88101971, 12.770994 , 5.22333595]])
array([1, 0, 2, 0, 1, 0, 0, 0, 1, 2, 0, 1, 2, 0, 1, 0, 1, 1, 2, 0, 2, 2,
1, 0, 2, 1, 2, 0, 2, 1, 2, 1, 1, 0, 0, 0, 0, 2, 1, 1, 1, 2, 2, 0,
0, 0, 1, 1, 1, 1, 2, 0, 1, 0, 2, 0, 2, 2, 2, 2, 2, 0, 1, 1, 2, 2,
0, 1, 1, 2, 2, 2, 0, 1, 0, 2, 0, 2, 1, 2, 0, 1, 0, 0, 2, 0, 1, 2,
1, 0, 0, 1, 2, 2, 1, 1, 1, 1, 2, 0])
'''
반응형
'[AI] > python.sklearn' 카테고리의 다른 글
sklearn.decomposition.PCA.visualization (0) | 2020.04.21 |
---|---|
sklearn.decomposition.PCA.basic (0) | 2020.04.21 |
sklearn.cluster.DBSCAN (0) | 2020.04.21 |
sklearn.datasets.make_moons (0) | 2020.04.21 |
sklearn.preprocessing.MinMaxScaler, StandardScaler, Normalizer (0) | 2020.04.20 |
sklearn.RandomForestClassifier.feature_importances_(중요도 표현) (0) | 2020.04.20 |
sklearn.ensemble.RandomForestClassifier.2 feature for visualization (0) | 2020.04.20 |
sklearn.ensemble.RandomForestClassifier.basic (0) | 2020.04.20 |
Comments