List of usage examples for com.google.common.primitives Doubles asList
public static List<Double> asList(double... backingArray)
From source file:org.dllearner.algorithms.qtl.experiments.Diagrams.java
public static void main(String[] args) throws Exception { File dir = new File(args[0]); dir.mkdirs();//from w w w. j a v a 2 s . co m Properties config = new Properties(); config.load(Thread.currentThread().getContextClassLoader() .getResourceAsStream("org/dllearner/algorithms/qtl/qtl-eval-config.properties")); String url = config.getProperty("url"); String username = config.getProperty("username"); String password = config.getProperty("password"); Class.forName("com.mysql.jdbc.Driver").newInstance(); // url = "jdbc:mysql://address=(protocol=tcp)(host=[2001:638:902:2010:0:168:35:138])(port=3306)(user=root)/qtl"; Connection conn = DriverManager.getConnection(url, username, password); int[] nrOfExamplesIntervals = { 5, 10, // 15, 20, // 25, 30 }; double[] noiseIntervals = { 0.0, 0.1, 0.2, 0.3, // 0.4, // 0.6 }; Map<HeuristicType, String> measure2ColumnName = Maps.newHashMap(); measure2ColumnName.put(HeuristicType.FMEASURE, "avg_fscore_best_returned"); measure2ColumnName.put(HeuristicType.PRED_ACC, "avg_predacc_best_returned"); measure2ColumnName.put(HeuristicType.MATTHEWS_CORRELATION, "avg_mathcorr_best_returned"); HeuristicType[] measures = { HeuristicType.PRED_ACC, HeuristicType.FMEASURE, HeuristicType.MATTHEWS_CORRELATION }; String[] labels = { "A_1", "F_1", "MCC" }; // get distinct noise intervals // |E| vs fscore String sql = "SELECT nrOfExamples,%s from eval_overall WHERE heuristic_measure = ? && noise = ? ORDER BY nrOfExamples"; PreparedStatement ps; for (double noise : noiseIntervals) { String s = ""; s += "\t"; s += Joiner.on("\t").join(Ints.asList(nrOfExamplesIntervals)); s += "\n"; for (HeuristicType measure : measures) { ps = conn.prepareStatement(String.format(sql, measure2ColumnName.get(measure))); ps.setString(1, measure.toString()); ps.setDouble(2, noise); ResultSet rs = ps.executeQuery(); s += measure; while (rs.next()) { int nrOfExamples = rs.getInt(1); double avgFscore = rs.getDouble(2); s += "\t" + avgFscore; } s += "\n"; } Files.write(s, new File(dir, "examplesVsScore-" + noise + ".tsv"), Charsets.UTF_8); } // noise vs fscore sql = "SELECT noise,%s from eval_overall WHERE heuristic_measure = ? && nrOfExamples = ?"; NavigableMap<Integer, Map<HeuristicType, double[][]>> input = new TreeMap<>(); for (int nrOfExamples : nrOfExamplesIntervals) { String s = ""; s += "\t"; s += Joiner.on("\t").join(Doubles.asList(noiseIntervals)); s += "\n"; String gnuplot = ""; // F-score ps = conn.prepareStatement( "SELECT noise,avg_fscore_best_returned from eval_overall WHERE heuristic_measure = 'FMEASURE' && nrOfExamples = ?"); ps.setInt(1, nrOfExamples); ResultSet rs = ps.executeQuery(); gnuplot += "\"F_1\"\n"; while (rs.next()) { double noise = rs.getDouble(1); double avgFscore = rs.getDouble(2); gnuplot += noise + "," + avgFscore + "\n"; } // precision gnuplot += "\n\n"; ps = conn.prepareStatement( "SELECT noise,avg_precision_best_returned from eval_overall WHERE heuristic_measure = 'FMEASURE' && nrOfExamples = ?"); ps.setInt(1, nrOfExamples); rs = ps.executeQuery(); gnuplot += "\"precision\"\n"; while (rs.next()) { double noise = rs.getDouble(1); double avgFscore = rs.getDouble(2); gnuplot += noise + "," + avgFscore + "\n"; } // recall gnuplot += "\n\n"; ps = conn.prepareStatement( "SELECT noise,avg_recall_best_returned from eval_overall WHERE heuristic_measure = 'FMEASURE' && nrOfExamples = ?"); ps.setInt(1, nrOfExamples); rs = ps.executeQuery(); gnuplot += "\"recall\"\n"; while (rs.next()) { double noise = rs.getDouble(1); double avgFscore = rs.getDouble(2); gnuplot += noise + "," + avgFscore + "\n"; } // MCC gnuplot += "\n\n"; ps = conn.prepareStatement( "SELECT noise,avg_mathcorr_best_returned from eval_overall WHERE heuristic_measure = 'MATTHEWS_CORRELATION' && nrOfExamples = ?"); ps.setInt(1, nrOfExamples); rs = ps.executeQuery(); gnuplot += "\"MCC\"\n"; while (rs.next()) { double noise = rs.getDouble(1); double avgFscore = rs.getDouble(2); gnuplot += noise + "," + avgFscore + "\n"; } // baseline F-score gnuplot += "\n\n"; ps = conn.prepareStatement( "SELECT noise,avg_fscore_baseline from eval_overall WHERE heuristic_measure = 'FMEASURE' && nrOfExamples = ?"); ps.setInt(1, nrOfExamples); rs = ps.executeQuery(); gnuplot += "\"baseline F_1\"\n"; while (rs.next()) { double noise = rs.getDouble(1); double avgFscore = rs.getDouble(2); gnuplot += noise + "," + avgFscore + "\n"; } // baseline MCC gnuplot += "\n\n"; ps = conn.prepareStatement( "SELECT noise,avg_mathcorr_baseline from eval_overall WHERE heuristic_measure = 'MATTHEWS_CORRELATION' && nrOfExamples = ?"); ps.setInt(1, nrOfExamples); rs = ps.executeQuery(); gnuplot += "\"baseline MCC\"\n"; while (rs.next()) { double noise = rs.getDouble(1); double avgFscore = rs.getDouble(2); gnuplot += noise + "," + avgFscore + "\n"; } Files.write(gnuplot.trim(), new File(dir, "noiseVsScore-" + nrOfExamples + ".dat"), Charsets.UTF_8); } if (!input.isEmpty()) { // plotNoiseVsFscore(input); } }
From source file:org.jpmml.sparkml.VectorUtil.java
static public List<Double> toList(Vector vector) { DenseVector denseVector = vector.toDense(); double[] values = denseVector.values(); return Doubles.asList(values); }
From source file:org.immutables.check.Checkers.java
public static IterableChecker<List<Double>, Double> check(double[] actualDoubleArray) { return check(Doubles.asList(actualDoubleArray)); }
From source file:org.jpmml.rexp.RDoubleVector.java
@Override public List<Double> getValues() { return Doubles.asList(this.values); }
From source file:com.analog.lyric.options.OptionDoubleList.java
public OptionDoubleList(double... elements) { super(Doubles.asList(elements).toArray(new Double[elements.length])); }
From source file:org.truth0.subjects.PrimitiveDoubleArraySubject.java
@Override protected List<Double> listRepresentation() { return Doubles.asList(getSubject()); }
From source file:org.jpmml.sparkml.model.GBTRegressionModelConverter.java
@Override public MiningModel encodeModel(Schema schema) { GBTRegressionModel model = getTransformer(); List<TreeModel> treeModels = TreeModelUtil.encodeDecisionTreeEnsemble(model, schema); MiningModel miningModel = new MiningModel(MiningFunction.REGRESSION, ModelUtil.createMiningSchema(schema)) .setSegmentation(MiningModelUtil.createSegmentation(Segmentation.MultipleModelMethod.WEIGHTED_SUM, treeModels, Doubles.asList(model.treeWeights()))); return miningModel; }
From source file:qa.ProcessFrame.java
public void setScores(int idx, double[] scoresArr) { scores.set(idx, Lists.newArrayList(Doubles.asList(scoresArr))); }
From source file:data.visualization.Plots.java
/** * Plot a time series, connecting the observation times to the measurements. * * @param timeSeries the series to plot. * @param title the title of the plot. * @param seriesName the name of the series to display. *///w w w . jav a 2 s.co m public static void plot(final TimeSeries timeSeries, final String title, final String seriesName) { new Thread(() -> { final List<Date> xAxis = new ArrayList<>(timeSeries.observationTimes().size()); for (OffsetDateTime dateTime : timeSeries.observationTimes()) { xAxis.add(Date.from(dateTime.toInstant())); } List<Double> seriesList = Doubles.asList(round(timeSeries.asArray(), 2)); final XYChart chart = new XYChartBuilder().theme(Styler.ChartTheme.GGPlot2).height(600).width(800) .title(title).build(); XYSeries residualSeries = chart.addSeries(seriesName, xAxis, seriesList); residualSeries.setXYSeriesRenderStyle(XYSeries.XYSeriesRenderStyle.Scatter); residualSeries.setMarker(new Circle()).setMarkerColor(Color.RED); JPanel panel = new XChartPanel<>(chart); JFrame frame = new JFrame(title); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.add(panel); frame.pack(); frame.setVisible(true); }).start(); }
From source file:org.esa.s3tbx.olci.radiometry.rayleigh.SpikeInterpolation.java
public static int arrayIndex(double[] xCoordinate, double val) { return Doubles.asList(xCoordinate).indexOf(val); }