EL之RF(RFC):利用RF对多分类问题进行建模并评估(六分类+分层抽样)

EL之RF(RFC):利用RF对多分类问题进行建模并评估(六分类+分层抽样)


输出结果

设计思路

核心代码

missCLassError = []
nTreeList = range(50, 2000, 50)
for iTrees in nTreeList:
    depth = None
    maxFeat  = 4 #try tweaking
    glassRFModel = ensemble.RandomForestClassifier(n_estimators=iTrees, max_depth=depth, max_features=maxFeat,
                                                 oob_score=False, random_state=531)

    glassRFModel.fit(xTrain,yTrain)

    prediction = glassRFModel.predict(xTest)
    correct = accuracy_score(yTest, prediction)

    missCLassError.append(1.0 - correct)
(0)

相关推荐