#print('x_test number: ', X_test.shape[0]) #print('Y_train number: ', Y.shape[0]) #print('y_test number: ', Y_test) regressor = SupervisedDBNRegression(hidden_layers_structure=[100], learning_rate_rbm=0.01, learning_rate=0.01, n_epochs_rbm=10, n_iter_backprop=100, batch_size=16, activation_function='relu') regressor.fit(X, Y) # Save the model regressor.save('models/abalone_3.pkl') # Restore it #regressor = SupervisedDBNRegression.load('models/abalone_2.pkl') # Test data1 = pd.read_csv("abalone_test.csv") data1['age'] = data1['rings'] + 1.5 data1.drop('rings', axis=1, inplace=True) X1 = data1.drop(['age', 'sex'], axis=1) Y1 = data1['age'] X1 = min_max_scaler.fit_transform(X1)
#print('X: ', X.shape[1]) #print('Y: ', Y) #print('Y_train number: ', Y_train[0]) #print('y_test number: ', Y_test.shape[0]) #''' # Training regressor = SupervisedDBNRegression(hidden_layers_structure=[10, 100], learning_rate_rbm=0.01, learning_rate=0.01, n_epochs_rbm=20, n_iter_backprop=100, batch_size=16, activation_function='relu') regressor.fit(X_train, Y_train) # Save the model regressor.save('models/taipei_data.pkl') # Restore it #regressor = SupervisedDBNRegression.load('models/model_regression.pkl') # Test X_test = min_max_scaler.transform(X_test) Y_pred = regressor.predict(X_test) print('Done.\nR-squared: %f\nMSE: %f\nMAPE: %f' % (r2_score(Y_test, Y_pred), mean_squared_error( Y_test, Y_pred), mean_absolute_percentage_error(Y_test, Y_pred))) #'''