Home > Blockchain >  ModuleNotFoundError: No module named 'sklearn.metrics.regression'
ModuleNotFoundError: No module named 'sklearn.metrics.regression'

Time:01-29

trying to do the following import:

from sklearn.metrics.regression import mean_absolute_error, mean_squared_error, r2_score

and I get error:

ModuleNotFoundError: No module named 'sklearn.metrics.regression'

tried fixing with installation of:

pip install -U scikit-learn scipy matplotlib

but I don't think that's what I'm missing since it didn't work...

CodePudding user response:

You're probably looking to import them from sklearn.metrics, not sklearn.metrics.regression

Link to the library

CodePudding user response:

What you are looking for is:

from sklearn import metrics 

metrics.mean_absolute_error(<your params here>)
metrics.mean_squared_error(<your params here>)
metrics.r2_score(<your params here>)

Edit

you can check the attributes of the metrics instance with:

dir(metrics)
  •  Tags:  
  • Related