org.tribuo.anomaly.example

## Class AnomalyDataGenerator

• ```public abstract class AnomalyDataGenerator
extends Object```
Generates three example train and test datasets, used for unit testing. They don't necessarily have sensible boundaries, it's for testing the machinery rather than accuracy.

Also has a dataset generator which returns a training dataset with no anomalies sampled from a single gaussian, and a test dataset sampled from two gaussians where the second is labelled anomalous.

• ### Constructor Summary

Constructors
Constructor and Description
`AnomalyDataGenerator()`
• ### Method Summary

All Methods
Modifier and Type Method and Description
`static com.oracle.labs.mlrg.olcut.util.Pair<Dataset<Event>,Dataset<Event>>` `denseTrainTest()`
Makes a simple dataset for training and testing.
`static com.oracle.labs.mlrg.olcut.util.Pair<Dataset<Event>,Dataset<Event>>` `denseTrainTest(double negate)`
Generates a train/test dataset pair which is dense in the features, each example has 4 features,{A,B,C,D}, and there are 4 clusters, {0,1,2,3}.
`static Example<Event>` `emptyExample()`
Generates an example with no features.
`static com.oracle.labs.mlrg.olcut.util.Pair<Dataset<Event>,Dataset<Event>>` `gaussianAnomaly()`
Generates two datasets, one without anomalies drawn from a single gaussian and the second drawn from a mixture of two gaussians, with the second tagged anomalous.
`static com.oracle.labs.mlrg.olcut.util.Pair<Dataset<Event>,Dataset<Event>>` ```gaussianAnomaly(long size, double fractionAnomalous)```
Generates two datasets, one without anomalies drawn from a single gaussian and the second drawn from a mixture of two gaussians, with the second tagged anomalous.
`static Example<Event>` `invalidSparseExample()`
Generates an example with the feature ids 1,5,8, which does not intersect with the ids used elsewhere in this class.
`static com.oracle.labs.mlrg.olcut.util.Pair<Dataset<Event>,Dataset<Event>>` `sparseTrainTest()`
Makes a simple dataset for training and testing.
`static com.oracle.labs.mlrg.olcut.util.Pair<Dataset<Event>,Dataset<Event>>` `sparseTrainTest(double negate)`
Generates a pair of datasets, where the features are sparse, and unknown features appear in the test data.
• ### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`
• ### Constructor Detail

• #### AnomalyDataGenerator

`public AnomalyDataGenerator()`
• ### Method Detail

• #### gaussianAnomaly

`public static com.oracle.labs.mlrg.olcut.util.Pair<Dataset<Event>,Dataset<Event>> gaussianAnomaly()`
Generates two datasets, one without anomalies drawn from a single gaussian and the second drawn from a mixture of two gaussians, with the second tagged anomalous. Generates 200 training examples and 200 test examples, with 20% anomalies.
Returns:
A pair of datasets.
• #### gaussianAnomaly

```public static com.oracle.labs.mlrg.olcut.util.Pair<Dataset<Event>,Dataset<Event>> gaussianAnomaly(long size,
double fractionAnomalous)```
Generates two datasets, one without anomalies drawn from a single gaussian and the second drawn from a mixture of two gaussians, with the second tagged anomalous.
Parameters:
`size` - The number of points to sample for each dataset.
`fractionAnomalous` - The fraction of anomalous data to generate.
Returns:
A pair of datasets.
• #### denseTrainTest

`public static com.oracle.labs.mlrg.olcut.util.Pair<Dataset<Event>,Dataset<Event>> denseTrainTest()`
Makes a simple dataset for training and testing.

Used for smoke testing, doesn't have a real boundary.

Returns:
A pair containing a training dataset and a testing dataset.
• #### denseTrainTest

`public static com.oracle.labs.mlrg.olcut.util.Pair<Dataset<Event>,Dataset<Event>> denseTrainTest(double negate)`
Generates a train/test dataset pair which is dense in the features, each example has 4 features,{A,B,C,D}, and there are 4 clusters, {0,1,2,3}.
Parameters:
`negate` - Supply -1.0 to negate some feature values.
Returns:
A pair of datasets.
• #### sparseTrainTest

`public static com.oracle.labs.mlrg.olcut.util.Pair<Dataset<Event>,Dataset<Event>> sparseTrainTest()`
Makes a simple dataset for training and testing.

Used for smoke testing, doesn't have a real boundary.

Returns:
A pair containing a training dataset and a testing dataset.
• #### sparseTrainTest

`public static com.oracle.labs.mlrg.olcut.util.Pair<Dataset<Event>,Dataset<Event>> sparseTrainTest(double negate)`
Generates a pair of datasets, where the features are sparse, and unknown features appear in the test data. It has the same 4 clusters {0,1,2,3}.
Parameters:
`negate` - Supply -1.0 to negate some feature values.
Returns:
A pair of datasets.
• #### invalidSparseExample

`public static Example<Event> invalidSparseExample()`
Generates an example with the feature ids 1,5,8, which does not intersect with the ids used elsewhere in this class. This should make the example empty at prediction time.
Returns:
An example with features {1:1.0,5:5.0,8:8.0}.
• #### emptyExample

`public static Example<Event> emptyExample()`
Generates an example with no features.
Returns:
An example with no features.
{"ft_lang_label":"__label__en","ft_lang_prob":0.7006328,"math_prob":0.63254595,"size":3030,"snap":"2023-40-2023-50","text_gpt3_token_len":693,"char_repetition_ratio":0.18076669,"word_repetition_ratio":0.2972136,"special_character_ratio":0.20462047,"punctuation_ratio":0.22086957,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.95268977,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-09-27T15:16:37Z\",\"WARC-Record-ID\":\"<urn:uuid:43684e36-d245-4bab-a003-4f179d4d7894>\",\"Content-Length\":\"24976\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:388e773b-81c4-4f61-b1ba-41ee50330459>\",\"WARC-Concurrent-To\":\"<urn:uuid:c9ad4c92-37d3-4be7-bb05-b5d9cab0ae25>\",\"WARC-IP-Address\":\"185.199.111.153\",\"WARC-Target-URI\":\"https://tribuo.org/learn/4.1/javadoc/org/tribuo/anomaly/example/AnomalyDataGenerator.html\",\"WARC-Payload-Digest\":\"sha1:HVNKCJEUI6Y2B7H5NMGW4UIAF6UDX44S\",\"WARC-Block-Digest\":\"sha1:YUR7KXQ7DNVRCFDDXTVSGY62MG2QMJWT\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-40/CC-MAIN-2023-40_segments_1695233510300.41_warc_CC-MAIN-20230927135227-20230927165227-00611.warc.gz\"}"}