机器学习工具WEKA的使用总结,包括算法选择、属性选择、参数优化

更新时间:2023-10-23 10:25:01 阅读量: 综合文库 文档下载

说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。

一、属性选择:

1、理论知识:

见以下两篇文章:

数据挖掘中的特征选择算法综述及基于WEKA的性能比较_陈良龙 数据挖掘中约简技术与属性选择的研究_刘辉

2、weka中的属性选择

2.1评价策略(attribute evaluator)

总的可分为filter和wrapper方法,前者注重对单个属性进行评价,后者侧重对特征子集进行评价。

Wrapper方法有:CfsSubsetEval Filter方法有:CorrelationAttributeEval

2.1.1 Wrapper方法: (1)CfsSubsetEval

根据属性子集中每一个特征的预测能力以及它们之间的关联性进行评估,单个特征预测能力强且特征子集内的相关性低的子集表现好。

Evaluates the worth of a subset of attributes by considering the individual predictive ability of each feature along with the degree of redundancy between them.Subsets of features that are highly correlated with the class while having low intercorrelation are preferred.

For more information see:

M. A. Hall (1998). Correlation-based Feature Subset Selection for Machine Learning. Hamilton, New Zealand.

(2)WrapperSubsetEval

Wrapper方法中,用后续的学习算法嵌入到特征选择过程中,通过测试特征

子集在此算法上的预测性能来决定其优劣,而极少关注特征子集中每个特征的预测性能。因此,并不要求最优特征子集中的每个特征都是最优的。

Evaluates attribute sets by using a learning scheme. Cross validation is used to estimate the accuracy of the learning scheme for a set of attributes.

For more information see:

Ron Kohavi, George H. John (1997). Wrappers for feature subset selection.Artificial Intelligence. 97(1-2):273-324.

2.1.2 Filter方法:

如果选用此评价策略,则搜索策略必须用Ranker。

(1)CorrelationAttributeEval

根据单个属性和类别的相关性进行选择。

Evaluates the worth of an attribute by measuring the correlation (Pearson's) between it and the class.

Nominal attributes are considered on a value by value basis by treating each value as an indicator. An overall correlation for a nominal attribute is arrived at via a weighted average.

(2)GainRatioAttributeEval

根据信息增益比选择属性。

Evaluates the worth of an attribute by measuring the gain ratio with respect to the class.

GainR(Class, Attribute) = (H(Class) - H(Class | Attribute)) / H(Attribute).

(3)InfoGainAttributeEval

根据信息增益选择属性。

Evaluates the worth of an attribute by measuring the information gain with respect to the class.

InfoGain(Class,Attribute) = H(Class) - H(Class | Attribute).

(4)OneRAttributeEval

根据OneR分类器评估属性。

Class for building and using a 1R classifier; in other words, uses the minimum-error attribute for prediction, discretizing numeric attributes. For more information, see:

R.C. Holte (1993). Very simple classification rules perform well on most commonly used datasets. Machine Learning. 11:63-91.

(5)PrincipalComponents

主成分分析(PCA)。

Performs a principal components analysis and transformation of the data. Use in conjunction with a Ranker search. Dimensionality reduction is accomplished by choosing enough eigenvectors to account for some percentage of the variance in the original data---default 0.95 (95%). Attribute noise can be filtered by transforming to the PC space, eliminating some of the worst eigenvectors, and then transforming back to the original space.

(6)ReliefFAttributeEval

根据ReliefF值评估属性。

Evaluates the worth of an attribute by repeatedly sampling an instance and considering the value of the given attribute for the nearest instance of the same and different class.Can operate on both discrete and continuous class data.

For more information see:

Kenji Kira, Larry A. Rendell: A Practical Approach to Feature Selection. In: Ninth International Workshop on Machine Learning, 249-256, 1992.

Igor Kononenko: Estimating Attributes: Analysis and Extensions of RELIEF. In: European Conference on Machine Learning, 171-182, 1994.

Marko Robnik-Sikonja, Igor Kononenko: An adaptation of Relief for attribute estimation in regression. In: Fourteenth International Conference on Machine Learning, 296-304, 1997.

(7)SymmetricalUncertAttributeEval

根据属性的对称不确定性评估属性。

Evaluates the worth of an attribute by measuring the symmetrical uncertainty with respect to the class.

SymmU(Class, Attribute) = 2 * (H(Class) - H(Class | Attribute)) / H(Class) + H(Attribute).

2.2搜索策略(Search Method)

2.2.1和评价策略中的wrapper方法对应 (1)BestFirst

最好优先的搜索策略。是一种贪心搜索策略。

Searches the space of attribute subsets by greedy hillclimbing augmented with a backtracking facility. Setting the number of consecutive non-improving nodes allowed controls the level of backtracking done. Best first may start with the empty set of attributes and search forward, or start with the full set of attributes and search backward, or start at any point and search in both directions (by considering all possible single attribute additions and deletions at a given point).

(2)ExhaustiveSearch

穷举搜索所有可能的属性子集。

Performs an exhaustive search through the space of attribute subsets starting from the empty set of attrubutes. Reports the best subset found.

(3)GeneticSearch

基于Goldberg在1989年提出的简单遗传算法进行的搜索。

Performs a search using the simple genetic algorithm described in Goldberg (1989).

For more information see:

David E. Goldberg (1989). Genetic algorithms in search, optimization and machine learning.Addison-Wesley.

(4)GreedyStepwise

向前或向后的单步搜索。

Performs a greedy forward or backward search through the space of attribute subsets.May start with no/all attributes or from an arbitrary point in the space. Stops when the addition/deletion of any remaining attributes results in a decrease in evaluation. Can also produce a ranked list of attributes by traversing the space from one side to the other and recording the order that attributes are selected.

(5)RandomSearch

随机搜索。

Performs a Random search in the space of attribute subsets. If no start set is supplied, Random search starts from a random point and reports the best subset found. If a start set is supplied, Random searches randomly for subsets that are as good or better than the start point with the same or or fewer attributes. Using RandomSearch in conjunction with a start set containing all attributes equates to the LVF algorithm of Liu and Setiono (ICML-96).

For more information see:

H. Liu, R. Setiono: A probabilistic approach to feature selection - A filter solution. In: 13th International Conference on Machine Learning, 319-327, 1996.

(6)RankSearch

用一个评估器计算属性判据值并排序。

Uses an attribute/subset evaluator to rank all attributes. If a subset evaluator is specified, then a forward selection search is used to generate a ranked list. From the ranked list of attributes, subsets of increasing size are evaluated, ie. The best attribute, the best attribute plus the next best attribute, etc.... The best attribute set is reported. RankSearch is linear in the number of attributes if a simple attribute evaluator is used such as GainRatioAttributeEval. For more information see:

Mark Hall, Geoffrey Holmes (2003). Benchmarking attribute selection techniques for discrete class data mining.IEEE Transactions on Knowledge and Data Engineering. 15(6):1437-1447.

2.2.2和评价策略中的filter方法对应 (1)Ranker :

对属性的判据值进行排序,和评价策略中的Filter方法结合使用。 Ranks attributes by their individual evaluations. Use in conjunction with attribute evaluators (ReliefF, GainRatio, Entropy etc).

3、我的总结

针对某一算法及其参数设置,选用WrapperSubsetEval评价策略和ExhaustiveSearch搜索策略,能够保证找到适合该算法即参数设置的最优属性子集。但其计算时间较长,并且随着属性个数的增多成指数级增长。

二、参数优化

针对某一特定算法,进行参数优化有以下三种方法:CVParameterSelection、GridSearch、MultiSearch。

1、CVParameterSelection

采用交叉验证的方法,对参数进行优化选择。

优点:

可以对任意数量的参数进行优化选择;

缺点:

①参数太多时,可能造成参数组合数量的爆炸性增长;②只能优化分类器的直接参数,不能优化其嵌入的参数,比如可以优化weka.classifiers.functions.SMO里的参数C,但不能优化weka.classifiers.meta.FilteredClassifier中的嵌入算法weka.classifiers.functions.SMO里的参数C。

示例:优化J48算法的置信系数C

① 载数据集;

② 选择 weka.classifiers.meta.CVParameterSelection作为分类器; ③ 选择weka.classifiers.trees.J48作为②的基分类器;

④ 参数优化的字符串:C 0.1 0.5 5(优化参数C,范围是从0.1至0.5,步距是0.5/5=0.1)

⑤ 进行运算,得到如下图所示的结果(最后一行是优化的参数):

2、GridSearch

采用网格搜索,而不是试验所有的参数组合,进行参数的选择。

优点:

①理论上,相同的优化范围及设置,GridSearch应该比CVParameterSelection要快;②不限于优化分类器的直接参数,也可以优化其嵌入算法的参数;③优化的2个参数中,其中一个可以是filter里的参数,所以需要在属性表达式中加前缀classifier.或filter.;④支持范围的自动扩展。

缺点:

最多优化2个参数。

示例:优化以RBFKernel为核的SMO算法的参数

① 加载数据集;

② 选择GridSearch为Classifier;

③ 选择GridSearch的Classifier为weka.classifiers.functions.SMO ,kernel为weka.classifiers.functions.supportVector.RBFKernel。

④ 设置X参数。XProperty:classifier.c,XMin:1,XMax:16,XStep:1,XExpression:I。这的意思是:选择参数c,其范围是1到16,步长1。 ⑤ 设

Y

YProperty

\:10,YExpression: pow(BASE,I)。这的意思是:选择参数kernel.gamma,其范围是10-5,10-4,…,102。

⑥ 输出如下(最后一行是优化的参数):

3、MultiSearch

类似网格参数,但更普通更简单。

优点:

①不限于优化分类器的直接参数,也可以优化其嵌入算法的参数或filter的参数;②支持任意数量的参数优化;

缺点:

不支持自动扩展边界。

4、我的总结

①如果需要优化的参数不大于2个,选用gridsearch,并且设置边界自动扩展;

②如果需要优化的参数大于2个,选用MultiSearch;

③如果优化分类器的直接参数,且参数数量不大于2个,也可以考虑用CVParameterSelection。

三、meta-Weka的算法

1、算法及描述

LocalWeightedLearning:局部加权学习; AdaBoostM1:AdaBoost方法;

AdditiveRegression:GBRT(Grandient Boosting Regression Tree)梯度下降回归树。是属于Boosting算法,也是将多分类器进行级联训练,后一级的分类器则更多关注前面所有分类器预测结果与实际结果的残差,在这个残差上训练新的分类器,最终预测时将残差级联相加。

AttributeSelectedClassifier:将属性选择和分类器集成设置,先进行属性选择、再进行分类或回归;

Bagging:bagging方法;

ClassificationViaRegression:用回归的方法进行分类;

LogitBoost:是一种boosting算法,用回归进行分类。 MultiClassClassifier:使用两类分类器进行多类分类的方法。 RondomCommittee:随机化基分类器结果的平均值作为结果。 RandomSubspace;

FilterClassifier:将过滤器和分类器集成设置,先进行过滤、再进行分类或回归;(autoweka中没有)

MultiScheme:在所指定的多个分类器或多种参数配置中,选择最优的一个。(犹如experiment)(autoweka中没有)

RandomizableFitteredClassifier:是

FilterClassifier

的变体,对于

RondomCommittee的ensemble classifiers是很有用的。要求不管是filter还是classifier都支持randomizable接口。(autoweka中没有)

Vote; Stacking。

2、我的总结

Meta提供了很多以基分类器为输入的方法,其中: ①AdaBoostM1和Bagging方法是常用的meta方法; ②MultiScheme和experiment的功能类似;

③AttributeSelectedClassifier将属性选择和分类器集成设置,比较方便。

四、Auto-WEKA

Auto-WEKA支持属性、算法、参数的自动选择。

1、属性选择

属性选择作为数据的预处理步骤,在分类或回归前运行。

Auto-WEKA中属性选择的评价策略和搜索策略如上图所示。其中标*的是搜

索策略,其余的是评价策略。可见,不包括WrapperSubsetEval评价策略和ExhaustiveSearch搜索策略组合的完备搜索。

2、算法选择

本文来源:https://www.bwwdw.com/article/hnuf.html

Top