Own data formatting code
import pandas as pd
def load_sampledata():
data = pd.read_csv(r'pycaret_sample.csv',
encoding='shift-jis',
engine='python',
index_col=[0],
parse_dates=[0])
data = data.resample('h').sum()
data['hour'] = data.index.hour
data['date'] = data.index.strftime('%Y-%m-%d (%a)')
dataset = data.pivot(index='hour',columns='date',values='Electric energy')
dataset = dataset.T.reset_index()
return dataset
setup
from pycaret.clustering import *
clu = setup(data = load_sampledata(),normalize=True)
You can check the setup contents
PyCaret modeling + plotting: 2 lines
create_model&plot
# creating a model
hclust = create_model('hclust')
# plotting a model
plot_model(hclust,plot='cluster',feature='date')
Recommended Posts