public AbstractListDataSet() { super(); setId("DataSet" + getCoreObjectId()); }
public final Matrix getInputMatrix() { Matrix input = getMatrix(INPUT); if (input == null) { List<Matrix> matrices = new FastArrayList<Matrix>(); for (Sample s : this) { matrices.add(s.getAsMatrix(INPUT)); } input = Matrix.Factory.vertCat(Ret.LINK, matrices); getMetaData().put(INPUT, input); } return input; }
List<ListDataSet> returnDataSets = new ArrayList<ListDataSet>(); Random rand = new Random(randomSeed); int classCount = getClassCount(); while (!allEmpty(sortedSamples)) { while (to.size() < (double) size() / numberOfCVSets && fromPointer < sortedSamples.size()) { List<Sample> from = sortedSamples.get(fromPointer);
public final Matrix getClassDistribution() { Matrix m = Matrix.Factory.zeros(getClassCount(), 1); Map<Integer, Double> map = new HashMap<Integer, Double>(); for (Sample s : this) { int c = s.getTargetClass(); Double d = map.get(c); if (d == null) { d = 0.0; } d++; map.put(c, d); } for (int i = 0; i < getClassCount(); i++) { Double d = map.get(i); if (d == null) { d = 0.0; } m.setAsDouble(d / size(), i, 0); } return m; }
public final double getAccuracy() { return getMetaDataDouble(ACCURACY); }
public ListDataSet clone() { AbstractListDataSet ds = null; try { ds = this.getClass().newInstance(); } catch (Exception e) { e.printStackTrace(); } for (Sample s : this) { ds.add(s.clone()); } return ds; }
public final int getClassCount() { return (int) get(0).getAsMatrix(TARGET).toColumnVector(Ret.LINK).getColumnCount(); }
public final Matrix getRMSEMatrix() { return getMatrix(RMSE); }
public final Set<String> keySet() { return getMetaData().keySet(); }
public final List<ListDataSet> splitByClass() { List<ListDataSet> returnDataSets = new ArrayList<ListDataSet>(); for (int i = 0; i < getClassCount(); i++) { ListDataSet ds = DataSet.Factory.labeledDataSet("Class " + i); for (Sample s : this) { if (s.getTargetClass() == i) { ds.add(s.clone()); } } returnDataSets.add(ds); } return returnDataSets; }
public final Matrix getTargetMatrix() { Matrix target = getMatrix(TARGET); if (target == null) { List<Matrix> matrices = new FastArrayList<Matrix>(); for (Sample s : this) { matrices.add(s.getAsMatrix(TARGET)); } target = Matrix.Factory.vertCat(Ret.LINK, matrices); getMetaData().put(TARGET, target); } return target; }
public final int getErrorCount() { return (int) getMetaDataDouble(ERRORCOUNT); }
Matrix.Factory.linkToArray(new double[] { 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0 }) .transpose()); animals.add(pigeon); Matrix.Factory.linkToArray(new double[] { 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0 }) .transpose()); animals.add(chicken); Matrix.Factory.linkToArray(new double[] { 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1 }) .transpose()); animals.add(duck); Matrix.Factory.linkToArray(new double[] { 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 1, 1 }) .transpose()); animals.add(goose); Matrix.Factory.linkToArray(new double[] { 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0 }) .transpose()); animals.add(owl); Matrix.Factory.linkToArray(new double[] { 1, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0 }) .transpose()); animals.add(falcon); Matrix.Factory.linkToArray(new double[] { 0, 1, 0, 1, 0, 0, 0, 0, 1, 1, 0, 1, 0 }) .transpose()); animals.add(eagle); Matrix.Factory.linkToArray(new double[] { 0, 1, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0, 0 })
public final int getFeatureCount() { return (int) get(0).getAsMatrix(INPUT).toColumnVector(Ret.LINK).getColumnCount(); }
public final Matrix getPredictedMatrix() { Matrix predicted = getMatrix(PREDICTED); if (predicted == null) { List<Matrix> matrices = new FastArrayList<Matrix>(); for (Sample s : this) { matrices.add(s.getAsMatrix(PREDICTED)); } predicted = Matrix.Factory.vertCat(Ret.LINK, matrices); getMetaData().put(PREDICTED, predicted); } return predicted; }
public final double getAsDouble(String key) { return getMetaDataDouble(key); }