def test_l1_neural_network_regressor_with_proximal_bundle(): X, y = load_boston(return_X_y=True) X_scaled = StandardScaler().fit_transform(X) X_train, X_test, y_train, y_test = train_test_split(X_scaled, y, train_size=0.75, random_state=123456) net = NeuralNetworkRegressor( (FullyConnected(13, 13, relu), FullyConnected(13, 1, linear)), loss=mean_absolute_error, optimizer=ProximalBundle, max_iter=150) net.fit(X_train, y_train) assert net.score(X_test, y_test) >= 0.83
def test_neural_network_regressor_with_stochastic_optimizer(): X, y = load_boston(return_X_y=True) X_scaled = StandardScaler().fit_transform(X) X_train, X_test, y_train, y_test = train_test_split(X_scaled, y, train_size=0.75, random_state=1) net = NeuralNetworkRegressor( (FullyConnected(13, 13, sigmoid), FullyConnected( 13, 13, sigmoid), FullyConnected(13, 1, linear)), loss=mean_squared_error, optimizer=Adam, learning_rate=0.02) net.fit(X_train, y_train) assert net.score(X_test, y_test) >= 0.84
def test_l2_neural_network_regressor_with_stochastic_optimizer(): X, y = load_boston(return_X_y=True) X_scaled = StandardScaler().fit_transform(X) X_train, X_test, y_train, y_test = train_test_split(X_scaled, y, train_size=0.75, random_state=123456) net = NeuralNetworkRegressor( (FullyConnected(13, 13, sigmoid), FullyConnected(13, 1, linear)), loss=mean_squared_error, optimizer=StochasticGradientDescent, learning_rate=0.01, momentum_type='nesterov', momentum=0.9) net.fit(X_train, y_train) assert net.score(X_test, y_test) >= 0.83