当前位置: 首页>>代码示例>>Python>>正文


Python ExtraTreesClassifier.n_estimators方法代码示例

本文整理汇总了Python中sklearn.ensemble.ExtraTreesClassifier.n_estimators方法的典型用法代码示例。如果您正苦于以下问题:Python ExtraTreesClassifier.n_estimators方法的具体用法?Python ExtraTreesClassifier.n_estimators怎么用?Python ExtraTreesClassifier.n_estimators使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sklearn.ensemble.ExtraTreesClassifier的用法示例。


在下文中一共展示了ExtraTreesClassifier.n_estimators方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: range

# 需要导入模块: from sklearn.ensemble import ExtraTreesClassifier [as 别名]
# 或者: from sklearn.ensemble.ExtraTreesClassifier import n_estimators [as 别名]
    
    # storage structure for forecasts
    mvalid = np.zeros((xtrain.shape[0],len(param_grid)))
    mfull = np.zeros((xtest.shape[0],len(param_grid)))
    
    ## build 2nd level forecasts
    for i in range(len(param_grid)):        
            print "processing parameter combo:", i
            # configure model with j-th combo of parameters
            x = param_grid[i]
            model.max_depth = int(x[0])
            model.max_features = int(x[1])
            model.max_features = int(x[2])
            model.min_samples_leaf = int(x[3])
            model.min_weight_fraction_leaf = x[4]
            model.n_estimators = int(x[5])
            
            # loop over folds
            for j in range(0,n_folds):
                idx0 = np.where(fold_index != j)
                idx1 = np.where(fold_index == j)
                x0 = np.array(xtrain)[idx0,:][0];
                x1 = np.array(xtrain)[idx1,:][0]
                y0 = np.array(y)[idx0];
                y1 = np.array(y)[idx1]

                model.fit(x0, y0)
                y_pre = model.predict_proba(x1)[:,1]
                mvalid[idx1,i] = y_pre
                print 'log loss: ', log_loss(y1,y_pre)
                print "finished fold:", j
开发者ID:mpearmain,项目名称:bnp,代码行数:33,代码来源:build_meta_extratrees.py

示例2: tuple

# 需要导入模块: from sklearn.ensemble import ExtraTreesClassifier [as 别名]
# 或者: from sklearn.ensemble.ExtraTreesClassifier import n_estimators [as 别名]
    n_minleaf = [1]
    n_minsplit = [1]
    n_maxfeat = [0.1]
    param_grid = tuple([n_vals, n_minleaf, n_minsplit, n_maxfeat])
    param_grid = list(product(*param_grid))

    # storage structure for forecasts
    mvalid = np.zeros((xtrain.shape[0],len(param_grid)))
    mfull = np.zeros((xtest.shape[0],len(param_grid)))
    
    ## build 2nd level forecasts
    for i in range(len(param_grid)):        
            print "processing parameter combo:", i
            # configure model with j-th combo of parameters
            x = param_grid[i]
            model.n_estimators = x[0]
            model.min_samples_leaf = x[1]     
            model.min_samples_split = x[2]
            model.max_features = x[3]
            
            # loop over folds
            for j in range(0,n_folds):
                idx0 = np.where(fold_index != j)
                idx1 = np.where(fold_index == j)
                x0 = np.array(xtrain)[idx0,:][0];
                x1 = np.array(xtrain)[idx1,:][0]
                y0 = np.array(y_train)[idx0];
                y1 = np.array(y_train)[idx1]

                # fit the model on observations associated with subject whichSubject in this fold
                model.fit(x0, y0)
开发者ID:andreymalakhov,项目名称:homesite,代码行数:33,代码来源:build_meta_extratrees.py


注:本文中的sklearn.ensemble.ExtraTreesClassifier.n_estimators方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。