本文整理汇总了Python中sklearn.decomposition.PCA.min方法的典型用法代码示例。如果您正苦于以下问题:Python PCA.min方法的具体用法?Python PCA.min怎么用?Python PCA.min使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sklearn.decomposition.PCA
的用法示例。
在下文中一共展示了PCA.min方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: saveScattered
# 需要导入模块: from sklearn.decomposition import PCA [as 别名]
# 或者: from sklearn.decomposition.PCA import min [as 别名]
def saveScattered(labels,sim,filename='a.png',metric=True,method='MDS',transparent='True',fontsize=12):
plt.close('all')
fig = plt.figure(figsize=(10, 8))#figsize=(30, 30)
plt.axis('off')
#axes = fig.add_subplot(1, 1, 1, axisbg='black')
dissim = 100 - sim #invertSim(sim)
if method=='MDS':
seed = 5
mds = MDS(n_components=2, metric=metric,max_iter=1000,random_state=seed,dissimilarity='precomputed')
data = mds.fit_transform(dissim.astype(np.float64))
if method=='PCA':
data = PCA(n_components=2).fit_transform(sim)
data = data + np.abs(data.min())
plt.scatter(data[:, 0], data[:, 1], s = 1, marker = 'o')
a = load_json('g.json')['nodes']
#http://wiki.scipy.org/Cookbook/Matplotlib/Show_colormaps
#colors = cm.rainbow(np.linspace(0, 1, 11))
colors = cm.Spectral(np.linspace(0, 1, 11))
b = {}
#[b.update({a[i]['name']:colors[a[i]['group']]}) for i in range(len(a))]
[b.update({a[i]['name']:colors[int(data[i,0]/6) %11]}) for i in range(len(a))]
for label, x, y in zip(labels, data[:, 0], data[:, 1]):
"""
if label=='ihacomtr' or label=='Haberturk':
plt.annotate(label, xy = (x, y), fontsize=fontsize, ha = 'right',weight='bold',color = b[label])
elif label=='yenisafak' or label== 'cnnturkcom':
plt.annotate(label, xy = (x, y), fontsize=fontsize, va = 'top',weight='bold',color = b[label])
else:
plt.annotate(label, xy = (x, y), fontsize=fontsize, ha = 'center',weight='bold',color = b[label]) # str(x)+","+str(y)
"""
plt.annotate(label, xy = (x, y), fontsize=fontsize, ha = 'center',weight='bold') # str(x)+","+str(y)
#xytext = (-20, 20),
#textcoords = 'offset points', ha = 'right', va = 'bottom',
#bbox = dict(boxstyle = 'round,pad=0.5', fc = 'yellow', alpha = 0.5),
#arrowprops = dict(arrowstyle = '->', connectionstyle = 'arc3,rad=0')
plt.axis('tight')
plt.savefig(filename,dpi=600,transparent=transparent,bbox_inches='tight', edgecolor='none')#,facecolor='black'