use of de.lmu.ifi.dbs.elki.result.SettingsResult in project elki by elki-project.
the class SettingsVisualization method makeVisualization.
@Override
public Visualization makeVisualization(VisualizerContext context, VisualizationTask task, VisualizationPlot plot, double width, double height, Projection proj) {
SettingsResult sr = task.getResult();
Collection<TrackedParameter> settings = sr.getSettings();
Element layer = plot.svgElement(SVGConstants.SVG_G_TAG);
// FIXME: use CSSClass and StyleLibrary
int i = 0;
Object last = null;
for (TrackedParameter setting : settings) {
if (setting.getOwner() != last && setting.getOwner() != null) {
String name;
try {
if (setting.getOwner() instanceof Class) {
name = ((Class<?>) setting.getOwner()).getName();
} else {
name = setting.getOwner().getClass().getName();
}
if (ClassParameter.class.isInstance(setting.getOwner())) {
name = ((ClassParameter<?>) setting.getOwner()).getValue().getName();
}
} catch (NullPointerException e) {
name = "[null]";
}
Element object = plot.svgText(0, i + 0.7, name);
object.setAttribute(SVGConstants.SVG_STYLE_ATTRIBUTE, "font-size: 0.6; font-weight: bold");
layer.appendChild(object);
i++;
last = setting.getOwner();
}
// get name and value
String name = setting.getParameter().getOptionID().getName();
String value = "[unset]";
try {
if (setting.getParameter().isDefined()) {
value = setting.getParameter().getValueAsString();
}
} catch (NullPointerException e) {
value = "[null]";
}
Element label = plot.svgText(0, i + 0.7, name);
label.setAttribute(SVGConstants.SVG_STYLE_ATTRIBUTE, "font-size: 0.6");
layer.appendChild(label);
Element vale = plot.svgText(7.5, i + 0.7, value);
vale.setAttribute(SVGConstants.SVG_STYLE_ATTRIBUTE, "font-size: 0.6");
layer.appendChild(vale);
// only advance once, since we want these two to be in the same line.
i++;
}
int cols = Math.max(30, (int) (i * height / width));
int rows = i;
final double margin = context.getStyleLibrary().getSize(StyleLibrary.MARGIN);
final String transform = SVGUtil.makeMarginTransform(width, height, cols, rows, margin / StyleLibrary.SCALE);
SVGUtil.setAtt(layer, SVGConstants.SVG_TRANSFORM_ATTRIBUTE, transform);
return new StaticVisualizationInstance(context, task, plot, width, height, layer);
}
use of de.lmu.ifi.dbs.elki.result.SettingsResult in project elki by elki-project.
the class VisualizerParameterizer method getTitle.
/**
* Try to automatically generate a title for this.
*
* @param db Database
* @param result Result object
* @return generated title
*/
public static String getTitle(Database db, Result result) {
List<TrackedParameter> settings = new ArrayList<>();
for (SettingsResult sr : SettingsResult.getSettingsResults(result)) {
settings.addAll(sr.getSettings());
}
String algorithm = null;
String distance = null;
String dataset = null;
for (TrackedParameter setting : settings) {
Parameter<?> param = setting.getParameter();
OptionID option = param.getOptionID();
String value = param.isDefined() ? param.getValueAsString() : null;
if (option.equals(AlgorithmStep.Parameterizer.ALGORITHM_ID)) {
algorithm = value;
}
if (option.equals(DistanceBasedAlgorithm.DISTANCE_FUNCTION_ID)) {
distance = value;
}
if (option.equals(FileBasedDatabaseConnection.Parameterizer.INPUT_ID)) {
dataset = value;
}
}
StringBuilder buf = new StringBuilder();
if (algorithm != null) {
buf.append(shortenClassname(algorithm.split(",")[0], '.'));
}
if (distance != null) {
if (buf.length() > 0) {
buf.append(" using ");
}
buf.append(shortenClassname(distance, '.'));
}
if (dataset != null) {
if (buf.length() > 0) {
buf.append(" on ");
}
buf.append(shortenClassname(dataset, File.separatorChar));
}
if (buf.length() > 0) {
return buf.toString();
}
return null;
}
use of de.lmu.ifi.dbs.elki.result.SettingsResult in project elki by elki-project.
the class KDDTask method run.
/**
* Method to run the specified algorithm using the specified database
* connection.
*/
public void run() {
// Input step
Database db = inputStep.getDatabase();
hier = db.getHierarchy();
// Algorithms - Data Mining Step
algorithmStep.runAlgorithms(db);
// TODO: this could be nicer
hier.add(db, new SettingsResult(settings));
// Evaluation
evaluationStep.runEvaluators(hier, db);
// Output / Visualization
outputStep.runResultHandlers(hier, db);
}
Aggregations