matlab 自带分类器(2012b以上)

train_data是训练特征数据, train_label是分类标签。
Predict_label是预测的标签。
MatLab训练数据, 得到语义标签向量 Scores(概率输出)。

1.逻辑回归(多项式MultiNomial logistic Regression)

Factor = mnrfit(train_data, train_label);
Scores = mnrval(Factor, test_data);

2.随机森林分类器(Random Forest)

Factor = TreeBagger(nTree, train_data, train_label);
[Predict_label,Scores] = predict(Factor, test_data);

https://www.cnblogs.com/huadongw/p/5248018.html

3.朴素贝叶斯分类(Naive Bayes)

Factor = NaiveBayes.fit(train_data, train_label);
Scores = posterior(Factor, test_data);
[Scores,Predict_label] = posterior(Factor, test_data);
Predict_label = predict(Factor, test_data);
accuracy = length(find(predict_label == test_label))/length(test_label)*100;

4. 支持向量机SVM分类

Factor = svmtrain(train_data, train_label);
predict_label = svmclassify(Factor, test_data);

5.K近邻分类器 (KNN)

Factor = ClassificationKNN.fit(train_data, train_label, 'NumNeighbors', num_neighbors);
predict_label = predict(Factor, test_data);
[predict_label, Scores] = predict(Factor, test_data);

6.集成学习器(Ensembles for Boosting, Bagging, or Random Subspace)

Factor = fitensemble(train_data, train_label, 'AdaBoostM2', 100, 'tree');
Factor = fitensemble(train_data, train_label, 'AdaBoostM2', 100, 'tree', 'type', 'classification');
Factor = fitensemble(train_data, train_label, 'Subspace', 50, 'KNN');
predict_label = predict(Factor, test_data);
[predict_label, Scores] = predict(Factor, test_data);

7. 判别分析分类器(discriminant analysis classifier)

Factor = ClassificationDiscriminant.fit(train_data, train_label);
Factor = ClassificationDiscriminant.fit(train_data, train_label, 'discrimType', '判别类型:伪线性...');
predict_label = predict(Factor, test_data);
[predict_label, Scores] = predict(Factor, test_data);

参考:http://blog.csdn.net/xuhaijiao99/article/details/15027093

已标记关键词 清除标记
相关推荐
©️2020 CSDN 皮肤主题: 书香水墨 设计师:CSDN官方博客 返回首页