Package org.grouplens.lenskit.util.table

Examples of org.grouplens.lenskit.util.table.TableLayoutBuilder


        outputFile = file;
        columnHeaders = Lists.newArrayList(columns);
        function = func;
        evalLayout = layout;

        TableLayoutBuilder builder = TableLayoutBuilder.copy(evalLayout.getCommonLayout());
        for (String col: columnHeaders) {
            builder.addColumn(col);
        }
        try {
            writer = CSVWriter.open(outputFile, builder.build());
        } catch (IOException e) {
            throw new RuntimeException("error opening output file", e);
        }
    }
View Full Code Here


        rowData = new ObjectArrayList<Object>(writer.getLayout().getColumnCount());
        rowData.addAll(values);

        fixedColumns = values.size();

        TableLayoutBuilder bld = new TableLayoutBuilder();
        List<String> bheaders = baseLayout.getColumns();
        for (String h : bheaders.subList(fixedColumns, bheaders.size())) {
            bld.addColumn(h);
        }
        layout = bld.build();
        assert layout.getColumnCount() + rowData.size() == writer.getLayout().getColumnCount();
    }
View Full Code Here

     * @param experiments The experiments.
     * @param measurements The measurements.
     * @return An output layout for the suite of experiments.
     */
    public static ExperimentOutputLayout create(ExperimentSuite experiments, MeasurementSuite measurements) {
        TableLayoutBuilder master = new TableLayoutBuilder();
        master.addColumn("Algorithm");
        Map<String,Integer> dataColumns = new HashMap<String, Integer>();
        for (String attr: experiments.getDataAttributes()) {
            dataColumns.put(attr, master.getColumnCount());
            master.addColumn(attr);
        }

        Map<String,Integer> algoColumns = new HashMap<String, Integer>();
        for (String attr: experiments.getAlgorithmAttributes()) {
            algoColumns.put(attr, master.getColumnCount());
            master.addColumn(attr);
        }

        TableLayout common = master.build();

        TableLayout results = layoutAggregateOutput(master, measurements);
        TableLayout user = layoutUserTable(master, measurements);

        return new ExperimentOutputLayout(common, dataColumns, algoColumns, results, user);
View Full Code Here

        return new ExperimentOutputLayout(common, dataColumns, algoColumns, results, user);
    }

    private static TableLayout layoutAggregateOutput(TableLayoutBuilder master, MeasurementSuite measurements) {
        TableLayoutBuilder output = master.clone();
        output.addColumn("BuildTime");
        output.addColumn("TestTime");

        for (MetricFactory<?> mf: measurements.getMetricFactories()) {
            List<String> labels = mf.getColumnLabels();
            if (labels != null) {
                for (String c: labels) {
                    output.addColumn(c);
                }
            }
        }

        return output.build();
    }
View Full Code Here

        return output.build();
    }

    private static TableLayout layoutUserTable(TableLayoutBuilder master, MeasurementSuite measurements) {
        TableLayoutBuilder perUser = master.clone();
        perUser.addColumn("User");
        perUser.addColumn("TestTime");
        perUser.addColumn("TrainEvents");
        perUser.addColumn("TestEvents");

        for (MetricFactory<?> mf : measurements.getMetricFactories()) {
            List<String> userColumnLabels = mf.getUserColumnLabels();
            if (userColumnLabels != null) {
                for (String c : userColumnLabels) {
                    perUser.addColumn(c);
                }
            }
        }

        return perUser.build();
    }
View Full Code Here

                               List<Pair<Symbol, String>> chans) throws IOException {
        super(Void.TYPE, Void.TYPE);
        outputLayout = layout;
        channels = chans;

        TableLayoutBuilder lb = TableLayoutBuilder.copy(layout.getCommonLayout())
                                                  .addColumn("User")
                                                  .addColumn("Item")
                                                  .addColumn("Rating")
                                                  .addColumn("Prediction");
        for (Pair<Symbol, String> chan: channels) {
            lb.addColumn(chan.getRight());
        }

        tableWriter = CSVWriter.open(file, lb.build());
    }
View Full Code Here

TOP

Related Classes of org.grouplens.lenskit.util.table.TableLayoutBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.