package org.apache.mahout.classifier.bayes;
public final class TrainClassifier
bayes和cbyes的入口类
两个分支
public static void trainNaiveBayes(Path dir, Path outputDir, BayesParameters params) throws IOException {
BayesDriver driver = new BayesDriver();
driver.runJob(dir, outputDir, params);
}
public static void trainCNaiveBayes(Path dir, Path outputDir, BayesParameters params) throws IOException {
CBayesDriver driver = new CBayesDriver();
driver.runJob(dir, outputDir, params);
}
先设定所有默认参数,如果有非默认项再覆盖
由于参数过多,定义一个类封装参数,便于后续传递
BayesParameters params = new BayesParameters();
// Setting all the default parameter values
params.setGramSize(1);
params.setMinDF(1);
params.set("alpha_i","1.0");
params.set("dataSource", "hdfs");
if (cmdLine.hasOption(gramSizeOpt)) {
params.setGramSize(Integer.parseInt((String) cmdLine.getValue(gramSizeOpt)));
}
if (cmdLine.hasOption(minDfOpt)) {
params.setMinDF(Integer.parseInt((String) cmdLine.getValue(minDfOpt)));
}
Path inputPath = new Path((String) cmdLine.getValue(inputDirOpt));
Path outputPath = new Path((String) cmdLine.getValue(outputOpt));
if ("cbayes".equalsIgnoreCase(classifierType)) {
log.info("Training Complementary Bayes Classifier");
trainCNaiveBayes(inputPath, outputPath, params);
} else {
log.info("Training Bayes Classifier");
// setup the HDFS and copy the files there, then run the trainer
trainNaiveBayes(inputPath, outputPath, params);
}
package org.apache.mahout.classifier.bayes;
public final class TestClassifier
入口
public static void classifyParallel(BayesParameters params) throws IOException {
BayesClassifierDriver.runJob(params);
}
分并行和非并行两种实现
if ("sequential".equalsIgnoreCase(classificationMethod)) {
classifySequential(params);
} else if ("mapreduce".equalsIgnoreCase(classificationMethod)) {
classifyParallel(params);
}
分享到:
相关推荐
pca特征提取的matlab代码用于音频特征提取、分类、分割和应用的 Python 库 这是 Tyiannak 编写的库 pyAudioAnalysis。 我在库中添加了一个神经网络模型,以便您可以使用神经网络而不是现有的 SVM 和 KNN 来训练和...
测试:一个示例代码,用于根据您的训练模型进行分类和预测。 如何运行这些脚本? 您可以通过启动 MATLAB 并运行来运行此分类器代码 train_model(training_data, model) test_model(model, test_data, test_outputs) ...
pca特征提取的matlab代码用于音频特征提取、分类、分割和应用的 Python 库 这是 Tyiannak 编写的库 pyAudioAnalysis。 我在库中添加了一个神经网络模型,以便您可以使用神经网络而不是现有的 SVM 和 KNN 来训练和...
matlab特征向量分类器代码组织学-多类-纹理 内容 该存储库包含项目“结直肠癌组织学中的纹理分析”的 MATLAB 源代码。 使用此代码,您可以使用...使用“main_trainClassifier.m”来训练分类器。 然后,手动更改“ main
该项目包含两个Matlab脚本和一个用于数据传输的arduino代码。 先决条件 对于Runnig Code,您需要将matlab安装到系统中,并且需要了解Matlab命令。对于Trainnig,您自己的数据需要具有自己的数据手套。 设置 使用...
matlab精度检验代码毫升分类器 基于分类学习器应用程序,从单个MATLAB脚本运行多个机器学习二进制分类器(SVM,LDA,决策树,KNN和逻辑回归)。 [trainedClassifier, validationScores, validationPredictions] = ...
使用svm对三种鱼的数据进行分类,用到了四种鱼的特征数据,核函数为高斯函数
使用表示学习的零射流分类法归纳本文的代码存储库:使用表示学习的零拍分类法归纳:一项实证研究模组1.改造嵌入基于本文实现了改进:将2.超类型分类器要根据分类法创建训练数据,请使用以下命令, python3 ...
actionletEnsemble-master\MSRDailyActivity3D\trainClassifier.m actionletEnsemble-master\README.md actionletEnsemble-master\feature actionletEnsemble-master\feature\computeMotionField.m ...
介绍这是在深度神经网络中提高准确性的多阶建模示例。 展示了如何使用类别预测模型的输出作为第二个模型的预测变量的不同方法。... 此函数是使用 MATLAB 的 CalssifierLearner App 的代码生成功能生成的
OpenCV2 有一个实用程序 trainclassifier,用于训练具有不同阶段的分类器。 使用 40 张图像的正数据集大小和 63 张图像的负数据集尝试了各种标志。 然而,分类器至少需要 6 个小时的训练时间,尝试各种其他选项需要...