gradient_descent

package
v0.0.0-...-ebe581b Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EvaluateModelSuperParamByCV

func EvaluateModelSuperParamByCV(sourceDataSet *common.DataSet, targetFeatureName string, alpha, amplitude float64, regMode int, regParam float64, cvMode int, cvParam int) float64

EvaluateModelSuperParamByCV 模型评估,通过RMSE(均方根误差)来评估 使用交叉验证的方案来验证泛化能力(后验知识),评价模型超参数的好坏,便于选择。 例如,可以用来寻找正则化的参数 注意:每次在迭代之前进行预处理,而不是统一进行预处理

- sourceDataSet 原始样本数据 - targetFeatureName 目标特征名称 - alpha 训练学习率 - amplitude 训练目标值 - regMode 正则模式 - regParam 正则参数 - cvMode 交叉验证模式 - cvParam 交叉验证参数

func PreProcessDataSet

func PreProcessDataSet(sourceDataSet *common.StandardizedDataSet, targetFeatureName string) *common.TrainDataSet

PreProcessDataSet 预处理标准化训练数据集

func StandardizeDataSet

func StandardizeDataSet(sourceDataSet *common.DataSet) *common.StandardizedDataSet

StandardizeDataSet 将样本数据集合进行标准化处理,将均值变为0,标准差变为1 Standardize the dataset, so mean will become 0 and standard deviation will become 1 对数据集的每一条数据的每个特征的减去该特征均值后除以特征标准差。 经过数据标准化之后,数据集合的所有特征都有了同样的变化范围。但标准化变换之后的特征分布没有发生改变。 尤其是,当数据集的各个特征取值范围存在较大差异时,或者是各特征取值单位差异较大时,需要使用标准化来对数据进行预处理。 通过该方法,可以使得梯度下降方法更快的找到最小参数以达到拟合收敛要求,或者在训练中使用更高的学习率α 注意,该函数是可选函数,如果数据集的各个特征维度的特征值都处于相似范围内,那么不做标准化处理也没关系。 当不知道数据集的各个特征维度的特征值的分布范围时,最好还是先进行标准化处理。 Z-score Normalization x' = (x - avgerage(x)) / standard_deviation(x)

func TrainModel

func TrainModel(trainDataSet *common.TrainDataSet, alpha float64, amplitude float64, regMode int, regParam float64) *common.Model

TrainModel 模型训练,alpha是梯度下降法的学习率α, amplitude是目标收敛震荡幅度 使用正则化的方案来提升泛化能力(先验知识)

- trainDataSet 预处理过的训练数据 - alpha 训练学习率 - amplitude 训练目标值 - regMode 正则模式 - regParam 正则参数

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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