Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Library 'squared' is deprecated in version 1.4 and will be removed in 1.6. #166

Open
DhruvDabas opened this issue Nov 3, 2024 · 0 comments

Comments

@DhruvDabas
Copy link

Describe the bug
'squared' is deprecated in version 1.4 and will be removed in 1.6.

https://github.com/ageron/handson-ml3/blob/main/10_neural_nets_with_keras.ipynb
Line number 11 in code, inside Regression MLP

To Reproduce

  Changed to import root_mean_squared_error

```python
  from sklearn.datasets import fetch_california_housing
  from sklearn.metrics import mean_squared_error
  from sklearn.model_selection import train_test_split
  from sklearn.neural_network import MLPRegressor
  from sklearn.pipeline import make_pipeline
  from sklearn.preprocessing import StandardScaler
  
  housing = fetch_california_housing()
  X_train_full, X_test, y_train_full, y_test = train_test_split(
      housing.data, housing.target, random_state=42)
  X_train, X_valid, y_train, y_valid = train_test_split(
      X_train_full, y_train_full, random_state=42)
  
  mlp_reg = MLPRegressor(hidden_layer_sizes=[50, 50, 50], random_state=42)
  pipeline = make_pipeline(StandardScaler(), mlp_reg)
  pipeline.fit(X_train, y_train)
  y_pred = pipeline.predict(X_valid)
  rmse = mean_squared_error(y_valid, y_pred, squared=False)

change to the below :

  from sklearn.datasets import fetch_california_housing
  from sklearn.metrics import mean_squared_error, root_mean_squared_error
  from sklearn.model_selection import train_test_split
  from sklearn.neural_network import MLPRegressor
  from sklearn.pipeline import make_pipeline
  from sklearn.preprocessing import StandardScaler
  
  housing = fetch_california_housing()
  X_train_full, X_test, y_train_full, y_test = train_test_split(housing.data, housing.target, random_state=42)
  
  X_train, X_valid, y_train, y_valid = train_test_split(X_train_full, y_train_full, random_state=42)
  
  mlp_reg = MLPRegressor(hidden_layer_sizes=[50, 50, 50], random_state=42)
  pipeline = make_pipeline(StandardScaler(), mlp_reg)
  pipeline.fit(X_train, y_train)
  
  y_pred = pipeline.predict(X_valid)
  rmse = root_mean_squared_error(y_valid, y_pred)
  
  print(rmse)

Screenshots
If applicable, add screenshots to help explain your problem.
Screenshot 2024-11-03 at 11 38 17 PM

The function is depricated kindly update to the above , i have provided the correct code too .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant