Class TimeSeriesIsolationForestOptions<T>
Configuration options for Time Series Isolation Forest anomaly detection.
public class TimeSeriesIsolationForestOptions<T> : TimeSeriesRegressionOptions<T>
Type Parameters
TThe numeric type used for calculations (typically double or float).
- Inheritance
-
TimeSeriesIsolationForestOptions<T>
- Inherited Members
Remarks
Time Series Isolation Forest extends the classic Isolation Forest algorithm to handle temporal data by incorporating lag features, rolling statistics, and seasonal decomposition.
For Beginners: Isolation Forest works by randomly isolating observations. Anomalies are easier to isolate because they are "few and different" - they end up in shorter branches of the isolation trees.
For time series, we enhance this by considering:
- Lag Features: How the current value relates to recent past values
- Rolling Statistics: Moving averages, standard deviations
- Seasonal Patterns: Accounting for regular patterns like daily/weekly cycles
- Trend: Long-term direction of the data
This makes it effective for detecting:
- Sudden spikes or drops (point anomalies)
- Values that are unusual given the context (contextual anomalies)
- Unusual patterns over time (collective anomalies)
Constructors
TimeSeriesIsolationForestOptions()
Creates a new instance with default values.
public TimeSeriesIsolationForestOptions()
TimeSeriesIsolationForestOptions(TimeSeriesIsolationForestOptions<T>)
Creates a copy of the specified options.
public TimeSeriesIsolationForestOptions(TimeSeriesIsolationForestOptions<T> other)
Parameters
otherTimeSeriesIsolationForestOptions<T>
Properties
ContaminationRate
Gets or sets the expected proportion of anomalies in the dataset.
public double ContaminationRate { get; set; }
Property Value
Remarks
For Beginners: This is used to set the threshold for what counts as an anomaly. A value of 0.1 means you expect about 10% of points to be anomalies. If unsure, start with 0.05-0.1 and adjust based on results.
LagFeatures
Gets or sets the number of lag features to include.
public int LagFeatures { get; set; }
Property Value
Remarks
For Beginners: Lag features capture how the current value relates to past values. For hourly data, lag=24 captures the daily pattern. For daily data, lag=7 captures the weekly pattern.
MaxDepth
Gets or sets the maximum depth of each isolation tree.
public int? MaxDepth { get; set; }
Property Value
- int?
Remarks
For Beginners: Limiting depth speeds up the algorithm without much accuracy loss. A depth of ceil(log2(sample_size)) is typically sufficient since anomalies are isolated early. If null, uses the theoretical limit.
NumTrees
Gets or sets the number of isolation trees in the forest.
public int NumTrees { get; set; }
Property Value
Remarks
For Beginners: More trees generally give more stable anomaly scores, but take longer to build. 100-200 trees is usually sufficient.
RandomSeed
Gets or sets the random seed for reproducibility.
public int? RandomSeed { get; set; }
Property Value
- int?
RollingWindowSize
Gets or sets the window size for rolling statistics (mean, std, min, max).
public int RollingWindowSize { get; set; }
Property Value
Remarks
For Beginners: Rolling statistics help detect if a value is unusual compared to its recent neighbors. A window of 10-30 is typical.
SampleSize
Gets or sets the number of samples to use when building each tree.
public int? SampleSize { get; set; }
Property Value
- int?
Remarks
For Beginners: A smaller sample size (e.g., 256) actually works better because anomalies are easier to isolate in smaller samples. This also makes the algorithm faster. If null, defaults to min(256, n_samples).
UseSeasonalDecomposition
Gets or sets whether to decompose the series into trend and seasonal components.
public bool UseSeasonalDecomposition { get; set; }
Property Value
Remarks
For Beginners: Seasonal decomposition helps detect anomalies that deviate from expected seasonal patterns. Enable this for data with clear daily, weekly, or yearly patterns.
UseTrendFeatures
Gets or sets whether to include trend-based features.
public bool UseTrendFeatures { get; set; }
Property Value
Remarks
For Beginners: Trend features help detect anomalies that deviate from the long-term direction of the data.