12345678910111213141516171819202122232425262728293031 |
- import pandas as pd
- # from pycaret.classification import *
- import librosa as fe
- data = pd.read_csv('data/data_all.csv')
- data.timestamp = data.timestamp.apply(lambda x: pd.Timestamp(x))
- data['month'] = data.timestamp.dt.month
- data['hour'] = data.timestamp.dt.hour
- data['dayofweek'] = data.timestamp.dt.dayofweek
- def f_e(df, cn='hum'):
- # delta feature
- df[f'd_{cn}'] = fe.feature.delta(df[f'{cn}'])
- df[f'dd_{cn}'] = fe.feature.delta(df[f'd_{cn}'], order=2)
- return df
- f_e(data, 'hum')
- f_e(data, 'temp')
- data.to_csv('data/data_all_feature_eng.csv', index=False)
- tmp = (data[data['timestamp'] == '2021-08-30 08:09:00'])
- out = tmp[['hum', 'd_hum', 'dd_hum', 'temp', 'd_temp', 'dd_temp', 'door', 'motion', 'illum', 'dayofweek', 'month', 'hour']]
- v = out.values.tolist()[0]
- print(v)
- v = ["{}".format(x) for x in v]
- print(v)
- import requests
- URL = f'http://localhost:8000/predict?hum={v[0]}&d_hum={v[1]}&dd_hum={v[2]}&temp={v[3]}&d_temp={v[4]}&dd_temp={v[5]}&door={v[6]}&motion={v[7]}&illum={v[8]}&dayofweek={v[9]}&month={v[10]}&hour={v[11]}'
- response = requests.get(URL)
- print(response.status_code)
- print(response.text)
|