Documentation
¶
Index ¶
- func Column(matrix [][]float64, columnIndex int) []float64
- func MinMax(floats []float64) (float64, float64)
- func Quantile(numbers []float64, q float64) float64
- func SampleRows(matrix [][]float64, size int) [][]float64
- type DetectionType
- type IsolationForest
- func (f *IsolationForest) BuildTree(samples [][]float64, depth int) *TreeNode
- func (f *IsolationForest) FeatureImportance(sample []float64) []int
- func (f *IsolationForest) Fit(samples [][]float64)
- func (f *IsolationForest) Predict(samples [][]float64) []int
- func (f *IsolationForest) Score(samples [][]float64) []float64
- type Options
- type TreeNode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SampleRows ¶
SampleRows randomly selects 'size' rows from the matrix.
Types ¶
type DetectionType ¶
type DetectionType string
type IsolationForest ¶
IsolationForest orchestrates anomaly detection using isolation trees
func NewWithOptions ¶
func NewWithOptions(options Options) *IsolationForest
NewWithOptions creates an IsolationForest with the specified options.
func (*IsolationForest) BuildTree ¶
func (f *IsolationForest) BuildTree(samples [][]float64, depth int) *TreeNode
BuildTree recursively partitions samples to isolate outliers
func (*IsolationForest) FeatureImportance ¶
func (f *IsolationForest) FeatureImportance(sample []float64) []int
FeatureImportance computes an importance score for each feature
func (*IsolationForest) Fit ¶
func (f *IsolationForest) Fit(samples [][]float64)
Fit constructs isolation trees from a given dataset
func (*IsolationForest) Predict ¶
func (f *IsolationForest) Predict(samples [][]float64) []int
Predict labels samples as outliers (1) or normal (0) based on the detection type
func (*IsolationForest) Score ¶
func (f *IsolationForest) Score(samples [][]float64) []float64
Score computes anomaly scores for each sample
type Options ¶
type Options struct {
// The anomaly score threshold
Threshold float64 `json:"threshold"`
// The proportion of outliers in the dataset
Proportion float64 `json:"proportion"`
// The number of trees to build in the forest
NumTrees int `json:"numTrees"`
// The sample size for each isolation tree
SampleSize int `json:"sampleSize"`
// The maximum depth of each isolation tree
MaxDepth int `json:"maxDepth"`
}
func (*Options) SetDefaultValues ¶
func (o *Options) SetDefaultValues()
SetDefaultValues applies default settings to unspecified fields
type TreeNode ¶
func (*TreeNode) FeatureImportance ¶
FeatureImportance calculates how many times each feature index is used during splits for the given sample.