From c819c339072f30cec8ce836b81f3d190e3473dfb Mon Sep 17 00:00:00 2001 From: PerryXDeng Date: Sun, 31 Mar 2019 11:33:08 -0400 Subject: [PATCH] output from multivar lin reg --- .~lock.DataFest 2019 - Codebook.xlsx# | 1 + hypotheses_modeling/KerasRegressions.py | 28 +++++++++++++------------ hypotheses_modeling/out.txt | 8 +++++++ 3 files changed, 24 insertions(+), 13 deletions(-) create mode 100644 .~lock.DataFest 2019 - Codebook.xlsx# create mode 100644 hypotheses_modeling/out.txt diff --git a/.~lock.DataFest 2019 - Codebook.xlsx# b/.~lock.DataFest 2019 - Codebook.xlsx# new file mode 100644 index 0000000..8af3a3a --- /dev/null +++ b/.~lock.DataFest 2019 - Codebook.xlsx# @@ -0,0 +1 @@ +,pxd256,null,31.03.2019 08:16,file:///home/pxd256/.config/libreoffice/4; \ No newline at end of file diff --git a/hypotheses_modeling/KerasRegressions.py b/hypotheses_modeling/KerasRegressions.py index 4ab364d..4fe6974 100644 --- a/hypotheses_modeling/KerasRegressions.py +++ b/hypotheses_modeling/KerasRegressions.py @@ -144,14 +144,14 @@ def time_series_linear_regression(dataset, k, n0, x_columns, y_columns): tf.keras.layers.Flatten(input_shape=[input_shape]), tf.keras.layers.Dense(output_shape) ]) - model.compile(optimizer='adam', loss='mean_squared_error', metrics=['accuracy']) - model.fit(x, y, epochs=50) - loss, _ = model.evaluate(x, y) - print(loss) + model.compile(optimizer='adam', loss='mean_squared_error', metrics=[tf.keras.metrics.mean_squared_error]) + model.fit(x, y, epochs=50, verbose=2) pred = model.predict(x) r2 = r2_(y, pred) - print(r2) - return model.get_weights() + hard_pred = model.predict(x[0]) + hard_out = np.matmul(x[0], [0.03589787, -0.03472298, 0.24109702, -0.10143519]) - 0.890594 + print(hard_pred, hard_out, y[0]) + return r2, model.get_weights() def time_series_dnn_regressions(dataset, k, n0, x_columns, y_columns): @@ -194,24 +194,26 @@ def time_series_dnn_regressions(dataset, k, n0, x_columns, y_columns): tf.keras.layers.Dense(32, activation=tf.nn.softmax), tf.keras.layers.Dense(output_shape) ]) - model.compile(optimizer='adam', loss='mean_squared_error', metrics=['accuracy']) - model.fit(x, y, epochs=100, verbose=0) + model.compile(optimizer='adam', loss='mean_squared_error', metrics=[tf.keras.metrics.mean_squared_error]) + model.fit(x, y, epochs=100, verbose=2) loss, accuracy = model.evaluate(x, y) - print(loss, accuracy) pred = model.predict(x) r2 = r2_(y, pred) - print(r2) - return model.get_weights() + return r2, model.get_weights() def main(): filename = "personal.csv" df = pd.read_csv(filename) - x = ["day", "playerID", "DailyLoadSliding", "sleepQuality"] + x = ["day", "playerID", "sleepHoursSliding", "sleepHours", "sleepQuality", "acuteChronicRatio"] y = ["day", "playerID", "fatigueNorm"] k = 0 n0 = 30 - weights = time_series_linear_regression(df, k, n0, x, y) + r2, weights = time_series_linear_regression(df, k, n0, x, y) + print("r2") + print(r2) + print("weights") + print(weights) if __name__ == "__main__": diff --git a/hypotheses_modeling/out.txt b/hypotheses_modeling/out.txt new file mode 100644 index 0000000..37d9d08 --- /dev/null +++ b/hypotheses_modeling/out.txt @@ -0,0 +1,8 @@ +Epoch 1/50, mean_squared_error: 90.4998 +Epoch 11/50, mean_squared_error: 1.0265 +Epoch 21/50, mean_squared_error: 0.9604 +Epoch 31/50, mean_squared_error: 0.8671 +Epoch 41/50, mean_squared_error: 0.7838 +r2, 0.07949744624446509 +slopes, 0.03589787,-0.03472298, 0.24109702, -0.10143519 +intercept, -0.8960594