unit8co / darts

A python library for user-friendly forecasting and anomaly detection on time series.
https://unit8co.github.io/darts/
Apache License 2.0
7.96k stars 866 forks source link

[Question] deprecated mean_squared_error #2551

Open quant12345 opened 2 days ago

quant12345 commented 2 days ago

Hello everyone!

I would like to correct the following warning: FutureWarning: 'squared' is deprecated in version 1.4 and will be removed in 1.6. To calculate the root mean squared error, use the function'root_mean_squared_error'.

In the tests build (3.8, all) the version is scikit-learn-1.3.2. 'root_mean_squared_error' appeared in scikit-learn-1.4.

Question: Do you plan to upgrade scikit-learn to 1.4(in builds 3.8)? Code processing depends on this.

madtoinou commented 1 day ago

Hi @quant12345,

Since Python 3.8 is reaching its end of support at the end of the month, we are planning on doing one last release for it. Once this is done, we will be able to focus on things such as fixing some warning/deprecation messages, remove the version capping on numpy and simplify the typing imports/synthax.

If you want to contribute to darts, I would recommend checking the issues labeled with the good first issue or pr welcomed :)

quant12345 commented 1 day ago

Considering that after scikit-learn-1.3.2 the next version is 1.4.0, it seems to me that it would be more appropriate to try to switch to scikit-learn-1.4.0 (if possible). And the next release of scikit-learn, judging by the chronology, will probably be 1.6 (I'm not exactly sure), where squared will be removed.

Of course, I can do scikit-learn version processing and depending on the version choose mean_squared_error, {"squared": False} or root_mean_squared_error. But then if you switch to 1.4.0, there will be unnecessary lines of code with version checking that will need to be removed (that is, changing the code again).

madtoinou commented 1 day ago

Hi @quant12345,

Since there is no cap on scikit-learn's version as you can see here, you are actually free to use another version. I just checked the environment that I am using to work with darts and it's actually relying on scikit-learn 1.4.1.

You can safely ignore the warning, we will make sure to solve it before the release of scikit-learn 1.6 (it's not a priority yet, we already have similar messages for pandas that we started to address).

quant12345 commented 1 day ago

I looked in scikit-learn 1.4.0 supports Python versions 3.9 to 3.12. I locally replaced "squared": False from mean_squared_errorto root_mean_squared_error and the tests pass without warning:

pytest darts/tests/metrics/test_metrics.py::TestMetrics::test_metrics_deterministic[config10]
pytest darts/tests/metrics/test_metrics.py::TestMetrics::test_metrics_deterministic[config17]

Thank @madtoinou for the detailed answers, I understand how to do this PR.

I'll try to study the good first issue again. Most of what I found concerned statistics, which I don't know that well. I fixed everything I could in the summer :-)