/** * Allocate a data item large enough to hold a single input vector. * * @return The data element. */ public MLData allocateInputVector() { return allocateInputVector(1); }
/** * 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); }
/** * Define an input column. * @param col The input column. */ public void defineInput(ColumnDefinition col) { this.helper.getInputColumns().add(col); }
NormalizationStrategy strat = this.helper.getNormStrategy(); .calculateNormalizedInputCount(); int normalizedOutputColumns = this.helper .calculateNormalizedOutputCount(); while ((line = this.source.readLine()) != null) { int column = 0; for (ColumnDefinition colDef : this.helper.getInputColumns()) { int index = findIndex(colDef); String value = line[index]; column = this.helper.normalizeToVector(colDef, column, getData()[row], true, value); for (ColumnDefinition colDef : this.helper.getOutputColumns()) { int index = findIndex(colDef); String value = line[index]; column = this.helper.normalizeToVector(colDef, column, getData()[row], false, value);
@Override protected Object doPredict(String[] line) { NormalizationHelper helper = model.getDataset().getNormHelper(); MLData input = helper.allocateInputVector(); helper.normalizeInputVector(line, input.getData(), false); MLData output = method.compute(input); DataType outputType = types.get(this.output); switch (outputType) { case _float : return output.getData(0); case _class: return helper.denormalizeOutputVectorToString(output)[0]; default: throw new IllegalArgumentException("Output type not yet supported "+outputType); } }
/** * {@inheritDoc} */ @Override public String suggestModelArchitecture(VersatileMLDataSet dataset) { int inputColumns = dataset.getNormHelper().getInputColumns().size(); int outputColumns = dataset.getNormHelper().getOutputColumns().size(); int hiddenCount = (int) ((double)(inputColumns+outputColumns) * 1.5); StringBuilder result = new StringBuilder(); result.append("?->gaussian(c="); result.append(hiddenCount); result.append(")->?"); return result.toString(); }
/** * 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 int determineOutputCount(VersatileMLDataSet dataset) { return dataset.getNormHelper().calculateNormalizedOutputCount(); } }
/** * Allocate a data item large enough to hold several input vectors. This is * normally used for timeslices. * * @param multiplier * How many input vectors. * @return The data element. */ public MLData allocateInputVector(int multiplier) { return new BasicMLData(calculateNormalizedInputCount() * multiplier); }
/** * Analyze a nominal value. * @param value The value to analyze. */ private void analyzeContinuous(String value) { double d = this.owner.getFormat().parse(value); if( this.count<0) { this.low = d; this.high = d; this.mean = d; this.sd = 0; this.count = 1; } else { this.mean = this.mean + d; this.low = Math.min(this.low, d); this.high = Math.max(this.high, d); this.count++; } }
/** * Define a source column. These define the raw input. Use this function if * you know the index of the column in a non-header file. * * @param name * The name of the column. * @param index * The index of the column, needed for non-headered files. * @param colType * The column type. * @return The column definition */ public ColumnDefinition defineSourceColumn(String name, int index, ColumnType colType) { ColumnDefinition result = new ColumnDefinition(name, colType); result.setIndex(index); addSourceColumn(result); return result; }
/** * {@inheritDoc} */ @Override public String suggestModelArchitecture(VersatileMLDataSet dataset) { int inputColumns = dataset.getNormHelper().getInputColumns().size(); int outputColumns = dataset.getNormHelper().getOutputColumns().size(); int hiddenCount = (int) ((double)(inputColumns+outputColumns) * 1.5); StringBuilder result = new StringBuilder(); result.append("?:B->TANH->"); result.append(hiddenCount); result.append(":B->TANH->?"); return result.toString(); }
/** * Define multiple output columns, all others as inputs. * @param outputColumns The output columns. */ public void defineMultipleOutputsOthersInput(ColumnDefinition[] outputColumns) { this.helper.clearInputOutput(); for (ColumnDefinition colDef : this.helper.getSourceColumns()) { boolean isOutput = false; for(ColumnDefinition col : outputColumns) { if( col==colDef) { isOutput = true; } } if ( isOutput) { defineOutput(colDef); } else if (colDef.getDataType() != ColumnType.ignore) { defineInput(colDef); } } }
/** * {@inheritDoc} */ @Override public int determineOutputCount(VersatileMLDataSet dataset) { return dataset.getNormHelper().calculateNormalizedOutputCount(); } }
/** * Create the selected method. * @return The created method. */ public MLMethod createMethod() { if (this.methodType == null) { throw new EncogError( "Please call selectMethod first to choose what type of method you wish to use."); } MLMethodFactory methodFactory = new MLMethodFactory(); MLMethod method = methodFactory.create(methodType, methodArgs, dataset .getNormHelper().calculateNormalizedInputCount(), this.config .determineOutputCount(dataset)); return method; }
@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); }
/** * {@inheritDoc} */ @Override public int determineOutputCount(VersatileMLDataSet dataset) { return dataset.getNormHelper().calculateNormalizedOutputCount(); } }