本文整理汇总了Java中com.rapidminer.datatable.DataTable.getNumberOfValues方法的典型用法代码示例。如果您正苦于以下问题:Java DataTable.getNumberOfValues方法的具体用法?Java DataTable.getNumberOfValues怎么用?Java DataTable.getNumberOfValues使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.rapidminer.datatable.DataTable
的用法示例。
在下文中一共展示了DataTable.getNumberOfValues方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: HeuristicPlotterConfigurator
import com.rapidminer.datatable.DataTable; //导入方法依赖的package包/类
public HeuristicPlotterConfigurator(PlotterConfigurationModel plotterSettings, DataTable dataTable) {
List<String> columnNames = new LinkedList<>(Arrays.asList(dataTable.getColumnNames()));
Iterator<String> iterator = columnNames.iterator();
// iterate over columns and remove all columns from list that have too many values
while (iterator.hasNext()) {
String columnName = iterator.next();
int columnIndex = dataTable.getColumnIndex(columnName);
// nominal columns with more than MAX_NOMINAL_VALUES will be removed
if (columnIndex != -1 && dataTable.isNominal(columnIndex)
&& dataTable.getNumberOfValues(columnIndex) > MAX_NOMINAL_VALUES) {
iterator.remove();
}
}
this.columnNames = columnNames.toArray(new String[columnNames.size()]);
this.settings = plotterSettings;
this.categoryToColumnListMap = new HashMap<>();
populateCategoryMap(dataTable);
}
示例2: drawLegend
import com.rapidminer.datatable.DataTable; //导入方法依赖的package包/类
/** This method can be used to draw a legend on the given graphics context. */
protected void drawLegend(Graphics graphics, DataTable table, int legendColumn, int xOffset, int alpha) {
if (legendColumn < 0 || legendColumn > table.getNumberOfColumns() - 1) {
return;
}
if (table.isNominal(legendColumn)) {
String maxNominalValuesString = ParameterService
.getParameterValue(MainFrame.PROPERTY_RAPIDMINER_GUI_PLOTTER_LEGEND_CLASSLIMIT);
int maxNumberOfNominalValues = 10;
try {
if (maxNominalValuesString != null) {
maxNumberOfNominalValues = Integer.parseInt(maxNominalValuesString);
}
} catch (NumberFormatException e) {
// LogService.getGlobal().logWarning("Plotter: cannot parse maximal number of nominal values for legend ("
// + maxNominalValuesString +
// ")! Using 10...");
LogService.getRoot().log(Level.WARNING,
"com.rapidminer.gui.plotter.PlotterAdapter.parsing_maximal_number_of_nominal_values_error",
maxNominalValuesString);
}
if (maxNumberOfNominalValues == -1 || table.getNumberOfValues(legendColumn) <= maxNumberOfNominalValues) {
drawNominalLegend(graphics, table, legendColumn, xOffset, alpha);
} else {
// LogService.getGlobal().logWarning("Plotter: cannot draw nominal legend since number of different values is too high (more than "
// +
// maxNominalValuesString + ")! Using numerical legend instead.");
LogService.getRoot().log(Level.WARNING,
"com.rapidminer.gui.plotter.PlotterAdapter.drawing_nominal_legend_error", maxNominalValuesString);
drawNumericalLegend(graphics, table, legendColumn, alpha);
}
} else if (table.isDate(legendColumn) || table.isTime(legendColumn) || table.isDateTime(legendColumn)) {
drawDateLegend(graphics, table, legendColumn, alpha);
} else {
drawNumericalLegend(graphics, table, legendColumn, alpha);
}
}
示例3: drawNominalLegend
import com.rapidminer.datatable.DataTable; //导入方法依赖的package包/类
private void drawNominalLegend(Graphics graphics, DataTable table, int legendColumn, int xOffset, int alpha) {
Graphics2D g = (Graphics2D) graphics.create();
g.translate(xOffset, 0);
// painting label name
String legendName = table.getColumnName(legendColumn);
g.drawString(legendName, MARGIN, 15);
Rectangle2D legendNameBounds = LABEL_FONT.getStringBounds(legendName, g.getFontRenderContext());
g.translate(legendNameBounds.getWidth(), 0);
// painting values
int numberOfValues = table.getNumberOfValues(legendColumn);
int currentX = MARGIN;
for (int i = 0; i < numberOfValues; i++) {
if (currentX > getWidth()) {
break;
}
String nominalValue = table.mapIndex(legendColumn, i);
if (nominalValue.length() > 16) {
nominalValue = nominalValue.substring(0, 16) + "...";
}
Shape colorBullet = new Ellipse2D.Double(currentX, 7, 7.0d, 7.0d);
Color color = getColorProvider().getPointColor((double) i / (double) (numberOfValues - 1), alpha);
g.setColor(color);
g.fill(colorBullet);
g.setColor(Color.black);
g.draw(colorBullet);
currentX += 12;
g.drawString(nominalValue, currentX, 15);
Rectangle2D stringBounds = LABEL_FONT.getStringBounds(nominalValue, g.getFontRenderContext());
currentX += stringBounds.getWidth() + 15;
}
}
示例4: getTicSize
import com.rapidminer.datatable.DataTable; //导入方法依赖的package包/类
protected double getTicSize(DataTable dataTable, int column, double min, double max) {
if (column < 0) {
return Double.NaN;
}
if (getNumberOfPlots(dataTable) == 1 && dataTable.isNominal(column)) {
if (dataTable.getNumberOfValues(column) <= 10) {
return 1;
} else {
return getNumericalTicSize(min, max);
}
} else {
return getNumericalTicSize(min, max);
}
}
示例5: getPointColorValue
import com.rapidminer.datatable.DataTable; //导入方法依赖的package包/类
/**
* Helper methods which can be used to deliver a value for the point color. For nominal values
* with two classes, this method tries to search another column with a name xxx(name) and
* changes the color a bit to the opponent color if the values are not the same. This might be
* nice for example in case of a predicted value and a real value.
*/
public double getPointColorValue(DataTable table, DataTableRow row, int column, double min, double max) {
double colorValue = row.getValue(column);
if (max == min && table.isNominal(column)) {
return colorValue / (table.getNumberOfValues(column) - 1);
} else {
double normalized = (colorValue - min) / (max - min);
if (!Double.isNaN(colorValue)) {
if (table.isNominal(column) && table.getNumberOfValues(column) == 2) {
String columnName = table.getColumnName(column);
int startParIndex = columnName.indexOf("(") + 1;
if (startParIndex >= 0) {
int endParIndex = columnName.indexOf(")", startParIndex);
if (endParIndex >= 0) {
String otherColumnName = columnName.substring(startParIndex, endParIndex);
int otherColumnIndex = table.getColumnIndex(otherColumnName);
if (otherColumnIndex >= 0) {
if (table.isNominal(otherColumnIndex)) {
double compareValue = row.getValue(otherColumnIndex);
if (!Double.isNaN(compareValue)) {
int compareIndex = (int) compareValue;
String compareString = table.mapIndex(otherColumnIndex, compareIndex);
compareIndex = table.mapString(column, compareString);
if (colorValue != compareIndex) {
// both values are different --> change color
if (normalized > 0.8) {
normalized = 0.8;
} else if (normalized < 0.2) {
normalized = 0.2;
}
}
}
}
}
}
}
}
}
return normalized;
}
}
示例6: 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>());
}
}
}