Re: [scikit-learn] Regarding negative value of sklearn.metrics.r2_score and sklearn.metrics.explained_variance_score

2021-08-12 Thread Samir K Mahajan
A note please (to Sebastian Raschka, mrschots). The OLS model that I used ( where the test score gave me a negative value) was not a good fit. Initial findings showed that t*he regression coefficients and the model as a whole were significant,*yet , finally , it failed in two econom

Re: [scikit-learn] Regarding negative value of sklearn.metrics.r2_score and sklearn.metrics.explained_variance_score

2021-08-12 Thread Samir K Mahajan
Thanks to all of you for your kind response. Indeed, it is a great learning experience. Yes, econometrics books too create models for prediction, and programming really makes things better in a complex world. My understanding is that machine learning does depend on econometrics too. My

Re: [scikit-learn] Regarding negative value of sklearn.metrics.r2_score and sklearn.metrics.explained_variance_score

2021-08-12 Thread Sebastian Raschka
The R2 function in scikit-learn works fine. A negative means that the regression model fits the data worse than a horizontal line representing the sample mean. E.g. you usually get that if you are overfitting the training set a lot and then apply that model to the test set. The econometrics book

Re: [scikit-learn] Regarding negative value of sklearn.metrics.r2_score and sklearn.metrics.explained_variance_score

2021-08-12 Thread Tomek Drabas
In the simplest case of a simple linear regression what you wrote holds true: the explained variance is simply a sum of variance explained by the model and the residual variability that cannot be explained, and that would always lie between 0 and 1. e.g. here: https://online.stat.psu.edu/stat500/le

Re: [scikit-learn] Regarding negative value of sklearn.metrics.r2_score and sklearn.metrics.explained_variance_score

2021-08-12 Thread mrschots
There is no constraint, that’s the point since nothing limits you to have a model with crap predictions leading to be worse than to just predict the target’s mean for every data point. If you do so —> negative R2. Best Regards, Em qui., 12 de ago. de 2021 às 16:21, Samir K Mahajan < samirkmahaja

Re: [scikit-learn] Regarding negative value of sklearn.metrics.r2_score and sklearn.metrics.explained_variance_score

2021-08-12 Thread Samir K Mahajan
Dear Christophe Pallier, Reshama Saikh and Tromek Drabas, Thank you for your kind response. Fair enough. I go with you R2 is not a square. However, if you open any book of econometrics, it says R2 is a ratio that lies between 0 and 1. *This is the constraint.* It measures the proportion or