MCPcopy Index your code
hub / github.com/VivekPa/AIAlpha / train_model

Method train_model

models/nnmodel.py:25–39  ·  view source on GitHub ↗
(self, x, y, epochs, model_name, save_model=True)

Source from the content-addressed store, hash-verified

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

Callers 3

run.pyFile · 0.45
run_full.pyFile · 0.45
pca_auto.pyFile · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected