Propre code de formatage des données
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='Énergie électrique')
dataset = dataset.T.reset_index()
return dataset
setup
from pycaret.clustering import *
clu = setup(data = load_sampledata(),normalize=True)
Vous pouvez vérifier le contenu de la configuration
Modélisation PyCaret + tracé: 2 lignes
create_model&plot
# creating a model
hclust = create_model('hclust')
# plotting a model
plot_model(hclust,plot='cluster',feature='date')