将OpenCV 2.4随机森林参数转换为Scikit-learn

时间:2017-12-21 09:48:02

标签: python-2.7 opencv machine-learning scikit-learn random-forest

我最近训练了一个随机森林分类器来使用OpenCV 2.4对图像进行分类但是,我在将分类器保存到XML文件时遇到了错误,并决定切换到Scikit-learn。

OpenCV中的交叉验证平均得分达到96.70%的准确率,但转换为Scikit-learn时,平均得分降至91.75%。

任何人都可以解释在将OpenCV代码转换为Scikit-learn时我错过了哪些参数?

这是我的OpenCV代码:

class ClassifierTrainer(object):
    def __init__(self, X, label_words):

        # Encoding the labels (words to numbers)
        self.le = preprocessing.LabelEncoder()

        self.clf = RandomForestClassifier(bootstrap=True, class_weight=None, criterion='gini',
            max_depth=100, max_features='auto', max_leaf_nodes=None,
            min_impurity_decrease=0.0, min_impurity_split=None,
            min_samples_leaf=1, min_samples_split=2,
            min_weight_fraction_leaf=0.0, n_estimators=100, n_jobs=1,
            oob_score=False, random_state=0, verbose=0, warm_start=False)

        y = self._encodeLabels(label_words)
        X = np.asarray(X)
        self.clf.fit(X, y)
        scores = cross_val_score(self.clf,X,y)
        print scores.mean()

这是我的Scikit学习代码:

unable to add a reference to project '[projectName]'

0 个答案:

没有答案