Documentation
¶
Overview ¶
Package models provides machine learning algorithms and utilities.
Index ¶
- func Accuracy(yTrue, yPred *seriesPkg.Series[any]) float64
- func AdjustedR2(yTrue, yPred *seriesPkg.Series[any], nFeatures int) float64
- func ConfusionMatrix(yTrue, yPred *seriesPkg.Series[any]) [][]int
- func F1Score(yTrue, yPred *seriesPkg.Series[any], average string) float64
- func MAE(yTrue, yPred *seriesPkg.Series[any]) float64
- func MSE(yTrue, yPred *seriesPkg.Series[any]) float64
- func Precision(yTrue, yPred *seriesPkg.Series[any], average string) float64
- func R2Score(yTrue, yPred *seriesPkg.Series[any]) float64
- func RMSE(yTrue, yPred *seriesPkg.Series[any]) float64
- func Recall(yTrue, yPred *seriesPkg.Series[any], average string) float64
- type ClassificationReport
- type Classifier
- type Clusterer
- type Model
- type Regressor
- type TrainTestSplit
- type Transformer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AdjustedR2 ¶
AdjustedR2 calculates the adjusted R² score.
func ConfusionMatrix ¶
ConfusionMatrix computes the confusion matrix. Returns a 2D slice where cm[i][j] is the count of samples with true label i and predicted label j.
func Precision ¶
Precision calculates the precision score. average: "binary" (for binary classification), "micro", "macro", "weighted"
Types ¶
type ClassificationReport ¶
type ClassificationReport struct {
Precision map[string]float64
Recall map[string]float64
F1Score map[string]float64
Support map[string]int
}
ClassificationReport contains precision, recall, F1, and support for each class.
func ClassificationReportFunc ¶
func ClassificationReportFunc(yTrue, yPred *seriesPkg.Series[any]) ClassificationReport
ClassificationReportFunc generates a comprehensive classification report.
type Classifier ¶
type Classifier interface {
Model
// PredictProba returns class probabilities for each sample
PredictProba(X *dataframe.DataFrame) (*dataframe.DataFrame, error)
}
Classifier adds classification-specific methods.
type Clusterer ¶
type Clusterer interface {
// Fit trains the clustering model on data X
Fit(X *dataframe.DataFrame) error
// Predict assigns cluster labels to new data X
Predict(X *dataframe.DataFrame) (*seriesPkg.Series[any], error)
// FitPredict fits the model and returns cluster labels
FitPredict(X *dataframe.DataFrame) (*seriesPkg.Series[any], error)
}
Clusterer is the interface for unsupervised clustering models.
type Model ¶
type Model interface {
// Fit trains the model on data X with target y
Fit(X *dataframe.DataFrame, y *seriesPkg.Series[any]) error
// Predict makes predictions on new data X
Predict(X *dataframe.DataFrame) (*seriesPkg.Series[any], error)
}
Model is the base interface for all ML models.
type Regressor ¶
type Regressor interface {
Model
}
Regressor is a marker interface for regression models.
type TrainTestSplit ¶
type TrainTestSplit struct {
XTrain *dataframe.DataFrame
XTest *dataframe.DataFrame
YTrain *seriesPkg.Series[any]
YTest *seriesPkg.Series[any]
}
TrainTestSplit contains the split datasets.
func TrainTestSplitFunc ¶
func TrainTestSplitFunc(X *dataframe.DataFrame, y *seriesPkg.Series[any], testSize float64, shuffle bool, stratify string, seed ...int64) (TrainTestSplit, error)
TrainTestSplitFunc splits data into training and test sets. X: feature DataFrame y: target Series testSize: fraction of data to use for testing (0-1) shuffle: whether to shuffle data before splitting stratify: column name to stratify by (maintains class proportions) seed: random seed (optional, defaults to time-based)
type Transformer ¶
type Transformer interface {
// Fit learns the transformation from data X
Fit(X *dataframe.DataFrame) error
// Transform applies the learned transformation to X
Transform(X *dataframe.DataFrame) (*dataframe.DataFrame, error)
// FitTransform fits and transforms in one step
FitTransform(X *dataframe.DataFrame) (*dataframe.DataFrame, error)
}
Transformer is the interface for dimensionality reduction and feature extraction.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package cluster provides clustering algorithms.
|
Package cluster provides clustering algorithms. |
|
Package crossval provides cross-validation utilities for model evaluation.
|
Package crossval provides cross-validation utilities for model evaluation. |
|
Package decomposition provides dimensionality reduction algorithms.
|
Package decomposition provides dimensionality reduction algorithms. |
|
Package linear provides linear regression models.
|
Package linear provides linear regression models. |
|
Package tree provides decision tree algorithms.
|
Package tree provides decision tree algorithms. |