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


Java Table.sampleSplit方法代码示例

本文整理汇总了Java中tech.tablesaw.api.Table.sampleSplit方法的典型用法代码示例。如果您正苦于以下问题:Java Table.sampleSplit方法的具体用法?Java Table.sampleSplit怎么用?Java Table.sampleSplit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tech.tablesaw.api.Table的用法示例。


在下文中一共展示了Table.sampleSplit方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: main

import tech.tablesaw.api.Table; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {

        Table example = Table.read().csv("../data/KNN_Example_1.csv");
        out(example.structure().printHtml());

        // show all the label values
        out(example.shortColumn("Label").asSet());

        Scatter.show("Example data", example.nCol(0), example.nCol(1), example.splitOn(example.shortColumn(2)));

        // two fold validation
        Table[] splits = example.sampleSplit(.5);
        Table train = splits[0];
        Table test = splits[1];

        RandomForest model = RandomForest.learn(10, train.shortColumn(2), train.nCol("X"), train.nCol("Y"));

        ConfusionMatrix matrix = model.predictMatrix(test.shortColumn(2), test.nCol("X"), test.nCol("Y"));

        // Prediction
        out(matrix.toTable().printHtml());
        out(String.valueOf(matrix.accuracy()));
    }
 
开发者ID:jtablesaw,项目名称:tablesaw,代码行数:24,代码来源:RandomForestExample.java

示例2: main

import tech.tablesaw.api.Table; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {

        Table example = Table.read().csv("../data/KNN_Example_1.csv");
        out(example.structure().printHtml());

        // show all the label values
        out(example.shortColumn("Label").asSet());

        Scatter.show("Example data", example.nCol(0), example.nCol(1), example.splitOn(example.shortColumn(2)));

        // two fold validation
        Table[] splits = example.sampleSplit(.5);
        Table train = splits[0];
        Table test = splits[1];

        DecisionTree model = DecisionTree.learn(10, train.shortColumn(2), train.nCol("X"), train.nCol("Y"));

        ConfusionMatrix matrix = model.predictMatrix(test.shortColumn(2), test.nCol("X"), test.nCol("Y"));

        // Prediction
        out(matrix.toTable().printHtml());
        out(String.valueOf(matrix.accuracy()));
    }
 
开发者ID:jtablesaw,项目名称:tablesaw,代码行数:24,代码来源:DecisionTreeExample.java

示例3: main

import tech.tablesaw.api.Table; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {

        Table example = Table.read().csv("../data/KNN_Example_1.csv");
        out(example.structure().printHtml());

        // show all the label values
        out(example.shortColumn("Label").asSet());

        Scatter.show("Example data", example.nCol(0), example.nCol(1), example.splitOn(example.shortColumn(2)));

        // two fold validation
        Table[] splits = example.sampleSplit(.5);
        Table train = splits[0];
        Table test = splits[1];

        LogisticRegression model = LogisticRegression.learn(train.shortColumn(2), train.nCol("X"), train.nCol("Y"));
        ConfusionMatrix matrix = model.predictMatrix(test.shortColumn(2), test.nCol("X"), test.nCol("Y"));

        // Prediction
        out(matrix.toTable().printHtml());
        out(String.valueOf(matrix.accuracy()));
    }
 
开发者ID:jtablesaw,项目名称:tablesaw,代码行数:23,代码来源:LogisticRegressionExample.java

示例4: main

import tech.tablesaw.api.Table; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {

        Table example = Table.read().csv("../data/KNN_Example_1.csv");
        out(example.structure().printHtml());

        // show all the label values
        out(example.shortColumn("Label").asSet());

        Scatter.show("Example data", example.nCol(0), example.nCol(1), example.splitOn(example.shortColumn(2)));

        // two fold validation
        Table[] splits = example.sampleSplit(.5);
        Table train = splits[0];
        Table test = splits[1];

        Lda model = Lda.learn(train.shortColumn(2), train.nCol("X"), train.nCol("Y"));

        ConfusionMatrix matrix = model.predictMatrix(test.shortColumn(2), test.nCol("X"), test.nCol("Y"));

        // Prediction
        out(matrix.toTable().printHtml());
        out(String.valueOf(matrix.accuracy()));
    }
 
开发者ID:jtablesaw,项目名称:tablesaw,代码行数:24,代码来源:LdaExample.java

示例5: main

import tech.tablesaw.api.Table; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {

        Table example = Table.read().csv("../data/KNN_Example_1.csv");
        out(example.structure().printHtml());

        // show all the label values
        out(example.shortColumn("Label").asSet());

        Scatter.show("Example data", example.nCol(0), example.nCol(1), example.splitOn(example.shortColumn(2)));

        // two fold validation
        Table[] splits = example.sampleSplit(.5);
        Table train = splits[0];
        Table test = splits[1];

        Knn knn = Knn.learn(2, train.shortColumn(2), train.nCol("X"), train.nCol("Y"));

        ConfusionMatrix matrix = knn.predictMatrix(test.shortColumn(2), test.nCol("X"), test.nCol("Y"));

        // Prediction
        out(matrix.toTable().printHtml());
        out(String.valueOf(matrix.accuracy()));
    }
 
开发者ID:jtablesaw,项目名称:tablesaw,代码行数:24,代码来源:KnnExample.java

示例6: testAsTable

import tech.tablesaw.api.Table; //导入方法依赖的package包/类
@Test
public void testAsTable() throws Exception {

    Table example = Table.read().csv("../data/KNN_Example_1.csv");

    Table[] splits = example.sampleSplit(.5);
    Table train = splits[0];
    Table test = splits[1];

    KNN<double[]> knn = KNN.learn(
            DoubleArrays.to2dArray(train.nCol("X"), train.nCol("Y")),
            train.shortColumn(2).toIntArray(), 2);

    int[] predicted = new int[test.rowCount()];
    SortedSet<Object> lableSet = new TreeSet<>(train.shortColumn(2).asSet());
    ConfusionMatrix confusion = new StandardConfusionMatrix(lableSet);
    for (int row : test) {
        double[] data = new double[2];
        data[0] = test.floatColumn(0).getFloat(row);
        data[1] = test.floatColumn(1).getFloat(row);
        predicted[row] = knn.predict(data);
        confusion.increment((int) test.shortColumn(2).get(row), predicted[row]);
    }
}
 
开发者ID:jtablesaw,项目名称:tablesaw,代码行数:25,代码来源:ConfusionMatrixTest.java

示例7: testWithBooleanColumn

import tech.tablesaw.api.Table; //导入方法依赖的package包/类
@Test
public void testWithBooleanColumn() throws Exception {

    Table example = Table.read().csv("../data/KNN_Example_1.csv");
    BooleanColumn booleanTarget = example.selectIntoColumn("bt", column("Label").isEqualTo(1));
    example.addColumn(booleanTarget);
    Table[] splits = example.sampleSplit(.5);
    Table train = splits[0];
    Table test = splits[1];

    LogisticRegression lr = LogisticRegression.learn(
            train.booleanColumn(3), train.nCol("X"), train.nCol("Y"));

    //TODO(lwhite): Better tests

    int[] predicted = new int[test.rowCount()];
    SortedSet<Object> lableSet = new TreeSet<>(train.shortColumn(2).asSet());
    ConfusionMatrix confusion = new StandardConfusionMatrix(lableSet);
    for (int row : test) {
        double[] data = new double[2];
        data[0] = test.floatColumn(0).getFloat(row);
        data[1] = test.floatColumn(1).getFloat(row);
        predicted[row] = lr.predict(data);
        confusion.increment((int) test.shortColumn(2).get(row), predicted[row]);
    }

    //TODO(lwhite): Better tests
    assertNotNull(confusion);
}
 
开发者ID:jtablesaw,项目名称:tablesaw,代码行数:30,代码来源:ConfusionMatrixTest.java


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