common

package
v0.0.0-...-aafbcf9 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// no Regularize
	RegNone = iota
	// L1 Lasso
	RegLasso
	// L2 Ridge
	RegRidge
)

定义正则化Regularize的类型 Regularize,正则化,也可以翻译为规则化。 意思是对模型的损失函数引入先验知识约束规则。使得在模型训练时(寻找满足损失函数的值达到最小时,模型参数的最优解),强行缩小模型参数的求解空间,从而产生符合先验知识约束规则的解。 例如,L1 Lasso约束规则,倾向于产生稀疏解,从而拥有特征选择的能力。L2 Ridge约束规则,更平滑,控制过拟合的效果比L1相对而言更好一些,但不具备特征选择的能力

View Source
const (
	// no Cross Validation
	CvNone = iota
	// Leave One Out Cross Validation (Exhaustive cross-validation)
	CvLoo
	// Leave P Out Cross Validation (Exhaustive cross-validation)
	CvLpo
	// K-Fold Cross Validation (Non-exhaustive cross-validation)
	CvKfold
	// Repeated K-Fold Cross Validation (Non-exhaustive cross-validation)
	CvRepKfold
	// Monte Carlo Cross Validation, also called Repeated random sub-sampling validation (Non-exhaustive cross-validation)
	CvMonteCarlo
)

定义交叉验证Cross Validation的类型

Variables

This section is empty.

Functions

This section is empty.

Types

type DTDataFeature

type DTDataFeature struct {
	FeatureName string         `json:"feature_name"` // 特征的名称
	Sets        map[int]string `json:"sets"`         // 特征集合,key是样本编号,value是特征的值。key从0开始自增
}

DTDataFeature 决策树样本的多元特征维度

func ImportFeaturesForDT

func ImportFeaturesForDT(fileRows [][]string) ([]*DTDataFeature, error)

ImportFeaturesForDT import decision tree features from file - fileRows file rows, first row is feature list

type DTDataSet

type DTDataSet struct {
	Features []*DTDataFeature
}

DTDataSet 用于决策树训练的样本数据集

type DataFeature

type DataFeature struct {
	FeatureName string `json:"feature_name"` // 特征的名称
	// 特别注意:key需要从0开始自增
	Sets map[int]float64 `json:"sets"` // 特征集合,key是样本编号,value是特征的值。线性回归模型仅能处理数值化特征,对于非数值化特征(分类特征),需要进行编码处理。
}

DataFeature 样本的多元特征维度

func ImportFeaturesForLinReg

func ImportFeaturesForLinReg(fileRows [][]string) ([]*DataFeature, error)

ImportFeaturesForLinReg import linear regression features from file

func ImportFeaturesForLogReg

func ImportFeaturesForLogReg(fileRows [][]string, label, labelName string) ([]*DataFeature, error)

ImportFeaturesForLogReg import logic regression features from file, target variable imported as 1 or 0 - fileRows file rows, first row is feature list - label target feature - labelName target variable

type DataSet

type DataSet struct {
	Features []*DataFeature // 样本多元特征,有多少维度,该数组就有多大
}

DataSet 用于训练的样本数据集

type EncLocalCost

type EncLocalCost struct {
	EncCost     map[int]*big.Int
	RandomNoise *big.Int
}

EncLocalCost 本地加密损失信息

type EncLocalGradient

type EncLocalGradient struct {
	EncGrad     map[int]*big.Int
	RandomNoise *big.Int
}

EncLocalGradient 本地加密梯度信息

type Model

type Model struct {
	Params        map[string]float64 `json:"params"`         // 模型参数集合,key是特征的名称,value是模型中该特征的系数
	TargetFeature string             `json:"target_feature"` // 目标特征名称
	RSquared      float64            `json:"r_squared"`      // r平方。用于衡量模型的拟合度,介于[0,1],越接近1,说明拟合度越优。
	RMSE          float64            `json:"rmse"`           // Root Mean Squared Error 均方根误差。用于衡量模型的误差。真实值-预测值,平方之后求和,再计算平均值,最后开平方
}

Model 训练后得到的模型

type StandardizedDataSet

type StandardizedDataSet struct {
	Features         []*DataFeature     `json:"features"`          // 样本多元特征
	XbarParams       map[string]float64 `json:"xbar_params"`       // 特征的均值
	SigmaParams      map[string]float64 `json:"sigma_params"`      // 特征的标准差
	OriginalFeatures []*DataFeature     `json:"original_features"` // 标准化处理之前的原始样本多元特征
}

StandardizedDataSet 经过标准化后的样本数据集

type TrainDataSet

type TrainDataSet struct {
	FeatureNames     []string           `json:"feature_names"`      // 特征的名称
	TrainSet         [][]float64        `json:"train_set"`          // 特征集合
	XbarParams       map[string]float64 `json:"xbar_params"`        // 特征的均值
	SigmaParams      map[string]float64 `json:"sigma_params"`       // 特征的标准差
	OriginalTrainSet [][]float64        `json:"original_train_set"` // 标准化处理之前的原始特征集合
}

TrainDataSet 经过预处理后的训练数据集合

Jump to

Keyboard shortcuts

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