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


Java DecisionTree类代码示例

本文整理汇总了Java中ca.pfv.spmf.algorithms.classifiers.decisiontree.id3.DecisionTree的典型用法代码示例。如果您正苦于以下问题:Java DecisionTree类的具体用法?Java DecisionTree怎么用?Java DecisionTree使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DecisionTree类属于ca.pfv.spmf.algorithms.classifiers.decisiontree.id3包,在下文中一共展示了DecisionTree类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import ca.pfv.spmf.algorithms.classifiers.decisiontree.id3.DecisionTree; //导入依赖的package包/类
@Test
public void main() {
    NoExceptionAssertion.assertDoesNotThrow(() -> {
        // Read input file and run algorithm to create a decision tree
        AlgoID3 algo = new AlgoID3();
        // There is three parameters:
        // - a file path
        // - the "target attribute that should be used to create the decision tree
        // - the separator that was used in the file to separate values (by default it is a space)
        DecisionTree tree = algo.runAlgorithm("tennis.txt", "play", " ");
        algo.printStatistics();

        // print the decision tree:
        tree.print();

        // Use the decision tree to make predictions
        // For example, we want to predict the class of an instance:
        String[] instance = {null, "sunny", "hot", "normal", "weak"};
        String prediction = tree.predictTargetAttributeValue(instance);
        System.out.println("The class that is predicted is: " + prediction);
    });
}
 
开发者ID:matfax,项目名称:spmf,代码行数:23,代码来源:MainTestID3.java

示例2: main

import ca.pfv.spmf.algorithms.classifiers.decisiontree.id3.DecisionTree; //导入依赖的package包/类
public static void main(String [] arg) throws IOException{
	// Read input file and run algorithm to create a decision tree
	AlgoID3 algo = new AlgoID3();
	// There is three parameters:
	// - a file path
	// - the "target attribute that should be used to create the decision tree
	// - the separator that was used in the file to separate values (by default it is a space)
	DecisionTree tree = algo.runAlgorithm(fileToPath("tennis.txt"), "play", " ");
	algo.printStatistics();
	
	// print the decision tree:
	tree.print();
	
	// Use the decision tree to make predictions
	// For example, we want to predict the class of an instance:
	String [] instance = {null, "sunny", "hot", "normal", "weak"};
	String prediction = tree.predictTargetAttributeValue(instance);
	System.out.println("The class that is predicted is: " + prediction);
}
 
开发者ID:YinYanfei,项目名称:CadalWorkspace,代码行数:20,代码来源:MainTestID3.java


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