algorithms

package
v0.8.15 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MethodMinMax          = "minmax"           // 最小-最大归一化(线性缩放)
	MethodZScore          = "zscore"           // Z-Score标准化
	MethodRobust          = "robust"           // 鲁棒标准化
	MethodL2              = "l2"               // L2正则化(单位向量)
	MethodLog             = "log"              // 对数变换
	MethodQuantileUniform = "quantile_uniform" // 映射到均匀分布
	MethodQuantileNormal  = "quantile_normal"  // 映射到正态分布
)

归一化方法常量定义

Variables

View Source
var (
	ErrEmptyData        = errors.New("data cannot be empty")
	ErrInvalidMethod    = errors.New("invalid normalization method")
	ErrConstantFeature  = errors.New("feature has constant value (zero variance)")
	ErrInsufficientData = errors.New("insufficient data points for quantile transformation")
)

自定义错误类型

Functions

func Normalize added in v0.8.6

func Normalize(data []float64, method string) ([]float64, error)

Normalize 归一化入口函数 方法选择建议:

  • 异常值多 → 鲁棒标准化、分位数变换
  • 稀疏数据 → L2正则化、绝对最大值归一化
  • 深度学习 → 最小-最大(适配Sigmoid/ReLU)
  • 正态假设 → Z-Score或分位数正态变换

func Polyfit added in v0.8.4

func Polyfit(x, y []float64, degree int) []float64

Polyfit 用最小二乘法拟合多项式系数

x: 自变量数组,y: 因变量数组,degree: 多项式阶数
返回系数数组(从高阶到低阶),例如 degree=1 时返回 [斜率, 截距]

func Quantile added in v0.8.4

func Quantile(data []float64, p float64) (float64, error)

Quantile 计算分位数 (0 <= p <= 1)

Types

This section is empty.

Jump to

Keyboard shortcuts

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