Comments (5)
Hi @ETTAN93,
At the moment, Darts does not offer any unsupervised models for anomaly detection but it can be added to the roadmap, especially if contributors propose architectures and open PRs.
from darts.
@madtoinou thanks for that.
Another thing to clarify, I used eval_accuracy in darts as part of the quantile detector class and compared it to the results I got from sklearn's recall_score.
I passed the same y_test and y_pred series to both:
from sklearn.metrics import recall_score
qd_recall = qd.eval_accuracy(y_test_series, qd_y_pred_series, metric='recall')
sklearn_recall = recall_score(y_test_series.pd_series(), qd_y_pred_series.pd_series())
For some reason, I am getting the inverse of values from both, i.e. when I sum the two recall scores, I end up with 1.0. In this particular case, qd_recall from darts returns me 0.9946808510638298 whereas the recall_score from sklearn returns me 0.005319148936170213.
Am I passing in the wrong parameters to the darts function? As far as I understand, the anomaly_score parameter should be the y_pred_series from the model? what does the window parameter do?
The same also happens when I evaluate the accuracy score. The two scores that are returned sums up to 1.
from sklearn.metrics import accuracy_score
qd_accuracy= qd.eval_accuracy(y_test_series, qd_y_pred_series, metric='accuracy')
sklearn_accuracy = accuracy_score(y_test_series.pd_series(), qd_y_pred_series.pd_series())
from darts.
Hi @ETTAN93, QuantileDetector.eval_accuracy()
expects the predicted scores from the Scorer and not the output of QuantileDetector.detect()
.
The following should work:
# darts
qd = QuantileDetector(high_quantile=0.5)
anom_pred = qd.fit_detect(scores_pred)
qd_recall = qd.eval_accuracy(anom_true, scores_pred, metric="recall")
# sklearn
sl_recall = recall_score(
anom_true.slice_intersect(anom_pred).pd_series(),
anom_pred.slice_intersect(anom_true).pd_series()
)
print(qd_recall, sl_recall)
outputs: (0.6923, 0.6923)
You could also use eval_accuracy_from_binary_prediction()
from
darts.ad.utilsto compute the recall on the output of the
QuantileDetector`.
Note also that in 1-2 weeks we'll release the new Darts version with the refactored anomaly detection module (including an example notebook). So the API will change slightly (see the changes and PR here).
from darts.
@dennisbader how is the scores_pred
defined?
from darts.
It can be any numeric non-binary input series. The detector converts non-binary to binary.
In the example above it was the output from KMeansScorer.score()
. But you can also use it on other series as shown below:
from sklearn.metrics import recall_score
from darts import TimeSeries
from darts.ad import QuantileDetector
from darts.datasets import AirPassengersDataset
series = AirPassengersDataset().load()
# flag values above 400 as anomalies
anom_true = TimeSeries.from_dataframe(
series.pd_dataframe() > 400
)
# darts
qd = QuantileDetector(high_quantile=0.95)
anom_pred = qd.fit_detect(series)
qd_recall = qd.eval_accuracy(anom_true, series, metric="recall")
# sklearn
sl_recall = recall_score(
anom_true.slice_intersect(anom_pred).pd_series(),
anom_pred.slice_intersect(anom_true).pd_series()
)
print(qd_recall, sl_recall)
gives (0.2857, 0.2857)
from darts.
Related Issues (20)
- Rewrite Ray Tune Hyperparameter optimization to use current Tuner method HOT 1
- Error importing RNN Model HOT 3
- Update pytorch lightning import to work with Ray and other libraries. HOT 2
- [Question] Help understanding warning message when trying to iteratively forecast HOT 1
- Replacing the obsolete applymap with map HOT 3
- [BUG] RegressionEnsembleModel predict error HOT 5
- Passing kwargs to the underlying fitting function HOT 1
- [BUG] Models that fit method do not support the parameter sample_weights cannot be fitted HOT 2
- [Question] should old versions of pandas be taken into account in PR HOT 2
- Global Vs Local Models and Multivariate vs Multiple Series Forecasting HOT 1
- fix: PerformanceWarning - DataFrame is highly fragmented
- Historical Backtest With Updated Covariates (Regression/ LGBM Model)
- Does Darts support mixed-frequency data? HOT 3
- Historical Backtest With Updating Covariates (Tree/ Regression Models) HOT 7
- [BUG] XGBModel parameters not forwarded to models created on grid search
- Documentation Inconsistency: `num_loader_workers` Parameter
- [Question] Ensemble model on a mix of local and global models using historical_forecasts on a univariate series HOT 5
- ARIMA with Past Covariates HOT 4
- Save model and weights into object HOT 2
- How are samples generated with RegressionModel / MLPRegressor? HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from darts.