lucky_odds
is basically a wrapper around the process: add_id
--> crazyfy
--> strange
(weird method with set of parameters) --> singularize
(default parameters: all methods)
--> get_anomalies
(flag top n.anom anomalies) --> fortify
to enrich source data.
By calling lucky_odds
, analyst gets back source data with an additional column flagging some records.
Though obviously simplifying the analysis process, not all options are available and intermediate objects
are not available for further analysis.
lucky_odds(data, n.anom = 5, ..., analysis.drop = NULL,
analysis.keep = NULL, weird = "knn", stack = "avg",
stack.method = "norm")
Source data (data.frame or data.table).
Number of anomaly candidate records to flags.
Additional parameters to be passed to weird method (analysis.method
).
Character - set of variables to be removed from analysis (metrics computations by weird).
Character - set of variables to be kept for analyis (metrics computations by weird).
weird method to use for metric computation
Stacking metric passed to get_anomalies
.
Stacking selection method passed to get_anomalies
.
If your source data contains variables you don't want to use in metrics computations - weird method: knnw, autoencode...,
then you have to first select analysis variables. You can thos this use either analysis.keep
OR analysis.drop
.
Those two parameters are mutually exclusive.
library(stranger)
data(iris)
anomalies <- lucky_odds(iris[,1:4])
table(anomalies$flag_anomaly)