linear_model

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 7, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClassifierOption

type ClassifierOption func(*SGDClassifier)

ClassifierOption はSGDClassifierの設定オプション

func WithClassifierAlpha

func WithClassifierAlpha(alpha float64) ClassifierOption

WithClassifierAlpha は正則化の強度を設定

func WithClassifierEta0

func WithClassifierEta0(eta0 float64) ClassifierOption

WithClassifierEta0 は初期学習率を設定

func WithClassifierLearningRate

func WithClassifierLearningRate(lr string) ClassifierOption

WithClassifierLearningRate は学習率スケジュールを設定

func WithClassifierLoss

func WithClassifierLoss(loss string) ClassifierOption

WithClassifierLoss は損失関数を設定

func WithClassifierMaxIter

func WithClassifierMaxIter(maxIter int) ClassifierOption

WithClassifierMaxIter は最大イテレーション数を設定

func WithClassifierPenalty

func WithClassifierPenalty(penalty string) ClassifierOption

WithClassifierPenalty は正則化を設定

func WithClassifierRandomState

func WithClassifierRandomState(seed int64) ClassifierOption

WithClassifierRandomState は乱数シードを設定

type LinearRegression added in v0.3.0

type LinearRegression struct {
	// contains filtered or unexported fields
}

LinearRegression is a linear regression model using ordinary least squares Fully compatible with scikit-learn's LinearRegression

func NewLinearRegression added in v0.3.0

func NewLinearRegression(options ...LinearRegressionOption) *LinearRegression

NewLinearRegression creates a new LinearRegression model

func (*LinearRegression) Clone added in v0.3.0

Clone creates a new instance of the model (with same hyperparameters)

func (*LinearRegression) Coef added in v0.3.0

func (lr *LinearRegression) Coef() []float64

Coef returns the learned weight coefficients

func (*LinearRegression) ExportWeights added in v0.3.0

func (lr *LinearRegression) ExportWeights() (*model.ModelWeights, error)

ExportWeights exports model weights (guarantees complete reproducibility)

func (*LinearRegression) Fit added in v0.3.0

func (lr *LinearRegression) Fit(X, y mat.Matrix) error

Fit trains the model with training data

func (*LinearRegression) GetParams added in v0.3.0

func (lr *LinearRegression) GetParams(deep bool) map[string]interface{}

GetParams returns the model's hyperparameters (scikit-learn compatible)

func (*LinearRegression) GetWeightHash added in v0.3.0

func (lr *LinearRegression) GetWeightHash() string

GetWeightHash calculates the hash value of weights (for verification)

func (*LinearRegression) ImportWeights added in v0.3.0

func (lr *LinearRegression) ImportWeights(weights *model.ModelWeights) error

ImportWeights imports model weights (guarantees complete reproducibility)

func (*LinearRegression) Intercept added in v0.3.0

func (lr *LinearRegression) Intercept() float64

Intercept returns the learned intercept

func (*LinearRegression) IsFitted added in v0.4.0

func (lr *LinearRegression) IsFitted() bool

IsFitted returns whether the model has been fitted

func (*LinearRegression) Predict added in v0.3.0

func (lr *LinearRegression) Predict(X mat.Matrix) (mat.Matrix, error)

Predict performs predictions on input data

func (*LinearRegression) Score added in v0.3.0

func (lr *LinearRegression) Score(X, y mat.Matrix) (float64, error)

Score computes the coefficient of determination (R²) of the model

func (*LinearRegression) SetParams added in v0.3.0

func (lr *LinearRegression) SetParams(params map[string]interface{}) error

SetParams sets the model's hyperparameters (scikit-learn compatible)

func (*LinearRegression) String added in v0.3.0

func (lr *LinearRegression) String() string

String returns the string representation of the model

type LinearRegressionOption added in v0.3.0

type LinearRegressionOption func(*LinearRegression)

LinearRegressionOption is a configuration option

func WithCopyX added in v0.3.0

func WithCopyX(copy bool) LinearRegressionOption

WithCopyX sets whether to copy data

func WithLRFitIntercept added in v0.3.0

func WithLRFitIntercept(fit bool) LinearRegressionOption

WithLRFitIntercept sets whether to learn intercept (for LinearRegression)

func WithNJobs added in v0.3.0

func WithNJobs(n int) LinearRegressionOption

WithNJobs sets number of parallel jobs

func WithNormalize added in v0.3.0

func WithNormalize(normalize bool) LinearRegressionOption

WithNormalize sets whether to normalize (deprecated)

func WithPositive added in v0.3.0

func WithPositive(positive bool) LinearRegressionOption

WithPositive sets positive constraint on coefficients

type LogisticRegression added in v0.4.0

type LogisticRegression struct {
	C float64 // Inverse regularization strength (1/alpha)
	// contains filtered or unexported fields
}

LogisticRegression implements logistic regression for classification Compatible with scikit-learn's LogisticRegression

func NewLogisticRegression added in v0.4.0

func NewLogisticRegression(opts ...LogisticRegressionOption) *LogisticRegression

NewLogisticRegression creates a new LogisticRegression classifier

func (*LogisticRegression) Fit added in v0.4.0

func (lr *LogisticRegression) Fit(X, y mat.Matrix) error

Fit trains the logistic regression model

func (*LogisticRegression) GetParams added in v0.4.0

func (lr *LogisticRegression) GetParams() map[string]interface{}

GetParams returns the model hyperparameters

func (*LogisticRegression) Predict added in v0.4.0

func (lr *LogisticRegression) Predict(X mat.Matrix) (mat.Matrix, error)

Predict makes predictions for input data

func (*LogisticRegression) PredictProba added in v0.4.0

func (lr *LogisticRegression) PredictProba(X mat.Matrix) (mat.Matrix, error)

PredictProba returns probability estimates for each class

func (*LogisticRegression) Score added in v0.4.0

func (lr *LogisticRegression) Score(X, y mat.Matrix) float64

Score returns the mean accuracy on the given test data and labels

func (*LogisticRegression) SetParams added in v0.4.0

func (lr *LogisticRegression) SetParams(params map[string]interface{}) error

SetParams sets the model hyperparameters

type LogisticRegressionOption added in v0.4.0

type LogisticRegressionOption func(*LogisticRegression)

LogisticRegressionOption is a functional option for LogisticRegression

func WithLRC added in v0.4.0

WithLRC sets the inverse regularization strength

func WithLRMaxIter added in v0.4.0

func WithLRMaxIter(maxIter int) LogisticRegressionOption

WithMaxIter sets the maximum number of iterations

func WithLRPenalty added in v0.4.0

func WithLRPenalty(penalty string) LogisticRegressionOption

WithLRPenalty sets the regularization type

func WithLRRandomState added in v0.4.0

func WithLRRandomState(seed int64) LogisticRegressionOption

WithRandomState sets the random seed

func WithLRSolver added in v0.4.0

func WithLRSolver(solver string) LogisticRegressionOption

WithLRSolver sets the optimization solver

func WithLRTol added in v0.4.0

func WithLRTol(tol float64) LogisticRegressionOption

WithTol sets the tolerance for stopping criteria

func WithLogisticFitIntercept added in v0.4.0

func WithLogisticFitIntercept(fit bool) LogisticRegressionOption

WithLogisticFitIntercept sets whether to fit intercept

type Option

type Option func(*SGDRegressor)

Option is a configuration option for SGDRegressor

func WithAlpha

func WithAlpha(alpha float64) Option

WithAlpha sets the regularization strength

func WithEta0

func WithEta0(eta0 float64) Option

WithEta0 は初期学習率を設定

func WithFitIntercept

func WithFitIntercept(fit bool) Option

WithFitIntercept は切片の学習有無を設定

func WithLearningRate

func WithLearningRate(lr string) Option

WithLearningRate sets the learning rate schedule

func WithLoss

func WithLoss(loss string) Option

WithLoss sets the loss function

func WithMaxIter

func WithMaxIter(maxIter int) Option

WithMaxIter は最大イテレーション数を設定

func WithPenalty

func WithPenalty(penalty string) Option

WithPenalty sets the regularization

func WithRandomState

func WithRandomState(seed int64) Option

WithRandomState は乱数シードを設定

func WithTol

func WithTol(tol float64) Option

WithTol は収束判定の許容誤差を設定

func WithWarmStart

func WithWarmStart(warmStart bool) Option

WithWarmStart はウォームスタートの有効/無効を設定

type PassiveAggressiveClassifier

type PassiveAggressiveClassifier struct {

	// Hyperparameters
	C float64 // Regularization parameter
	// contains filtered or unexported fields
}

PassiveAggressiveClassifier is a passive aggressive classification model

func NewPassiveAggressiveClassifier

func NewPassiveAggressiveClassifier(options ...PassiveAggressiveOption) *PassiveAggressiveClassifier

NewPassiveAggressiveClassifier creates a new PassiveAggressiveClassifier

func (*PassiveAggressiveClassifier) Fit

Fit はバッチ学習でモデルを訓練

func (*PassiveAggressiveClassifier) FitStream

func (pa *PassiveAggressiveClassifier) FitStream(ctx context.Context, dataChan <-chan *model.Batch) error

func (*PassiveAggressiveClassifier) GetParams added in v0.4.0

func (pa *PassiveAggressiveClassifier) GetParams() map[string]interface{}

GetParams returns the hyperparameters for classifier

func (*PassiveAggressiveClassifier) IsFitted added in v0.4.0

func (pa *PassiveAggressiveClassifier) IsFitted() bool

IsFitted returns whether the classifier has been fitted

func (*PassiveAggressiveClassifier) IsWarmStart

func (pa *PassiveAggressiveClassifier) IsWarmStart() bool

func (*PassiveAggressiveClassifier) NIterations

func (pa *PassiveAggressiveClassifier) NIterations() int

func (*PassiveAggressiveClassifier) PartialFit

func (pa *PassiveAggressiveClassifier) PartialFit(X, y mat.Matrix, classes []int) error

PartialFit はミニバッチでモデルを逐次的に学習

func (*PassiveAggressiveClassifier) Predict

Predict は入力データに対する予測を行う

func (*PassiveAggressiveClassifier) SetWarmStart

func (pa *PassiveAggressiveClassifier) SetWarmStart(warmStart bool)

type PassiveAggressiveOption

type PassiveAggressiveOption func(interface{})

PassiveAggressiveOption is a configuration option

func WithPAC

WithPAC sets regularization parameter

func WithPAFitIntercept

func WithPAFitIntercept(fit bool) PassiveAggressiveOption

WithPAFitIntercept sets whether to learn intercept

func WithPALoss

func WithPALoss(loss string) PassiveAggressiveOption

WithPALoss sets loss function

func WithPAMaxIter

func WithPAMaxIter(maxIter int) PassiveAggressiveOption

WithPAMaxIter sets maximum number of iterations

type PassiveAggressiveRegressor

type PassiveAggressiveRegressor struct {

	// Hyperparameters
	C float64 // Regularization parameter
	// contains filtered or unexported fields
}

PassiveAggressiveRegressor is a passive aggressive regression model Compatible with scikit-learn's PassiveAggressiveRegressor

func NewPassiveAggressiveRegressor

func NewPassiveAggressiveRegressor(options ...PassiveAggressiveOption) *PassiveAggressiveRegressor

NewPassiveAggressiveRegressor creates a new PassiveAggressiveRegressor

func (*PassiveAggressiveRegressor) Fit

Fit はバッチ学習でモデルを訓練

func (*PassiveAggressiveRegressor) FitStream

func (pa *PassiveAggressiveRegressor) FitStream(ctx context.Context, dataChan <-chan *model.Batch) error

FitStream はデータストリームからモデルを学習

func (*PassiveAggressiveRegressor) GetParams added in v0.4.0

func (pa *PassiveAggressiveRegressor) GetParams() map[string]interface{}

GetParams returns the hyperparameters for regressor

func (*PassiveAggressiveRegressor) IsFitted added in v0.4.0

func (pa *PassiveAggressiveRegressor) IsFitted() bool

IsFitted returns whether the regressor has been fitted

func (*PassiveAggressiveRegressor) IsWarmStart

func (pa *PassiveAggressiveRegressor) IsWarmStart() bool

IsWarmStart はウォームスタートが有効かどうかを返す

func (*PassiveAggressiveRegressor) NIterations

func (pa *PassiveAggressiveRegressor) NIterations() int

NIterations は実行された学習イテレーション数を返す

func (*PassiveAggressiveRegressor) PartialFit

func (pa *PassiveAggressiveRegressor) PartialFit(X, y mat.Matrix, classes []int) error

PartialFit はミニバッチでモデルを逐次的に学習

func (*PassiveAggressiveRegressor) Predict

Predict は入力データに対する予測を行う

func (*PassiveAggressiveRegressor) SetWarmStart

func (pa *PassiveAggressiveRegressor) SetWarmStart(warmStart bool)

SetWarmStart はウォームスタートの有効/無効を設定

type SGDClassifier

type SGDClassifier struct {
	// contains filtered or unexported fields
}

SGDClassifier is a classification model using stochastic gradient descent Compatible with scikit-learn's SGDClassifier

func NewSGDClassifier

func NewSGDClassifier(options ...ClassifierOption) *SGDClassifier

NewSGDClassifier は新しいSGDClassifierを作成

func (*SGDClassifier) Classes

func (sgd *SGDClassifier) Classes() []int

Classes は学習されたクラスラベルを返す

func (*SGDClassifier) Coef

func (sgd *SGDClassifier) Coef() [][]float64

Coef は学習された重み係数を返す

func (*SGDClassifier) DecisionFunction

func (sgd *SGDClassifier) DecisionFunction(X mat.Matrix) (mat.Matrix, error)

DecisionFunction は決定関数の値を返す

func (*SGDClassifier) Fit

func (sgd *SGDClassifier) Fit(X, y mat.Matrix) error

Fit はバッチ学習でモデルを訓練

func (*SGDClassifier) FitPredictStream

func (sgd *SGDClassifier) FitPredictStream(ctx context.Context, dataChan <-chan *model.Batch) <-chan mat.Matrix

FitPredictStream は学習と予測を同時に行う(test-then-train方式)

func (*SGDClassifier) FitStream

func (sgd *SGDClassifier) FitStream(ctx context.Context, dataChan <-chan *model.Batch) error

FitStream はデータストリームからモデルを学習

func (*SGDClassifier) GetConverged

func (sgd *SGDClassifier) GetConverged() bool

GetConverged は収束したかどうかを返す

func (*SGDClassifier) GetLearningRate

func (sgd *SGDClassifier) GetLearningRate() float64

GetLearningRate は現在の学習率を返す

func (*SGDClassifier) GetLearningRateSchedule

func (sgd *SGDClassifier) GetLearningRateSchedule() string

GetLearningRateSchedule は学習率スケジュールを返す

func (*SGDClassifier) GetLoss

func (sgd *SGDClassifier) GetLoss() float64

GetLoss は現在の損失値を返す

func (*SGDClassifier) GetLossHistory

func (sgd *SGDClassifier) GetLossHistory() []float64

GetLossHistory は損失値の履歴を返す

func (*SGDClassifier) GetParams added in v0.4.0

func (sgd *SGDClassifier) GetParams() map[string]interface{}

GetParams returns the hyperparameters

func (*SGDClassifier) Intercept

func (sgd *SGDClassifier) Intercept() []float64

Intercept は学習された切片を返す

func (*SGDClassifier) IsFitted added in v0.4.0

func (sgd *SGDClassifier) IsFitted() bool

IsFitted returns whether the model has been fitted

func (*SGDClassifier) IsWarmStart

func (sgd *SGDClassifier) IsWarmStart() bool

IsWarmStart はウォームスタートが有効かどうかを返す

func (*SGDClassifier) NIterations

func (sgd *SGDClassifier) NIterations() int

NIterations は実行された学習イテレーション数を返す

func (*SGDClassifier) PartialFit

func (sgd *SGDClassifier) PartialFit(X, y mat.Matrix, classes []int) error

PartialFit はミニバッチでモデルを逐次的に学習(オンライン学習)

func (*SGDClassifier) Predict

func (sgd *SGDClassifier) Predict(X mat.Matrix) (mat.Matrix, error)

Predict は入力データに対する予測を行う

func (*SGDClassifier) PredictProba

func (sgd *SGDClassifier) PredictProba(X mat.Matrix) (mat.Matrix, error)

PredictProba は各クラスの予測確率を返す

func (*SGDClassifier) PredictStream

func (sgd *SGDClassifier) PredictStream(ctx context.Context, inputChan <-chan mat.Matrix) <-chan mat.Matrix

PredictStream は入力ストリームに対してリアルタイム予測

func (*SGDClassifier) Score

func (sgd *SGDClassifier) Score(X, y mat.Matrix) (float64, error)

Score はモデルの精度を計算

func (*SGDClassifier) SetLearningRate

func (sgd *SGDClassifier) SetLearningRate(lr float64)

SetLearningRate は学習率を設定

func (*SGDClassifier) SetLearningRateSchedule

func (sgd *SGDClassifier) SetLearningRateSchedule(schedule string)

SetLearningRateSchedule は学習率スケジュールを設定

func (*SGDClassifier) SetWarmStart

func (sgd *SGDClassifier) SetWarmStart(warmStart bool)

SetWarmStart はウォームスタートの有効/無効を設定

type SGDRegressor

type SGDRegressor struct {
	// contains filtered or unexported fields
}

SGDRegressor is a linear regression model using stochastic gradient descent Compatible with scikit-learn's SGDRegressor

func NewSGDRegressor

func NewSGDRegressor(options ...Option) *SGDRegressor

NewSGDRegressor creates a new SGDRegressor

func (*SGDRegressor) Coef

func (sgd *SGDRegressor) Coef() []float64

Coef は学習された重み係数を返す

func (*SGDRegressor) Fit

func (sgd *SGDRegressor) Fit(X, y mat.Matrix) error

Fit はバッチ学習でモデルを訓練

func (*SGDRegressor) FitPredictStream

func (sgd *SGDRegressor) FitPredictStream(ctx context.Context, dataChan <-chan *model.Batch) <-chan mat.Matrix

FitPredictStream は学習と予測を同時に行う(test-then-train方式)

func (*SGDRegressor) FitStream

func (sgd *SGDRegressor) FitStream(ctx context.Context, dataChan <-chan *model.Batch) error

FitStream はデータストリームからモデルを学習

func (*SGDRegressor) GetConverged

func (sgd *SGDRegressor) GetConverged() bool

GetConverged は収束したかどうかを返す

func (*SGDRegressor) GetLearningRate

func (sgd *SGDRegressor) GetLearningRate() float64

GetLearningRate は現在の学習率を返す

func (*SGDRegressor) GetLearningRateSchedule

func (sgd *SGDRegressor) GetLearningRateSchedule() string

GetLearningRateSchedule は学習率スケジュールを返す

func (*SGDRegressor) GetLoss

func (sgd *SGDRegressor) GetLoss() float64

GetLoss は現在の損失値を返す

func (*SGDRegressor) GetLossHistory

func (sgd *SGDRegressor) GetLossHistory() []float64

GetLossHistory は損失値の履歴を返す

func (*SGDRegressor) GetParams added in v0.4.0

func (sgd *SGDRegressor) GetParams() map[string]interface{}

GetParams returns the hyperparameters

func (*SGDRegressor) Intercept

func (sgd *SGDRegressor) Intercept() float64

Intercept は学習された切片を返す

func (*SGDRegressor) IsFitted added in v0.4.0

func (sgd *SGDRegressor) IsFitted() bool

IsFitted returns whether the model has been fitted

func (*SGDRegressor) IsWarmStart

func (sgd *SGDRegressor) IsWarmStart() bool

IsWarmStart はウォームスタートが有効かどうかを返す

func (*SGDRegressor) NIterations

func (sgd *SGDRegressor) NIterations() int

NIterations は実行された学習イテレーション数を返す

func (*SGDRegressor) PartialFit

func (sgd *SGDRegressor) PartialFit(X, y mat.Matrix, classes []int) error

PartialFit はミニバッチでモデルを逐次的に学習(オンライン学習)

func (*SGDRegressor) Predict

func (sgd *SGDRegressor) Predict(X mat.Matrix) (mat.Matrix, error)

Predict は入力データに対する予測を行う

func (*SGDRegressor) PredictStream

func (sgd *SGDRegressor) PredictStream(ctx context.Context, inputChan <-chan mat.Matrix) <-chan mat.Matrix

PredictStream は入力ストリームに対してリアルタイム予測

func (*SGDRegressor) Score

func (sgd *SGDRegressor) Score(X, y mat.Matrix) (float64, error)

Score はモデルの決定係数(R²)を計算

func (*SGDRegressor) SetLearningRate

func (sgd *SGDRegressor) SetLearningRate(lr float64)

SetLearningRate は学習率を設定

func (*SGDRegressor) SetLearningRateSchedule

func (sgd *SGDRegressor) SetLearningRateSchedule(schedule string)

SetLearningRateSchedule は学習率スケジュールを設定

func (*SGDRegressor) SetWarmStart

func (sgd *SGDRegressor) SetWarmStart(warmStart bool)

SetWarmStart はウォームスタートの有効/無効を設定

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL