本文整理汇总了Java中com.rapidminer.example.table.DataRowReader.hasNext方法的典型用法代码示例。如果您正苦于以下问题:Java DataRowReader.hasNext方法的具体用法?Java DataRowReader.hasNext怎么用?Java DataRowReader.hasNext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.rapidminer.example.table.DataRowReader
的用法示例。
在下文中一共展示了DataRowReader.hasNext方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fillTableWithRandomValues
import com.rapidminer.example.table.DataRowReader; //导入方法依赖的package包/类
/**
* After creation of a new MemoryExampleTable with given size all values are Double.NaN. Use
* this method to fill the table with random values in the range specified by minimum and
* maximum values of the attributes. Please note that the attributes in the example table must
* already have proper minimum and maximum values. This works only for numerical attribute.
* Nominal attribute values will be set to 0.
*/
private static void fillTableWithRandomValues(ExampleTable exampleTable, ExampleSet baseSet, RandomGenerator random) {
DataRowReader reader = exampleTable.getDataRowReader();
Attribute[] attributes = exampleTable.getAttributes();
while (reader.hasNext()) {
DataRow dataRow = reader.next();
for (int i = 0; i < attributes.length; i++) {
if (attributes[i] != null) {
if (!attributes[i].isNominal()) {
double min = baseSet.getStatistics(attributes[i], Statistics.MINIMUM);
double max = baseSet.getStatistics(attributes[i], Statistics.MAXIMUM);
if (max > min) {
dataRow.set(attributes[i], random.nextDoubleInRange(min, max));
} else {
dataRow.set(attributes[i], random.nextDouble() * 2 - 1);
}
} else {
dataRow.set(attributes[i], 0);
}
}
}
}
}
示例2: fillTableWithRandomValues
import com.rapidminer.example.table.DataRowReader; //导入方法依赖的package包/类
/**
* After creation of a new ExampleTable with given size all values are 0. Use this method to
* fill the table with random values in the range specified by minimum and maximum values of the
* attributes. Please note that the attributes in the example table must already have proper
* minimum and maximum values. This works only for numerical attribute. Nominal attribute values
* will be set to 0.
*/
private static void fillTableWithRandomValues(ExampleTable exampleTable, ExampleSet baseSet, RandomGenerator random) {
DataRowReader reader = exampleTable.getDataRowReader();
Attribute[] attributes = exampleTable.getAttributes();
while (reader.hasNext()) {
DataRow dataRow = reader.next();
for (int i = 0; i < attributes.length; i++) {
if (attributes[i] != null) {
if (!attributes[i].isNominal()) {
double min = baseSet.getStatistics(attributes[i], Statistics.MINIMUM);
double max = baseSet.getStatistics(attributes[i], Statistics.MAXIMUM);
if (max > min) {
dataRow.set(attributes[i], random.nextDoubleInRange(min, max));
} else {
dataRow.set(attributes[i], random.nextDouble() * 2 - 1);
}
} else {
dataRow.set(attributes[i], 0);
}
}
}
}
}
示例3: prepareCopyValueTask
import com.rapidminer.example.table.DataRowReader; //导入方法依赖的package包/类
/**
* Creates a {@link Callable} which copies the values from the source to the target
* {@link ExampleTable} by using the {@link DataRowReader}, only the values of the defined
* {@link Attribute}s will be copied.
*/
private Callable<Void> prepareCopyValueTask(ExampleTable source, ExampleTable target, Attribute[] attributes) {
return new Callable<Void>() {
@Override
public Void call() {
try {
startSignal.await();
DataRowReader sourceReader = source.getDataRowReader();
DataRowReader targetReader = target.getDataRowReader();
DataRow sourceRow = null;
DataRow targetRow = null;
while (sourceReader.hasNext() && targetReader.hasNext()) {
sourceRow = sourceReader.next();
targetRow = targetReader.next();
for (Attribute a : attributes) {
targetRow.set(a, sourceRow.get(a));
}
}
} catch (InterruptedException e) {
Assert.fail(Thread.currentThread().getName() + " " + e.getMessage());
}
return null;
}
};
}
示例4: fillTableWithRandomValues
import com.rapidminer.example.table.DataRowReader; //导入方法依赖的package包/类
/**
* After creation of a new MemoryExampleTable with given size all values are
* Double.NaN. Use this method to fill the table with random values in the
* range specified by minimum and maximum values of the attributes. Please
* note that the attributes in the example table must already have proper
* minimum and maximum values. This works only for numerical attribute.
* Nominal attribute values will be set to 0.
*/
private static void fillTableWithRandomValues(ExampleTable exampleTable, ExampleSet baseSet, RandomGenerator random) {
DataRowReader reader = exampleTable.getDataRowReader();
Attribute[] attributes = exampleTable.getAttributes();
while (reader.hasNext()) {
DataRow dataRow = reader.next();
for (int i = 0; i < attributes.length; i++) {
if (attributes[i] != null) {
if (!attributes[i].isNominal()) {
double min = baseSet.getStatistics(attributes[i], Statistics.MINIMUM);
double max = baseSet.getStatistics(attributes[i], Statistics.MAXIMUM);
if (max > min)
dataRow.set(attributes[i], random.nextDoubleInRange(min, max));
else
dataRow.set(attributes[i], random.nextDouble()*2 - 1);
} else {
dataRow.set(attributes[i], 0);
}
}
}
}
}
示例5: fillTable
import com.rapidminer.example.table.DataRowReader; //导入方法依赖的package包/类
/**
* Fills the table with the length of the given complex numbers in the column of the attribute.
*/
private void fillTable(ExampleTable table, Attribute attribute, Peak[] values) throws OperatorException {
DataRowReader reader = table.getDataRowReader();
int k = 0;
while (reader.hasNext()) {
DataRow dataRow = reader.next();
dataRow.set(attribute, values[k++].getMagnitude());
checkForStop();
}
}
示例6: writeColumnValues
import com.rapidminer.example.table.DataRowReader; //导入方法依赖的package包/类
/**
* Writes the values provided by the {@link #columnFillers} into the table.
*/
private void writeColumnValues() {
DataRowReader tableReader = table.getDataRowReader();
int k = 0;
while (tableReader.hasNext()) {
DataRow dataRow = tableReader.next();
for (Entry<Attribute, IntToDoubleFunction> entry : columnFillers.entrySet()) {
dataRow.set(entry.getKey(), entry.getValue().applyAsDouble(k));
}
k++;
}
}
示例7: doWork
import com.rapidminer.example.table.DataRowReader; //导入方法依赖的package包/类
@Override
public final void doWork() throws OperatorException {
ExampleSet inputExampleSet = exampleSetInput.getData(ExampleSet.class);
ExampleSet applySet = null;
// check for needed copy of original exampleset
if (writesIntoExistingData()) {
int type = DataRowFactory.TYPE_DOUBLE_ARRAY;
if (inputExampleSet.getExampleTable() instanceof MemoryExampleTable) {
DataRowReader dataRowReader = inputExampleSet.getExampleTable().getDataRowReader();
if (dataRowReader.hasNext()) {
type = dataRowReader.next().getType();
}
}
// check if type is supported to be copied
if (type >= 0) {
applySet = MaterializeDataInMemory.materializeExampleSet(inputExampleSet, type);
}
}
if (applySet == null) {
applySet = (ExampleSet) inputExampleSet.clone();
}
// we apply on the materialized data, because writing can't take place in views anyway.
ExampleSet result = apply(applySet);
originalOutput.deliver(inputExampleSet);
exampleSetOutput.deliver(result);
}
示例8: doWork
import com.rapidminer.example.table.DataRowReader; //导入方法依赖的package包/类
@Override
public final void doWork() throws OperatorException {
ExampleSet inputExampleSet = exampleSetInput.getData(ExampleSet.class);
ExampleSet applySet = null;
// check for needed copy of original exampleset
if (originalOutput.isConnected() && writesIntoExistingData()) {
int type = DataRowFactory.TYPE_DOUBLE_ARRAY;
if (inputExampleSet.getExampleTable() instanceof MemoryExampleTable) {
DataRowReader dataRowReader = inputExampleSet.getExampleTable().getDataRowReader();
if (dataRowReader.hasNext()) {
type = dataRowReader.next().getType();
}
}
// check if type is supported to be copied
if (type >= 0) {
applySet = MaterializeDataInMemory.materializeExampleSet(inputExampleSet, type);
}
}
if (applySet == null)
applySet = (ExampleSet) inputExampleSet.clone();
// we apply on the materialized data, because writing can't take place in views anyway.
ExampleSet result = apply(applySet);
originalOutput.deliver(inputExampleSet);
exampleSetOutput.deliver(result);
}
示例9: apply
import com.rapidminer.example.table.DataRowReader; //导入方法依赖的package包/类
@Override
public ExampleSet apply(ExampleSet exampleSet) throws OperatorException {
Tools.onlyNonMissingValues(exampleSet, "Fourier Transform");
// create new example table
int numberOfNewExamples = FastFourierTransform.getGreatestPowerOf2LessThan(exampleSet.size()) / 2;
ExampleTable exampleTable = new MemoryExampleTable(new LinkedList<Attribute>(), new DataRowFactory(DataRowFactory.TYPE_DOUBLE_ARRAY, '.'), numberOfNewExamples);
// create frequency attribute (for frequency)
Attribute frequencyAttribute = AttributeFactory.createAttribute("frequency", Ontology.REAL);
exampleTable.addAttribute(frequencyAttribute);
DataRowReader drr = exampleTable.getDataRowReader();
int k = 0;
while (drr.hasNext()) {
DataRow dataRow = drr.next();
dataRow.set(frequencyAttribute, FastFourierTransform.convertFrequency(k++, numberOfNewExamples, exampleSet.size()));
}
// create FFT values
Attribute label = exampleSet.getAttributes().getLabel();
// add FFT values
FastFourierTransform fft = new FastFourierTransform(WindowFunction.BLACKMAN_HARRIS);
SpectrumFilter filter = new SpectrumFilter(SpectrumFilter.NONE);
for (Attribute current : exampleSet.getAttributes()) {
if (current.isNumerical()) {
Complex[] result = fft.getFourierTransform(exampleSet, label, current);
Peak[] spectrum = filter.filter(result, exampleSet.size());
// create new attribute and fill table with values
Attribute newAttribute = AttributeFactory.createAttribute("fft(" + current.getName() + ")", Ontology.REAL);
exampleTable.addAttribute(newAttribute);
fillTable(exampleTable, newAttribute, spectrum);
}
}
ExampleSet resultSet = new SimpleExampleSet(exampleTable);
return resultSet;
}
示例10: generateAll
import com.rapidminer.example.table.DataRowReader; //导入方法依赖的package包/类
/**
* Generates all new attributes and updates the ExampleTable. Returns a list of Attributes for
* the newly generated attributes.
*
* @param exampleTable
* the source example table
* @param generatorList
* List of FeatureGenerators
* @return A list of Attributes
*/
public static List<Attribute> generateAll(ExampleTable exampleTable, Collection<FeatureGenerator> generatorList)
throws GenerationException {
LogService.getRoot().log(Level.FINE, "com.rapidminer.generator.FeatureGenerator.starting_feature_generation",
generatorList.size());
Iterator<FeatureGenerator> gi = generatorList.iterator();
while (gi.hasNext()) {
gi.next().setExampleTable(exampleTable);
}
// for performance reasons convert the list to an array
FeatureGenerator[] generators = new FeatureGenerator[generatorList.size()];
generatorList.toArray(generators);
List<Attribute> newAttributeList = newAttributes(generators, exampleTable);
// add the attributes to the example table and ensure length of the
// DataRows
exampleTable.addAttributes(newAttributeList);
LogService.getRoot().log(Level.FINE, "com.rapidminer.generator.FeatureGenerator.generator_list", generatorList);
LogService.getRoot().log(Level.FINE,
"com.rapidminer.generator.FeatureGenerator.input_has_feature_count_and_example_count",
new Object[] { exampleTable.getAttributeCount(), exampleTable.size() });
// generate the attribute values:
DataRowReader reader = exampleTable.getDataRowReader();
while (reader.hasNext()) {
DataRow dataRow = reader.next();
for (int j = 0; j < generators.length; j++) {
generators[j].generate(dataRow);
}
}
LogService.getRoot().log(Level.FINE, "com.rapidminer.generator.FeatureGenerator.finished_feature_generation");
LogService.getRoot().log(Level.FINE,
"com.rapidminer.generator.FeatureGenerator.generated_set_has_feature_count_and_example_count",
new Object[] { exampleTable.getAttributeCount(), exampleTable.size() });
return newAttributeList;
}
示例11: apply
import com.rapidminer.example.table.DataRowReader; //导入方法依赖的package包/类
@Override
public ExampleSet apply(ExampleSet exampleSet) throws OperatorException {
Tools.onlyNonMissingValues(exampleSet, getOperatorClassName(), this);
// create new example table
int numberOfNewExamples = FastFourierTransform.getGreatestPowerOf2LessThan(exampleSet.size()) / 2;
ExampleTable exampleTable = new MemoryExampleTable(new LinkedList<Attribute>(), new DataRowFactory(
DataRowFactory.TYPE_DOUBLE_ARRAY, '.'), numberOfNewExamples);
// create frequency attribute (for frequency)
Attribute frequencyAttribute = AttributeFactory.createAttribute("frequency", Ontology.REAL);
exampleTable.addAttribute(frequencyAttribute);
DataRowReader drr = exampleTable.getDataRowReader();
int k = 0;
while (drr.hasNext()) {
DataRow dataRow = drr.next();
dataRow.set(frequencyAttribute,
FastFourierTransform.convertFrequency(k++, numberOfNewExamples, exampleSet.size()));
}
// create FFT values
Attribute label = exampleSet.getAttributes().getLabel();
// add FFT values
FastFourierTransform fft = new FastFourierTransform(WindowFunction.BLACKMAN_HARRIS);
SpectrumFilter filter = new SpectrumFilter(SpectrumFilter.NONE);
for (Attribute current : exampleSet.getAttributes()) {
if (current.isNumerical()) {
Complex[] result = fft.getFourierTransform(exampleSet, label, current);
Peak[] spectrum = filter.filter(result, exampleSet.size());
// create new attribute and fill table with values
Attribute newAttribute = AttributeFactory.createAttribute("fft(" + current.getName() + ")", Ontology.REAL);
exampleTable.addAttribute(newAttribute);
fillTable(exampleTable, newAttribute, spectrum);
}
}
ExampleSet resultSet = new SimpleExampleSet(exampleTable);
return resultSet;
}
示例12: generateAll
import com.rapidminer.example.table.DataRowReader; //导入方法依赖的package包/类
/**
* Generates all new attributes and updates the ExampleTable. Returns a list
* of Attributes for the newly generated attributes.
*
* @param exampleTable
* the source example table
* @param generatorList
* List of FeatureGenerators
* @return A list of Attributes
*/
public static List<Attribute> generateAll(ExampleTable exampleTable, Collection<FeatureGenerator> generatorList) throws GenerationException {
//LogService.getGlobal().log("Starting feature generation with " + generatorList.size() + " generators.", LogService.STATUS);
LogService.getRoot().log(Level.FINE, "com.rapidminer.generator.FeatureGenerator.starting_feature_generation",generatorList.size());
Iterator<FeatureGenerator> gi = generatorList.iterator();
while (gi.hasNext())
gi.next().setExampleTable(exampleTable);
// for performance reasons convert the list to an array
FeatureGenerator[] generators = new FeatureGenerator[generatorList.size()];
generatorList.toArray(generators);
List<Attribute> newAttributeList = newAttributes(generators, exampleTable);
// add the attributes to the example table and ensure length of the
// DataRows
exampleTable.addAttributes(newAttributeList);
//LogService.getGlobal().log("Generator list: " + generatorList, LogService.STATUS);
LogService.getRoot().log(Level.FINE, "com.rapidminer.generator.FeatureGenerator.generator_list",generatorList);
//LogService.getGlobal().log("Input set has " + exampleTable.getAttributeCount() + " features, " + exampleTable.size() + " examples.", LogService.STATUS);
LogService.getRoot().log(Level.FINE, "com.rapidminer.generator.FeatureGenerator.input_has_feature_count_and_example_count",
new Object[] {exampleTable.getAttributeCount(), exampleTable.size()});
// generate the attribute values:
DataRowReader reader = exampleTable.getDataRowReader();
while (reader.hasNext()) {
DataRow dataRow = reader.next();
for (int j = 0; j < generators.length; j++) {
generators[j].generate(dataRow);
}
}
//LogService.getGlobal().log("Finished feature generation.", LogService.STATUS);
LogService.getRoot().log(Level.FINE, "com.rapidminer.generator.FeatureGenerator.finished_feature_generation");
//LogService.getGlobal().log("Generated set has " + exampleTable.getAttributeCount() + " features, " + exampleTable.size() + " examples.", LogService.STATUS);
LogService.getRoot().log(Level.FINE, "com.rapidminer.generator.FeatureGenerator.generated_set_has_feature_count_and_example_count",
new Object[] {exampleTable.getAttributeCount(), exampleTable.size()});
return newAttributeList;
}