2017-07-18 49 views
-2

我有一个15,000左右的小数据集有13个功能。所有的输入都是整数,而不是非常大的数字。SVR,SVM,梯度提升和XGBoost永远运行[python]

我使用这些数据来训练分类器,如SVR,SVM,XGboost等与Gridsearch。

但是每次训练过程中需要永远。(超过60分钟)

我已经扩展我的输入数据X,但它仍然需要大量的时间。 另外,从其他有类似问题的帖子中,加入了catch_size iin分类器,如SVC(cache_size = 7000)来训练模型,但似乎无助于加速计算。

它自己的数据非常小,所以我觉得这很奇怪。

这里是我的代码的例子,如果有人可以给我什么建议,我将非常感激非常。

from xgboost.sklearn import XGBRegressor 

one_to_left = st.beta(10, 1)  
from_zero_positive = st.expon(0, 50) 

params = { 
    "n_estimators": [100, 110, 120, 130, 140, 150, 160, 170, 180, 190,  200], 
    "max_depth": [2, 3, 4, 5, 6, 7, 8, 9, 10], 
    "learning_rate": [0.05, 0.4, 1, 1.5, 2, 2.5, 3, 4], 
    "colsample_bytree": [0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0], 
    "subsample":[0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0], 
         } 

xgbreg = XGBRegressor() 
gs = GridSearchCV(xgbreg, params) 
gs.fit(X_train, y_train) 
y_gs = gs.predict(X_test) 

目标变量y是整数回归问题的百分比; 二进制数据0和1用于分类问题。

+0

不能说XGBoost,但基于svm的估计量与缩放​​数据(主要是意味着标准化)运作良好。看看[这里](http://scikit-learn.org/stable/modules/preprocessing.html#standardization-or-mean-removal-and-variance-scaling)。同时发布您的数据和完整的代码,以便其他人可以验证他们机器上的运行时间。 –

回答

0

让我们看看在电网使用的是:

params = { 
    "n_estimators": [100, 110, 120, 130, 140, 150, 160, 170, 180, 190,  200], 
    "max_depth": [2, 3, 4, 5, 6, 7, 8, 9, 10], 
    "learning_rate": [0.05, 0.4, 1, 1.5, 2, 2.5, 3, 4], 
    "colsample_bytree": [0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0], 
    "subsample":[0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0], 
         } 

电网的总大小为:

from numpy import prod 

grid_size_per_parameter = [len(i) for i in params.values()] 
### [8, 11, 9, 8, 8] 

prod(grid_size_per_parameter) 
50688 # this is how many models you need to train, not counting cv folds 

你有一个大的网格。许多模型要训练。 我的意思是如果这需要一个小时,你仍然可以每分钟训练1000个模型:)

如果你有多CPU机器,你可以设置n_jobs= -1来使用所有可用的并行核心。但我会更聪明地与电网。搜索更小的空间。