This commit is contained in:
Paul Schaub 2018-06-11 16:43:06 +02:00
commit e86ba8ee3d
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311

View file

@ -3,9 +3,11 @@ import tensorflow as tf
import matplotlib.pyplot as pp import matplotlib.pyplot as pp
import pywatts.neural import pywatts.neural
from sklearn.metrics import explained_variance_score, mean_absolute_error, median_absolute_error from sklearn.metrics import explained_variance_score, mean_absolute_error, median_absolute_error
import pandas
from sklearn.model_selection import train_test_split from sklearn.model_selection import train_test_split
df = pywatts.db.rows_to_df(list(range(1, 50))) df = pywatts.db.rows_to_df(list(range(1, 50)))
X = df[[col for col in df.columns if col != 'dc']] X = df[[col for col in df.columns if col != 'dc']]
y = df['dc'] y = df['dc']
@ -14,12 +16,20 @@ X_train, X_tmp, y_train, y_tmp = train_test_split(X, y, test_size=0.2, random_st
X_test, X_val, y_test, y_val = train_test_split(X_tmp, y_tmp, test_size=0.5, random_state=23) X_test, X_val, y_test, y_val = train_test_split(X_tmp, y_tmp, test_size=0.5, random_state=23)
X_train.shape, X_test.shape, X_val.shape
feature_cols = [tf.feature_column.numeric_column(col) for col in X.columns] feature_cols = [tf.feature_column.numeric_column(col) for col in X.columns]
n = pywatts.neural.Net(feature_cols=feature_cols) n = pywatts.neural.Net(feature_cols=feature_cols)
def input_data(json_str):
tmp_df = pandas.read_json(json_str)
return pandas.DataFrame.from_dict(
{'dc': [x for l in tmp_df['dc'] for x in l],
'temp': [x for l in tmp_df['temp'] for x in l],
'wind': [x for l in tmp_df['wind'] for x in l]}
)
def train(steps=100): def train(steps=100):
evaluation = [] evaluation = []
for i in range(steps): for i in range(steps):