use of org.knime.base.node.viz.plotter.DataProvider in project knime-core by knime.
the class LinReg2LinePlotter method updateSize.
/**
* First calls super then adapts the regression line.
*/
@Override
public void updateSize() {
if (getXAxis() == null || getXAxis().getCoordinate() == null || getYAxis() == null || getYAxis().getCoordinate() == null) {
return;
}
super.updateSize();
DataProvider dataProvider = getDataProvider();
if (dataProvider == null) {
return;
}
RegressionContent content = ((LinReg2DataProvider) dataProvider).getLinRegContent();
if (content == null) {
return;
}
double xMin = ((NumericCoordinate) getXAxis().getCoordinate()).getMinDomainValue();
double xMax = ((NumericCoordinate) getXAxis().getCoordinate()).getMaxDomainValue();
String xName = getSelectedXColumn().getName();
List<String> includedList = content.getCovariates();
String target = content.getSpec().getTargetCols().get(0).getName();
if (!xName.equals(target) && includedList.contains(xName)) {
double yMin = getApproximationFor(xName, xMin, content);
double yMax = getApproximationFor(xName, xMax, content);
((LinReg2LineDrawingPane) getDrawingPane()).setLineFirstPoint(getMappedXValue(new DoubleCell(xMin)), getMappedYValue(new DoubleCell(yMin)));
((LinReg2LineDrawingPane) getDrawingPane()).setLineLastPoint(getMappedXValue(new DoubleCell(xMax)), getMappedYValue(new DoubleCell(yMax)));
}
}
use of org.knime.base.node.viz.plotter.DataProvider in project knime-core by knime.
the class LinRegLinePlotter method updateSize.
/**
* First calls super then adapts the regression line.
*/
@Override
public void updateSize() {
if (getXAxis() == null || getXAxis().getCoordinate() == null || getYAxis() == null || getYAxis().getCoordinate() == null) {
return;
}
super.updateSize();
DataProvider dataProvider = getDataProvider();
if (dataProvider == null) {
return;
}
DataArray data = dataProvider.getDataArray(0);
if (data == null) {
return;
}
LinearRegressionContent params = ((LinRegDataProvider) dataProvider).getParams();
if (params == null) {
return;
}
double xMin = ((NumericCoordinate) getXAxis().getCoordinate()).getMinDomainValue();
double xMax = ((NumericCoordinate) getXAxis().getCoordinate()).getMaxDomainValue();
String xName = getSelectedXColumn().getName();
String[] temp = ((LinRegDataProvider) dataProvider).getLearningColumns();
if (temp == null) {
return;
}
List<String> includedCols = Arrays.asList(temp);
if (!xName.equals(params.getTargetColumnName()) && includedCols.contains(xName)) {
double yMin = params.getApproximationFor(xName, xMin);
double yMax = params.getApproximationFor(xName, xMax);
((LinRegLineDrawingPane) getDrawingPane()).setLineFirstPoint(getMappedXValue(new DoubleCell(xMin)), getMappedYValue(new DoubleCell(yMin)));
((LinRegLineDrawingPane) getDrawingPane()).setLineLastPoint(getMappedXValue(new DoubleCell(xMax)), getMappedYValue(new DoubleCell(yMax)));
}
}
use of org.knime.base.node.viz.plotter.DataProvider in project knime-core by knime.
the class LinRegLinePlotter method updatePaintModel.
/**
* Retrieves the linear regression params, updates the column selection
* boxes appropriately and adds the regression line to the scatterplot.
*/
@Override
public void updatePaintModel() {
DataProvider dataProvider = getDataProvider();
if (dataProvider == null) {
return;
}
DataArray data = dataProvider.getDataArray(0);
if (data == null) {
return;
}
LinearRegressionContent params = ((LinRegDataProvider) dataProvider).getParams();
if (params == null) {
return;
}
// set the target column to fix
((LinRegLinePlotterProperties) getProperties()).setTargetColumn(params.getTargetColumnName());
// get the included columns
String[] includedCols = ((LinRegDataProvider) dataProvider).getLearningColumns();
if (includedCols == null) {
return;
}
((LinRegLinePlotterProperties) getProperties()).setIncludedColumns(includedCols);
// update the combo boxes
DataTableSpec spec = data.getDataTableSpec();
((LinRegLinePlotterProperties) getProperties()).update(spec);
super.updatePaintModel();
double xMin = ((NumericCoordinate) getXAxis().getCoordinate()).getMinDomainValue();
double xMax = ((NumericCoordinate) getXAxis().getCoordinate()).getMaxDomainValue();
String xName = getSelectedXColumn().getName();
List<String> includedList = Arrays.asList(includedCols);
if (!xName.equals(params.getTargetColumnName()) && includedList.contains(xName)) {
double yMin = params.getApproximationFor(xName, xMin);
double yMax = params.getApproximationFor(xName, xMax);
((LinRegLineDrawingPane) getDrawingPane()).setLineFirstPoint(getMappedXValue(new DoubleCell(xMin)), getMappedYValue(new DoubleCell(yMin)));
((LinRegLineDrawingPane) getDrawingPane()).setLineLastPoint(getMappedXValue(new DoubleCell(xMax)), getMappedYValue(new DoubleCell(yMax)));
getDrawingPane().repaint();
}
}
Aggregations