Mean Absolute error, MSE, R^2 taking quite sometime - Locally

Summary

Hello All,

I have created a small ML based app locally, where user can change (Hyper)parameters from UI and the output metrics should change.

Issue:

Two issues:

  1. After changing the parameter from UI, it takes quite sometime to display the new metrics based on the new parameters.

  2. R^2 is throwing error. (r2_score(y, prediction))

TypeError: ‘DeltaGenerator’ object is not callable r2_score()

Details:

  • IDE: Visual Studio Code
  • Browser: Chrome
  • Data size: ~48 MB
  • Metrics used: Mean Absolute error, MSE, R^2.

Any help will be highly appreciated!

Thank you,
Joydeep

Steps to reproduce

After changing the parameter from UI, it takes quite sometime to display the new metrics based on the new parameters.

Code snippet:

regsr = RandomForestRegressor(max_depth=max_depth, n_estimators=num_estimators)

X = taxi_data[[input_feature]]
y = taxi_data[['trip_distance']]

regsr.fit(X, y.values.ravel()) 
prediction = regsr.predict(y)

disp_col.write(mean_absolute_error(y, prediction))
disp_col.write(mean_squared_error(y, prediction))
disp_col(r2_score(y, prediction))   # This is generating error

If applicable, please provide the steps we should take to reproduce the error or specified behavior.

Expected behavior:

Explain what you expect to happen when you run the code above.

Actual behavior:

Explain the undesired behavior or error you see when you run the code above.
If you’re seeing an error message, share the full contents of the error message here.

Debug info

  • Streamlit version: (get it with $ streamlit version)
  • Python version: (get it with $ python --version)
  • Using Conda? PipEnv? PyEnv? Pex?
  • OS version:
  • Browser version:

Requirements file

Using Conda? PipEnv? PyEnv? Pex? Share the contents of your requirements file here.
Not sure what a requirements file is? Check out this doc and add a requirements file to your app.

Links

  • Link to your GitHub repo:
  • Link to your deployed app:

Additional information

If needed, add any other context about the problem here.

I think I have found the error. I will update here once I test and receive the correct output.

The Issue has been resolved !

I was using disp_col(r2_score(y, prediction)) , whereas
it should have been disp_col.write(r2_score(y, prediction))

2 Likes

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.