/** * {@inheritDoc} */ @Override public int determineOutputCount(VersatileMLDataSet dataset) { return dataset.getNormHelper().calculateNormalizedOutputCount(); } }
/** * Define a source column. Used when the file does not contain headings. * @param name The name of the column. * @param index The index of the column. * @param colType The column type. * @return The column definition. */ public ColumnDefinition defineSourceColumn(String name, int index, ColumnType colType) { return this.helper.defineSourceColumn(name, index, colType); }
/** * Create the datasets that we will divide into. * @param dataDivisionList The list of divisions. * @param parentDataset The data set to divide. * @param inputCount The input count. * @param idealCount The ideal count. */ private void createDividedDatasets(List<DataDivision> dataDivisionList, VersatileMLDataSet parentDataset, int inputCount, int idealCount) { for (DataDivision division : dataDivisionList) { MatrixMLDataSet dataset = new MatrixMLDataSet(parentDataset.getData(), inputCount, idealCount, division.getMask()); dataset.setLagWindowSize(parentDataset.getLagWindowSize()); dataset.setLeadWindowSize(parentDataset.getLeadWindowSize()); division.setDataset(dataset); } }
/** * Define a single column as an output column, all others as inputs. * @param outputColumn The output column. */ public void defineSingleOutputOthersInput(ColumnDefinition outputColumn) { this.helper.clearInputOutput(); for (ColumnDefinition colDef : this.helper.getSourceColumns()) { if (colDef == outputColumn) { defineOutput(colDef); } else if (colDef.getDataType() != ColumnType.ignore) { defineInput(colDef); } } }
/** * {@inheritDoc} */ @Override public MLDataSet openAdditional() { MatrixMLDataSet result = new MatrixMLDataSet(this.data, this.calculatedInputSize, this.calculatedIdealSize, this.mask); result.setLagWindowSize(getLagWindowSize()); result.setLeadWindowSize(getLeadWindowSize()); return result; }
/** * {@inheritDoc} */ @Override public int determineOutputCount(VersatileMLDataSet dataset) { return dataset.getNormHelper().getOutputColumns().get(0).getClasses().size(); } }
/** * Construct the dataset from another matrix dataset. * @param data The data. * @param mask The mask. */ public MatrixMLDataSet(MatrixMLDataSet data, int[] mask) { this.data = data.getData(); this.calculatedInputSize = data.getCalculatedInputSize(); this.calculatedIdealSize = data.getCalculatedIdealSize(); this.mask = mask; }
/** * Allocate a data item large enough to hold a single input vector. * * @return The data element. */ public MLData allocateInputVector() { return allocateInputVector(1); }
/** * {@inheritDoc} */ @Override public final boolean hasNext() { return this.currentIndex < MatrixMLDataSet.this.size(); }
/** * {@inheritDoc} */ @Override public Iterator<MLDataPair> iterator() { return new MatrixMLDataSetIterator(); }
/** * {@inheritDoc} */ @Override public int size() { return (int) getRecordCount(); }
private int[] buildFirstList(int length) { int[] result = new int[length]; if( this.baseDataset==null) { for (int i = 0; i < length; i++) { result[i] = i; } } else { for (int i = 0; i < length; i++) { result[i] = this.baseDataset.getMask()[i]; } } return result; }
/** * {@inheritDoc} */ @Override public boolean isSupervised() { return getIdealSize() == 0; }
/** * Define an output column. * @param col The output column. */ public void defineOutput(ColumnDefinition col) { this.helper.getOutputColumns().add(col); }
/** * {@inheritDoc} */ @Override public int determineOutputCount(VersatileMLDataSet dataset) { return dataset.getNormHelper().calculateNormalizedOutputCount(); } }
/** * Define a source column. * @param name The name of the source column. * @param colType The column type. * @return The column definition. */ public ColumnDefinition defineSourceColumn(String name, ColumnType colType) { return this.helper.defineSourceColumn(name, -1, colType); }
public void process(boolean shuffle) { int[] firstList = buildFirstList(this.baseDataset.size()); if( shuffle ) { shuffleList(firstList); } List<int[]> foldContents = allocateFolds(); populateFolds(foldContents,firstList); buildSets(foldContents); }
@Override public int determineOutputCount(VersatileMLDataSet dataset) { return dataset.getNormHelper().calculateNormalizedOutputCount(); } }
/** * {@inheritDoc} */ @Override public int determineOutputCount(VersatileMLDataSet dataset) { return dataset.getNormHelper().calculateNormalizedOutputCount(); } }