Question 13
What is the purpose of the tol parameter in the fit method of the stochastic regressor?
from sklearn.linear_model import SGDRegressorfrom sklearn.model_selection import train_test_splitfrom sklearn.metrics import mean_squared_error
model = SGDRegressor()
X_train, X_val, y_train, y_val = train_test_split(X, y, test_size=0.2, random_state=42)
model.fit(X_train, y_train, early_stopping=True, validation_data=(X_val, y_val), validation_fraction=0.2, tol=0.001, n_iter_no_change=5)
y_pred = model.predict(X_test)
mse = mean_squared_error(y_test, y_pred)It specifies the tolerance level for early stopping based on the change in the validation error.
It controls the learning rate of the stochastic regressor during training.
It determines the maximum number of iterations for the training process.
It defines the fraction of the validation set used for early stopping.