Browse Source

output from multivar lin reg

master
PerryXDeng 5 years ago
parent
commit
c819c33907
3 changed files with 24 additions and 13 deletions
  1. +1
    -0
      .~lock.DataFest 2019 - Codebook.xlsx#
  2. +15
    -13
      hypotheses_modeling/KerasRegressions.py
  3. +8
    -0
      hypotheses_modeling/out.txt

+ 1
- 0
.~lock.DataFest 2019 - Codebook.xlsx# View File

@ -0,0 +1 @@
,pxd256,null,31.03.2019 08:16,file:///home/pxd256/.config/libreoffice/4;

+ 15
- 13
hypotheses_modeling/KerasRegressions.py View File

@ -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.Flatten(input_shape=[input_shape]),
tf.keras.layers.Dense(output_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) pred = model.predict(x)
r2 = r2_(y, pred) 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): 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(32, activation=tf.nn.softmax),
tf.keras.layers.Dense(output_shape) 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) loss, accuracy = model.evaluate(x, y)
print(loss, accuracy)
pred = model.predict(x) pred = model.predict(x)
r2 = r2_(y, pred) r2 = r2_(y, pred)
print(r2)
return model.get_weights()
return r2, model.get_weights()
def main(): def main():
filename = "personal.csv" filename = "personal.csv"
df = pd.read_csv(filename) df = pd.read_csv(filename)
x = ["day", "playerID", "DailyLoadSliding", "sleepQuality"]
x = ["day", "playerID", "sleepHoursSliding", "sleepHours", "sleepQuality", "acuteChronicRatio"]
y = ["day", "playerID", "fatigueNorm"] y = ["day", "playerID", "fatigueNorm"]
k = 0 k = 0
n0 = 30 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__": if __name__ == "__main__":

+ 8
- 0
hypotheses_modeling/out.txt View File

@ -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

Loading…
Cancel
Save