(self, x, y, epochs, model_name, save_model=True)
| 23 | self.model = model |
| 24 | |
| 25 | def train_model(self, x, y, epochs, model_name, save_model=True): |
| 26 | self.model.compile(optimizer="adam", loss="mean_squared_error", metrics=["mse", "acc"]) |
| 27 | |
| 28 | # load data |
| 29 | |
| 30 | train_x = np.reshape(np.array(x), (len(x), 1, self.input_shape)) |
| 31 | train_y = np.array(y) |
| 32 | # train_stock = np.array(pd.read_csv("train_stock.csv")) |
| 33 | |
| 34 | # train model |
| 35 | |
| 36 | self.model.fit(train_x, train_y, epochs=epochs) |
| 37 | |
| 38 | if save_model: |
| 39 | self.model.save(f"models/saved_models/{model_name}.h5", overwrite=True, include_optimizer=True) |
| 40 | |
| 41 | def test_model(self, x, y): |
| 42 | test_x = np.reshape(np.array(x), (len(x), 1, self.input_shape)) |
no outgoing calls
no test coverage detected