sklearn的超参数优化
hpsklearn的Python项目详细描述
#hyperopt sklearn
[hyperopt sklearn](http://hyperopt.github.com/hyperopt-sklearn/)是在
[scikit learn](http://scikit learn.org/)中基于机器学习算法的模型选择。
gh[示例](http://hyperopt.github.io/hyperopt sklearn/文档)
或更早的
[笔记本](http://nbviewer.ipython.org/github/hyperopt/hyperopt sklearn/tree/master/notebooks)
ne git@github.com:hyperopt/hyperopt sklearn.git
(cd hyperopt sklearn&;pip install-e.)
psklearn import hyperoptistimator,svc
来自sklearn import svm
)
分为训练集和测试集
y=iris.target
test_size=int(0.2*len(y))
np.random.seed(13)
index=np.random.permutation(len(x))
x_train=x[index[:-test_size]
y廑train=y[index[:-test_size]
x廑test test=x[索引[-测试大小:]
y撸测试=y[索引[-测试大小:]
),
algo=tpe.建议,
max_evals=100,
trial_timeout=120)
e(x_u检验,y_u检验))
,
最小样本量叶=1,最小样本量叶=2,
最小加权样本量叶=0.0,n个估计量=13,n个工作数=1,
oob评分=False,随机状态=1,verbose=False,
最小样本量叶=0.0,n个估计量=13,n个工作数=1,
最小样本量叶=0.0一个例子e使用mnist,并对分类器和预处理更加具体。
```
从hpsklearn import hyperoptestimator,额外的树
从sklearn.datasets import fetch hymldata
从hyperopt import tpe
将numpy导入np
下载数据并分成训练和测试集
digits=fetch mldata('mnist original')
x=digits.data
y=digits.target
测试大小=int(0.2*len(y))
np.random.seed(13)
索引=np.random.permutation(len(x))
x列=x[索引[:-测试大小]
y列=y[索引[:-测试大小]
x列st=x[索引[-test_size:]
y_test=y[索引[-test_size:]
algo=tpe.建议,
最大值=10,
t
根据数据搜索超参数空间
estim.fit(x_火车,y_火车)
;显示结果
打印(estim.score(x_检验,y_检验))
<0.96278585714286
prin打印(estim.best_model())
<0.962785714286
{{{{{{{{{{}{{{{{{{{}{{{}=真,类权重=无,准则='熵',
最大深度=无,最大特征=0.9592022875857,
最大叶节点=无,最小杂质减少=0.0,
最大叶节点=无,最小杂质减少=0.0,
最小杂质分裂=无,最小样本叶=1,
最小样本分裂=2,最小重量分数叶=0.0,
n估计值=20,n个工作=1,oob,oob。u score=false,随机状态=3,
verbose=false,warm_start=false),"predocs":(),"ex_predocs":()}
`````
发出或发出请求!
实现这些功能的源代码在[这里]找到(https://github.com/hyperopt/hyperopt/hyperopt/hyperopt-sklearn/blob/master/hpsklearn/components.py)
` `
svc
svc非线性
svc非线性
svc非线性
svc
svc非线性
knn
adau boost
梯度增强
随机森林
>额外的树
>决策树
>sgd
>xgboost分类
>多项式
>高斯
>被动主动主动主动
>线性判别分析
>二次判别分析
>rbm
>colkmean
>一对一对一对一对一对一对一对一对一。br/>对于一个简单的泛型在多个分类器之间搜索空间,使用"任意分类器"。如果您的数据是稀疏矩阵格式,请使用"任何稀疏分类法"。
<
<
svr
svr
svr线性
svr rbf
svr多元
adau-boo _回归
森林回归
额外树木回归
sgd回归
xgboost_regression
```
如果您的数据是稀疏矩阵格式,请使用"任意稀疏回归器"。
<
<
对于跨许多预处理算法的简单通用搜索空间,请使用"any"prep处理`.
如果使用原始文本数据,请使用"任何文本预处理"。
当前只有tfidf用于文本,但将来可能会添加更多。
请注意,"hyperoptestimator"中的"预处理"参数需要一个列表,因为各种预处理步骤可以链接在一起。
通用搜索空间函数s"any_preprocessing"和"any_text_preprocessing"已经返回一个列表,但其他的则不返回,因此应该将它们包装在一个列表中。
如果不想执行任何预处理,请传入一个空列表`[]`。
[hyperopt sklearn](http://hyperopt.github.com/hyperopt-sklearn/)是在
[scikit learn](http://scikit learn.org/)中基于机器学习算法的模型选择。
gh[示例](http://hyperopt.github.io/hyperopt sklearn/文档)
或更早的
[笔记本](http://nbviewer.ipython.org/github/hyperopt/hyperopt sklearn/tree/master/notebooks)
ne git@github.com:hyperopt/hyperopt sklearn.git
(cd hyperopt sklearn&;pip install-e.)
psklearn import hyperoptistimator,svc
来自sklearn import svm
)
分为训练集和测试集
test_size=int(0.2*len(y))
np.random.seed(13)
index=np.random.permutation(len(x))
x_train=x[index[:-test_size]
y廑train=y[index[:-test_size]
x廑test test=x[索引[-测试大小:]
y撸测试=y[索引[-测试大小:]
),
algo=tpe.建议,
max_evals=100,
trial_timeout=120)
e(x_u检验,y_u检验))
,
最小样本量叶=1,最小样本量叶=2,
最小加权样本量叶=0.0,n个估计量=13,n个工作数=1,
oob评分=False,随机状态=1,verbose=False,
最小样本量叶=0.0,n个估计量=13,n个工作数=1,
最小样本量叶=0.0一个例子e使用mnist,并对分类器和预处理更加具体。
```
从hpsklearn import hyperoptestimator,额外的树
从sklearn.datasets import fetch hymldata
从hyperopt import tpe
将numpy导入np
下载数据并分成训练和测试集
digits=fetch mldata('mnist original')
x=digits.data
y=digits.target
测试大小=int(0.2*len(y))
np.random.seed(13)
索引=np.random.permutation(len(x))
x列=x[索引[:-测试大小]
y列=y[索引[:-测试大小]
x列st=x[索引[-test_size:]
y_test=y[索引[-test_size:]
algo=tpe.建议,
最大值=10,
t
根据数据搜索超参数空间
estim.fit(x_火车,y_火车)
;显示结果
打印(estim.score(x_检验,y_检验))
<0.96278585714286
prin打印(estim.best_model())
<0.962785714286
{{{{{{{{{{}{{{{{{{{}{{{}=真,类权重=无,准则='熵',
最大深度=无,最大特征=0.9592022875857,
最大叶节点=无,最小杂质减少=0.0,
最大叶节点=无,最小杂质减少=0.0,
最小杂质分裂=无,最小样本叶=1,
最小样本分裂=2,最小重量分数叶=0.0,
n估计值=20,n个工作=1,oob,oob。u score=false,随机状态=3,
verbose=false,warm_start=false),"predocs":(),"ex_predocs":()}
`````
发出或发出请求!
实现这些功能的源代码在[这里]找到(https://github.com/hyperopt/hyperopt/hyperopt/hyperopt-sklearn/blob/master/hpsklearn/components.py)
` `
svc
svc非线性
svc非线性
svc非线性
svc
svc非线性
knn
adau boost
梯度增强
随机森林
>额外的树
>决策树
>sgd
>xgboost分类
>多项式
>高斯
>被动主动主动主动
>线性判别分析
>二次判别分析
>rbm
>colkmean
>一对一对一对一对一对一对一对一对一。br/>对于一个简单的泛型在多个分类器之间搜索空间,使用"任意分类器"。如果您的数据是稀疏矩阵格式,请使用"任何稀疏分类法"。
<
<
svr
svr
svr线性
svr rbf
svr多元
adau-boo _回归
森林回归
额外树木回归
sgd回归
xgboost_regression
```
如果您的数据是稀疏矩阵格式,请使用"任意稀疏回归器"。
<
<
对于跨许多预处理算法的简单通用搜索空间,请使用"any"prep处理`.
如果使用原始文本数据,请使用"任何文本预处理"。
当前只有tfidf用于文本,但将来可能会添加更多。
请注意,"hyperoptestimator"中的"预处理"参数需要一个列表,因为各种预处理步骤可以链接在一起。
通用搜索空间函数s"any_preprocessing"和"any_text_preprocessing"已经返回一个列表,但其他的则不返回,因此应该将它们包装在一个列表中。
如果不想执行任何预处理,请传入一个空列表`[]`。