20 lines
505 B
Python
20 lines
505 B
Python
from sklearn.cluster import KMeans
|
|
import pandas
|
|
from matplotlib import pyplot as plt
|
|
|
|
factors = ['T', 'RH', 'D1', 'TI1', 'P']
|
|
kmeans = KMeans(n_clusters=4)
|
|
data = pandas.read_csv('WindData.csv')
|
|
|
|
i = 0
|
|
for i in range(len(factors)):
|
|
corr = data[['V1', factors[i]]]
|
|
kmeans.fit(corr)
|
|
plt.xlabel('V1', fontsize=14)
|
|
plt.ylabel(factors[i], fontsize=14)
|
|
|
|
plt.scatter(corr.values[:, 0], corr.values[:, 1], c=kmeans.labels_)
|
|
plt.savefig('images/' + factors[i] + '-V1.png')
|
|
plt.show()
|
|
|