Documentation ¶
Index ¶
- Variables
- func NewObservation(o float64, es []float64) *observation
- type ANOVA
- type ConditionError
- type ConditionErrorHint
- type ExplanatoryVarHint
- type ExplanatoryVarResult
- type InterceptResult
- type Model
- type ObservationsAnalysis
- type Regression
- func (r *Regression) AddObservations(observations ...*observation) error
- func (r *Regression) BackwardElimination(p float64, forcedExpVarsIndexesSet map[int]struct{}) ([]Model, error)
- func (r *Regression) DisregardIndex(idx int)
- func (r *Regression) GetExplanatoryVariableLabel(i int) string
- func (r *Regression) GetObjectiveVariableLabel() string
- func (r *Regression) ResetDisregarding()
- func (r *Regression) Run() (*Model, error)
- func (r *Regression) SetExplanatoryVariableLabel(i int, label string)
- func (r *Regression) SetObjectiveVariableLabel(label string)
- func (r *Regression) ValidateExplanatoryVars() []int
Constants ¶
This section is empty.
Variables ¶
var ( ErrNearSingular = &ConditionError{isExactlySingular: false} ErrExactlySingular = &ConditionError{isExactlySingular: true} )
var ( // ErrNotEnoughObservations signals that there weren't enough observations to train the model. ErrNotEnoughObservations = errors.New("not enough observations") // ErrTooManyExplanatoryVars signals that there are too many explanatory variables for the number of observations being made. ErrTooManyExplanatoryVars = errors.New("not enough observations to support this many explanatory variables") // ErrNoExplanatoryVars signals that there is no explanatory variables to train the model. ErrNoExplanatoryVars = errors.New("no explanatory variables to train the models") // ErrInvalidArgument signals that any of given arguments to call the function was invalid. ErrInvalidArgument = errors.New("invalid argument") )
Functions ¶
func NewObservation ¶
NewObservation creates a well formed *observation used for training.
Types ¶
type ANOVA ¶
type ANOVA struct { RegressionSumOfSquares float64 // 回帰の平方和 RegressionDegreeOfFreedom int // 回帰の自由度 RegressionMeanOfSquares float64 // 回帰の平均平方 RegressionFstat float64 // 回帰のF値 RegressionProb float64 // 回帰の有意確率 ResidualSumOfSquares float64 // 残差の平方和 ResidualDegreeOfFreedom int // 残差の自由度 ResidualMeanOfSquares float64 // 残差の平均平方 TotalSumOfSquares float64 // 合計の平方和 TotalDegreeOfFreedom int // 合計の自由度 }
ANOVA : 分散分析の結果
type ConditionError ¶ added in v2.2.0
type ConditionError struct { Hint *ConditionErrorHint // contains filtered or unexported fields }
func (ConditionError) Error ¶ added in v2.2.0
func (e ConditionError) Error() string
func (ConditionError) Is ¶ added in v2.2.0
func (e ConditionError) Is(err error) bool
func (ConditionError) Unwrap ¶ added in v2.2.0
func (e ConditionError) Unwrap() error
type ConditionErrorHint ¶ added in v2.2.0
type ConditionErrorHint struct {
ExplanatoryVars []ExplanatoryVarHint
}
type ExplanatoryVarHint ¶ added in v2.2.0
type ExplanatoryVarResult ¶
type ExplanatoryVarResult struct { OriginalIndex int // 元々のインデックス Label string // 名称 Coeff float64 // 偏回帰係数 B StandardError float64 // 偏回帰係数の標準誤差(非標準化係数 標準誤差) StandardizedCoeff float64 // 標準化偏回帰係数 β TStat float64 // t値 Prob float64 // 有意確率(p値) Correlation float64 // ゼロ次相関(通常の相関係数) PartialCorrelation float64 // 偏相関 PartCorrelation float64 // 部分相関 Tolerance float64 // 共線性の統計量 許容度 TOL VIF float64 // 共線性の統計量 VIF }
ExplanatoryVarResult : 回帰分析により算出された説明変数の結果
type InterceptResult ¶
type InterceptResult struct { Value float64 // 定数(y切片)の値 StandardError float64 // 標準誤差(非標準化係数 標準誤差) TStat float64 // t値 }
InterceptResult : 回帰分析により算出された定数(y切片)の結果
type Model ¶
type Model struct { NumOfObservations int // 分析に用いた観測値の数 NumOfExplanatoryVars int // 分析に用いた説明変数の数 DisregardedExplanatoryVarsSet map[int]struct{} // 分析に使用されなかったインデックスのセット UnexplainedVariation float64 // 残差変動 ExplainedVariation float64 // 回帰変動 TotalVariation float64 // 全変動 R float64 // 重相関係数 R2 float64 // 決定係数 AdjustedR2 float64 // 自由度調整済み決定係数 StandardError float64 // 回帰の標準誤差(推定値の標準偏差) ANOVA *ANOVA // 分散分析 ObjectiveVarLabel string // 目的変数の名称 Intercept *InterceptResult // 定数(y切片)の分析結果 ExplanatoryVars []ExplanatoryVarResult // 各説明変数の分析結果 // contains filtered or unexported fields }
Model : 回帰モデル
func (*Model) FormulaString ¶
FormulaString : 回帰モデル式を文字列で取得する
func (*Model) GetObservationsAnalysis ¶
func (m *Model) GetObservationsAnalysis() *ObservationsAnalysis
GetObservationsAnalysis : 観測値に関する分析結果を取得する
type ObservationsAnalysis ¶
type ObservationsAnalysis struct { ObjectiveVarsDense *mat.Dense // 目的変数の観測値の行列 ExplanatoryVarsDense *mat.Dense // 説明変数の観測値の行列 MeanOfObjectiveVars float64 // 目的変数の観測値の平均 StandardDeviationOfObjectiveVars float64 // 目的変数の観測値の標準偏差 MeansOfExplanatoryVars []float64 // 各説明変数の観測値の平均 StandardDeviationOfExplanatoryVars []float64 // 各説明変数の観測値の標準偏差 PredictedVals []float64 // 予測値 Residuals []float64 // 残差 }
ObservationsAnalysis : 観測値に関する分析結果
type Regression ¶
type Regression struct {
// contains filtered or unexported fields
}
Regression is the exposed data structure for interacting with the API.
func NewRegression ¶
func NewRegression() *Regression
NewRegression initializes the structure and returns it for interacting with regression APIs.
func (*Regression) AddObservations ¶
func (r *Regression) AddObservations(observations ...*observation) error
AddObservations adds observations.
func (*Regression) BackwardElimination ¶
func (r *Regression) BackwardElimination(p float64, forcedExpVarsIndexesSet map[int]struct{}) ([]Model, error)
BackwardElimination : 変数減少法で解析する
`forcedExpVarsIndexesSet`に指定したインデックスの説明変数は強制投入(必ず使用)される
func (*Regression) DisregardIndex ¶
func (r *Regression) DisregardIndex(idx int)
DisregardIndex adds given index to the disregarding set
func (*Regression) GetExplanatoryVariableLabel ¶
func (r *Regression) GetExplanatoryVariableLabel(i int) string
GetExplanatoryVariableLabel gets the label of i-th explanatory variable.
func (*Regression) GetObjectiveVariableLabel ¶
func (r *Regression) GetObjectiveVariableLabel() string
GetObjectiveVariableLabel gets the label of the objective variable.
func (*Regression) ResetDisregarding ¶
func (r *Regression) ResetDisregarding()
ResetDisregarding : 無視する説明変数の設定をリセットする
func (*Regression) Run ¶
func (r *Regression) Run() (*Model, error)
Run calculates a model using QR decomposition.
func (*Regression) SetExplanatoryVariableLabel ¶
func (r *Regression) SetExplanatoryVariableLabel(i int, label string)
SetExplanatoryVariableLabel sets the label of i-th explanatory variable.
func (*Regression) SetObjectiveVariableLabel ¶
func (r *Regression) SetObjectiveVariableLabel(label string)
SetObjectiveVariableLabel sets the label of the objective variable.
func (*Regression) ValidateExplanatoryVars ¶ added in v2.2.0
func (r *Regression) ValidateExplanatoryVars() []int
ValidateExplanatoryVars returns indexes of invalid explanatory variables. It considers an explanatory variable is not valid if is has all same observed values.