本文整理汇总了Java中com.rapidminer.datatable.DataTable.isNumerical方法的典型用法代码示例。如果您正苦于以下问题:Java DataTable.isNumerical方法的具体用法?Java DataTable.isNumerical怎么用?Java DataTable.isNumerical使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.rapidminer.datatable.DataTable
的用法示例。
在下文中一共展示了DataTable.isNumerical方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: SingleValueValueRange
import com.rapidminer.datatable.DataTable; //导入方法依赖的package包/类
/**
* Instantiates a new {@link SingleValueValueRange}.
*
* The string representation is created based on the data type of a column in a data table.
*
* @param value
* the value of the value range
* @param dataTable
* a data table, from which the data type of the value is extracted
* @param columnIdx
* the column index in data table which is used to extract the data type of the value
* @throws IllegalArgumentException
* if the specified column has an unknown data type (i.e. neither numerical, nominal
* nor date).
*/
public SingleValueValueRange(double value, DataTable dataTable, int columnIdx) {
this.value = value;
this.columnIdx = columnIdx;
if (columnIdx >= 0) {
if (Double.isNaN(value)) {
valueString = I18N.getGUILabel("plotter.unknown_value_label");
} else if (dataTable.isNumerical(columnIdx)) {
valueString = Double.toString(value);
} else if (dataTable.isNominal(columnIdx)) {
valueString = dataTable.mapIndex(columnIdx, (int) value);
} else if (dataTable.isDateTime(columnIdx)) {
valueString = Tools.formatDateTime(new Date((long) value));
} else {
throw new IllegalArgumentException("unknown data type in data table - this should not happen");
}
}
}
示例2: DataTableColumn
import com.rapidminer.datatable.DataTable; //导入方法依赖的package包/类
/**
* @brief Creates a new {@link DataTableColumn}.
*
* name and value type are automatically initialized from the specified column in
* dataTable. The DataTableColumn does not keep a reference to dataTable.
*/
public DataTableColumn(DataTable dataTable, int columnIdx) {
if (columnIdx >= 0 && columnIdx < dataTable.getColumnNumber()) {
this.columnName = dataTable.getColumnName(columnIdx);
if (dataTable.isDateTime(columnIdx)) {
this.valueType = ValueType.DATE_TIME;
} else if (dataTable.isNominal(columnIdx)) {
this.valueType = ValueType.NOMINAL;
} else if (dataTable.isNumerical(columnIdx)) {
this.valueType = ValueType.NUMERICAL;
} else {
this.valueType = ValueType.INVALID;
}
} else {
this.columnName = null;
this.valueType = ValueType.INVALID;
}
}
示例3: getColumnIndex
import com.rapidminer.datatable.DataTable; //导入方法依赖的package包/类
/**
* Finds the column index for the column named columnName in dataTable, checks if that column in
* the data table is compatible with to settings valueType, and updates this.columnIdx.
*
* If the column does not exist or is not compatible, the columnIdx is set to -1.
*/
public static int getColumnIndex(DataTable dataTable, String columnName, ValueType valueType) {
int columnIdx = dataTable.getColumnIndex(columnName);
if (columnIdx >= 0) {
// check value type
switch (valueType) {
case NOMINAL:
if (!dataTable.isNominal(columnIdx)) {
columnIdx = -1;
}
break;
case NUMERICAL:
if (!dataTable.isNumerical(columnIdx)) {
columnIdx = -1;
}
break;
case DATE_TIME:
if (!dataTable.isDateTime(columnIdx)) {
columnIdx = -1;
}
break;
case INVALID:
// do nothing
break;
}
}
return columnIdx;
}
示例4: doWork
import com.rapidminer.datatable.DataTable; //导入方法依赖的package包/类
@Override
public void doWork() throws OperatorException {
DataTable table = null;
if (isParameterSet(PARAMETER_LOG_NAME)) {
String dataTableName = getParameterAsString(PARAMETER_LOG_NAME);
table = getProcess().getDataTable(dataTableName);
} else {
if (getProcess().getDataTables().size() > 0) {
table = getProcess().getDataTables().iterator().next();
logNote("No log name was specified, using first data table found...");
}
}
// check
if (table == null) {
throw new UserError(this, 939);
}
// create attributes
List<Attribute> attributes = new ArrayList<Attribute>();
for (int i = 0; i < table.getNumberOfColumns(); i++) {
String name = table.getColumnName(i);
if (table.isDate(i)) {
attributes.add(AttributeFactory.createAttribute(name, Ontology.DATE));
} else if (table.isDateTime(i)) {
attributes.add(AttributeFactory.createAttribute(name, Ontology.DATE_TIME));
} else if (table.isNumerical(i)) {
attributes.add(AttributeFactory.createAttribute(name, Ontology.REAL));
} else {
attributes.add(AttributeFactory.createAttribute(name, Ontology.NOMINAL));
}
}
// create table
MemoryExampleTable exampleTable = new MemoryExampleTable(attributes);
for (int r = 0; r < table.getNumberOfRows(); r++) {
DataTableRow row = table.getRow(r);
double[] data = new double[attributes.size()];
for (int i = 0; i < table.getNumberOfColumns(); i++) {
if (table.isDate(i)) {
data[i] = row.getValue(i);
} else if (table.isDateTime(i)) {
data[i] = row.getValue(i);
} else if (table.isNumerical(i)) {
data[i] = row.getValue(i);
} else {
Attribute attribute = attributes.get(i);
String value = table.getValueAsString(row, i);
data[i] = attribute.getMapping().mapString(value);
}
}
exampleTable.addDataRow(new DoubleArrayDataRow(data));
}
// create and return example set
exampleSetOutput.deliver(exampleTable.createExampleSet());
dummyPorts.passDataThrough();
}
示例5: populateCategoryMap
import com.rapidminer.datatable.DataTable; //导入方法依赖的package包/类
private void populateCategoryMap(DataTable dataTable) {
this.categoryToColumnListMap.put(HeuristicPlotterConfigurator.NUMERICAL, new ArrayList<String>());
this.categoryToColumnListMap.put(HeuristicPlotterConfigurator.LABEL, new ArrayList<String>());
this.categoryToColumnListMap.put(HeuristicPlotterConfigurator.NOMINAL, new ArrayList<String>());
this.categoryToColumnListMap.put(HeuristicPlotterConfigurator.DATE, new ArrayList<String>());
for (int i = 0; i < dataTable.getNumberOfColumns(); i++) {
if (dataTable.isNumerical(i)) {
this.categoryToColumnListMap.get(HeuristicPlotterConfigurator.NUMERICAL).add(dataTable.getColumnName(i));
}
if (dataTable.isNominal(i)) {
if (dataTable.getNumberOfValues(i) <= MAX_NOMINAL_VALUES) {
this.categoryToColumnListMap.get(HeuristicPlotterConfigurator.NOMINAL).add(dataTable.getColumnName(i));
}
}
if (dataTable.isDateTime(i)) {
this.categoryToColumnListMap.get(HeuristicPlotterConfigurator.DATE).add(dataTable.getColumnName(i));
}
}
if (dataTable instanceof DataTableExampleSetAdapter) {
DataTableExampleSetAdapter mine = (DataTableExampleSetAdapter) dataTable;
String labelName = mine.getLabelName();
if (labelName != null) {
if (mine.isLabelNominal()) {
// only add nominal labels with less than MAX_NOMINAL_VALUES different values
if (mine.getNumberOfValues(mine.getColumnIndex(labelName)) <= MAX_NOMINAL_VALUES) {
this.categoryToColumnListMap.get(HeuristicPlotterConfigurator.NOMINAL).add(labelName);
this.categoryToColumnListMap.get(HeuristicPlotterConfigurator.LABEL).add(labelName);
}
} else {
this.categoryToColumnListMap.get(HeuristicPlotterConfigurator.LABEL).add(labelName);
}
// remove Label from the numerical attribute list
if (this.categoryToColumnListMap.get(HeuristicPlotterConfigurator.NUMERICAL).contains(labelName)) {
this.categoryToColumnListMap.get(HeuristicPlotterConfigurator.NUMERICAL).remove(labelName);
}
}
// if there is a cluster attribute it can be handled as an additional label for axis
// selection:
if (mine.getClusterName() != null) {
this.categoryToColumnListMap.get(HeuristicPlotterConfigurator.LABEL).add(mine.getClusterName());
}
} else { // set empty values unless Label and Nominal are already set
if (categoryToColumnListMap.get(HeuristicPlotterConfigurator.LABEL).equals("")) {
this.categoryToColumnListMap.put(HeuristicPlotterConfigurator.LABEL, new ArrayList<String>());
}
if (categoryToColumnListMap.get(HeuristicPlotterConfigurator.NOMINAL).equals("")) {
this.categoryToColumnListMap.put(HeuristicPlotterConfigurator.NOMINAL, new ArrayList<String>());
}
}
}