use of org.knime.core.data.DataColumnDomain in project knime-core by knime.
the class NominalTargetColumnHelper method createMetaData.
/**
* {@inheritDoc}
*/
@Override
protected TreeTargetNominalColumnMetaData createMetaData(final DataColumnSpec nominalColSpec) {
DataColumnDomain domain = nominalColSpec.getDomain();
CheckUtils.checkArgument(domain.hasValues(), "The target field \"%s\" in the data dictionary has no possible values assigned.", nominalColSpec);
NominalValueRepresentation[] nomVals = NominalColumnHelperUtil.extractNomValReps(domain.getValues());
return new TreeTargetNominalColumnMetaData(nominalColSpec.getName(), nomVals);
}
use of org.knime.core.data.DataColumnDomain in project knime-core by knime.
the class LogRegLearnerNodeDialogPane method updateTargetCategories.
/**
* Update list of target categories.
*/
private void updateTargetCategories(final DataCell selectedItem) {
m_targetReferenceCategory.removeAllItems();
String selectedColumn = m_selectionPanel.getSelectedColumn();
if (selectedColumn != null) {
DataColumnSpec colSpec = m_inSpec.getColumnSpec(selectedColumn);
if (null != colSpec) {
// select last as default
DataCell newSelectedItem = null;
DataCell lastItem = null;
final DataColumnDomain domain = colSpec.getDomain();
if (domain.hasValues()) {
for (DataCell cell : domain.getValues()) {
m_targetReferenceCategory.addItem(cell);
lastItem = cell;
if (cell.equals(selectedItem)) {
newSelectedItem = selectedItem;
}
}
if (newSelectedItem == null) {
newSelectedItem = lastItem;
}
m_targetReferenceCategory.getModel().setSelectedItem(newSelectedItem);
}
}
}
m_targetReferenceCategory.setEnabled(m_targetReferenceCategory.getModel().getSize() > 0);
}
use of org.knime.core.data.DataColumnDomain in project knime-core by knime.
the class LogRegLearnerNodeDialogPane method updateTargetCategories.
/**
* Update list of target categories.
*/
private void updateTargetCategories(final DataCell selectedItem) {
m_targetReferenceCategory.removeAllItems();
String selectedColumn = m_selectionPanel.getSelectedColumn();
if (selectedColumn != null) {
DataColumnSpec colSpec = m_inSpec.getColumnSpec(selectedColumn);
if (null != colSpec) {
// select last as default
DataCell newSelectedItem = null;
DataCell lastItem = null;
final DataColumnDomain domain = colSpec.getDomain();
if (domain.hasValues()) {
for (DataCell cell : domain.getValues()) {
m_targetReferenceCategory.addItem(cell);
lastItem = cell;
if (cell.equals(selectedItem)) {
newSelectedItem = selectedItem;
}
}
if (newSelectedItem == null) {
newSelectedItem = lastItem;
}
m_targetReferenceCategory.getModel().setSelectedItem(newSelectedItem);
}
}
}
m_targetReferenceCategory.setEnabled(m_targetReferenceCategory.getModel().getSize() > 0);
}
use of org.knime.core.data.DataColumnDomain in project knime-core by knime.
the class LogRegLearner method checkConstantLearningFields.
private void checkConstantLearningFields(final BufferedDataTable data) throws InvalidSettingsException {
Set<String> exclude = new HashSet<String>();
for (DataColumnSpec colSpec : m_pmmlOutSpec.getLearningCols()) {
if (colSpec.getType().isCompatible(DoubleValue.class)) {
final DataColumnDomain domain = colSpec.getDomain();
final DataCell lowerBound = domain.getLowerBound();
final DataCell upperBound = domain.getUpperBound();
assert lowerBound != null || data.size() == 0 : "Non empty table must have domain set at this point";
if (ObjectUtils.equals(lowerBound, upperBound)) {
exclude.add(colSpec.getName());
}
}
}
// Maybe in recalcDomainForTargetAndLearningFields.
if (!exclude.isEmpty()) {
StringBuilder warning = new StringBuilder();
warning.append(exclude.size() == 1 ? "Column " : "Columns ");
warning.append(ConvenienceMethods.getShortStringFrom(exclude, 5));
warning.append(exclude.size() == 1 ? " has a constant value " : " have constant values ");
warning.append(" - will be ignored during training");
LOGGER.warn(warning.toString());
m_warningMessage = (m_warningMessage == null ? "" : m_warningMessage + "\n") + warning.toString();
// re-init learner so that it has the correct learning columns
init(data.getDataTableSpec(), exclude);
}
}
use of org.knime.core.data.DataColumnDomain in project knime-core by knime.
the class DoubleGrayValueRenderer method setValue.
/**
* /** Sets the gray value according to the value and the column
* domain's min/max. If the object is not instance of DoubleValue, the
* cell is painted red.
* @param value The value to be rendered.
* @see javax.swing.table.DefaultTableCellRenderer#setValue(Object)
*/
@Override
protected void setValue(final Object value) {
Color c;
if (value instanceof DoubleValue) {
DoubleValue cell = (DoubleValue) value;
double val = cell.getDoubleValue();
DataColumnSpec spec = getColSpec();
double min = Double.POSITIVE_INFINITY;
double max = Double.NEGATIVE_INFINITY;
if (spec != null) {
DataColumnDomain domain = spec.getDomain();
DataCell lower = domain.getLowerBound();
DataCell upper = domain.getUpperBound();
if (lower instanceof DoubleValue) {
min = ((DoubleValue) lower).getDoubleValue();
}
if (upper instanceof DoubleValue) {
max = ((DoubleValue) upper).getDoubleValue();
}
}
if (min >= max) {
min = 0.0;
max = 1.0;
}
setToolTipText(Double.toString(val));
c = setDoubleValue(val, min, max);
setIconColor(c);
setTextInternal(null);
} else if (isPaintCrossForMissing()) {
setToolTipText("Missing Value");
setIconColor(null);
setTextInternal(null);
} else {
setToolTipText("Missing Value");
setIcon(null);
setTextInternal(DataType.getMissingCell().toString());
}
}
Aggregations