classification

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: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Predict

func Predict(dataset *common.DTDataSet, tree *CTree) (map[int]string, error)

预测,利用决策树对样本进行预测 - dataset 预测样本集 - tree 训练得到的模型

Types

type CTree

type CTree struct {
	Root *CTreeNode
}

决策树

func Train

func Train(dataset *common.DTDataSet, contFeatures []string, label string, cond StopCondition, regParam float64) (*CTree, error)

训练,返回一个决策树 - dataset 训练样本集 - contFeatures 取值为连续值的特征列表 - label 目标特征 - cond 分支停止条件 - regParam 泛化参数/剪枝参数

type CTreeNode

type CTreeNode struct {
	DataSet     *common.DTDataSet
	FeatureName string      // 当前节点使用的特征,若为叶子节点则该值为空
	Continuous  bool        // 该特征是否为连续值
	SplitValue  interface{} // 特征的分割值,可以是离散或连续值,用来分割样本,若为叶子节点则该值为空
	Result      string      // 该分支最终的决策值,若为非叶子节点该值为空
	Left        *CTreeNode  // 节点的左子节点,若为叶子节点该值为空
	Right       *CTreeNode  // 节点的右子节点,若为叶子节点该值为空
	Depth       int         // 节点所在的分支深度,Root深度为0
	Gini        float64     // 该节点的基尼指数
}

决策树节点

type StopCondition

type StopCondition struct {
	SampleThreshold int     // 节点样本数的阈值,节点的样本数小于该值则该节点标记为叶子节点
	DepthThreshold  int     // 节点深度的阈值,到达阈值则该节点标记为叶子节点
	GiniThreshold   float64 // 基尼指数震荡阈值,若节点基尼指数和父节点基尼指数振的差值小于该值,则该节点标记为叶子节点
}

停止条件涉及的参数

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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