In [3]:
from hourlypowerconsumptions import HourlyPowerConsumptions
from visualizations import plot_barchart
import numpy as np
from sklearn.cluster import KMeans
In [2]:
dir_path = "/Users/zoraida/Desktop/TEFCON/all-country-data/hourly"
pattern = "/Hourly_201*month*.xls"
In [3]:
pc = HourlyPowerConsumptions(dir_path, pattern, skiprows=9, maxcolumns=26, hourchange='3B:00:00')
In [4]:
country = "ES"# country to analyse
df = pc.normalized_hourly_country_data(country)
In [5]:
df.head()
Out[5]:
In [6]:
X = df.iloc[:, 4:28].values
In [7]:
X
Out[7]:
In [8]:
X.shape
Out[8]:
In [9]:
df.values.shape
Out[9]:
In [10]:
kmeans = KMeans(init='k-means++', n_clusters=2, n_init=10)
In [11]:
labels_ = kmeans.fit_predict(df.iloc[:, 4:28].values)
In [12]:
type(labels_)
Out[12]:
In [13]:
labels_.shape
Out[13]:
In [14]:
print labels_
In [ ]: