Y_DIM = 5 if __name__ == '__main__': parser = argparse.ArgumentParser() parser.add_argument('-X', help = 'X.h5 file (with path)') parser.add_argument('--Y', help = '(optional) Y.h5 file (with path)') parser.add_argument('--file_out', help = '(optional) .h5 file output (with path)') args = parser.parse_args() # reading X data filenameX = args.X r = reader.H5Reader({'X':(None,X_DIM), 'Y':(None,Y_DIM)}) dataX = r.read(filenameX) X = dataX['X'] # load models filename = os.path.join( PATH_MDL, 'neural_network.sav') model = joblib.load( filename ) filename = os.path.join( PATH_MDL, 'scalerX.sav') scalerX = joblib.load( filename ) filename = os.path.join( PATH_MDL, 'scalerY.sav') scalerY = joblib.load( filename ) filename = os.path.join( PATH_MDL, 'linreg.sav') benchmark = joblib.load( filename ) # neural_network predict
import reader import os import tools import liquid_algos as algo import joblib path_data = 'data' path_mdl = 'model' if __name__ == '__main__': ### read data filenameX = os.path.join(path_data, 'X.h5') filenameY = os.path.join(path_data, 'Y.h5') r = reader.H5Reader(data_shape={'Y': (None, 5)}) dataX = r.read(filenameX) dataY = r.read(filenameY) X = dataX['X'] Y = dataY['Y'] # train NN scalerX, scalerY = algo.fit_scaler(X), algo.fit_scaler(Y) Xscale, Yscale = scalerX.transform(X), scalerY.transform(Y) model = algo.sklearn_nn(hidden_layer_sizes=(256, 128), activation='relu', max_iter=100) model.fit(Xscale, Yscale)