Search in sources :

Example 1 with ScalesResult

use of de.lmu.ifi.dbs.elki.result.ScalesResult in project elki by elki-project.

the class OpenGL3DParallelCoordinates method processNewResult.

@Override
public void processNewResult(ResultHierarchy hier, Result newResult) {
    boolean nonefound = true;
    List<Relation<?>> rels = ResultUtil.getRelations(newResult);
    for (Relation<?> rel : rels) {
        if (!TypeUtil.NUMBER_VECTOR_FIELD.isAssignableFromType(rel.getDataTypeInformation())) {
            continue;
        }
        @SuppressWarnings("unchecked") Relation<? extends O> vrel = (Relation<? extends O>) rel;
        ScalesResult scales = ScalesResult.getScalesResult(vrel);
        ProjectionParallel proj = new SimpleParallel(null, scales.getScales());
        PropertiesBasedStyleLibrary stylelib = new PropertiesBasedStyleLibrary();
        StylingPolicy stylepol = getStylePolicy(hier, stylelib);
        new Instance<>(vrel, proj, settings, stylepol, stylelib).run();
        nonefound = false;
    }
    if (nonefound && hier.equals(newResult)) {
        LOG.warning("3DPC did not find a number vector field relation to visualize!");
    }
}
Also used : SimpleParallel(de.lmu.ifi.dbs.elki.visualization.projections.SimpleParallel) PropertiesBasedStyleLibrary(de.lmu.ifi.dbs.elki.visualization.style.PropertiesBasedStyleLibrary) ProjectionParallel(de.lmu.ifi.dbs.elki.visualization.projections.ProjectionParallel) Relation(de.lmu.ifi.dbs.elki.database.relation.Relation) ScalesResult(de.lmu.ifi.dbs.elki.result.ScalesResult) StylingPolicy(de.lmu.ifi.dbs.elki.visualization.style.StylingPolicy) ClusterStylingPolicy(de.lmu.ifi.dbs.elki.visualization.style.ClusterStylingPolicy)

Example 2 with ScalesResult

use of de.lmu.ifi.dbs.elki.result.ScalesResult in project elki by elki-project.

the class AddSingleScale method run.

/**
 * Add scales to a single vector relation.
 *
 * @param rel Relation
 * @return Scales
 */
private ScalesResult run(Relation<? extends NumberVector> rel) {
    final int dim = RelationUtil.dimensionality(rel);
    LinearScale[] scales = new LinearScale[dim];
    if (minmax == null) {
        DoubleMinMax mm = new DoubleMinMax();
        for (DBIDIter iditer = rel.iterDBIDs(); iditer.valid(); iditer.advance()) {
            NumberVector vec = rel.get(iditer);
            for (int d = 0; d < dim; d++) {
                final double val = vec.doubleValue(d);
                if (val != val) {
                    // NaN
                    continue;
                }
                mm.put(val);
            }
        }
        LinearScale scale = new LinearScale(mm.getMin(), mm.getMax());
        for (int i = 0; i < dim; i++) {
            scales[i] = scale;
        }
    } else {
        // Use predefined.
        LinearScale scale = new LinearScale(minmax[0], minmax[1]);
        for (int i = 0; i < dim; i++) {
            scales[i] = scale;
        }
    }
    ScalesResult res = new ScalesResult(scales);
    return res;
}
Also used : LinearScale(de.lmu.ifi.dbs.elki.math.scales.LinearScale) DoubleMinMax(de.lmu.ifi.dbs.elki.math.DoubleMinMax) ScalesResult(de.lmu.ifi.dbs.elki.result.ScalesResult) NumberVector(de.lmu.ifi.dbs.elki.data.NumberVector) ListSizeConstraint(de.lmu.ifi.dbs.elki.utilities.optionhandling.constraints.ListSizeConstraint) DBIDIter(de.lmu.ifi.dbs.elki.database.ids.DBIDIter)

Example 3 with ScalesResult

use of de.lmu.ifi.dbs.elki.result.ScalesResult in project elki by elki-project.

the class AddUniformScale method run.

/**
 * Add scales to a single vector relation.
 *
 * @param rel Relation
 * @return Scales
 */
private ScalesResult run(Relation<? extends NumberVector> rel) {
    double[][] mms = RelationUtil.computeMinMax(rel);
    int dim = mms[0].length;
    double delta = 0.;
    for (int d = 0; d < dim; d++) {
        double del = mms[1][d] - mms[0][d];
        delta = del > delta ? del : delta;
    }
    if (delta < Double.MIN_NORMAL) {
        delta = 1.;
    }
    int log10res = (int) Math.ceil(Math.log10(delta / (LinearScale.MAXTICKS - 1)));
    double res = MathUtil.powi(10, log10res);
    // Target width
    double target = Math.ceil(delta / res) * res;
    LinearScale[] scales = new LinearScale[dim];
    for (int d = 0; d < dim; d++) {
        double mid = (mms[0][d] + mms[1][d] - target) * .5;
        double min = Math.floor(mid / res) * res;
        double max = Math.ceil((mid + target) / res) * res;
        scales[d] = new LinearScale(min, max);
    }
    return new ScalesResult(scales);
}
Also used : LinearScale(de.lmu.ifi.dbs.elki.math.scales.LinearScale) ScalesResult(de.lmu.ifi.dbs.elki.result.ScalesResult)

Example 4 with ScalesResult

use of de.lmu.ifi.dbs.elki.result.ScalesResult in project elki by elki-project.

the class AddUniformScale method run.

@SuppressWarnings("unchecked")
@Override
public Result run(Database database) {
    for (Relation<?> rel : database.getRelations()) {
        if (TypeUtil.NUMBER_VECTOR_FIELD.isAssignableFromType(rel.getDataTypeInformation())) {
            ScalesResult res = run((Relation<? extends NumberVector>) rel);
            ResultUtil.addChildResult(rel, res);
        }
    }
    return null;
}
Also used : ScalesResult(de.lmu.ifi.dbs.elki.result.ScalesResult)

Example 5 with ScalesResult

use of de.lmu.ifi.dbs.elki.result.ScalesResult in project elki by elki-project.

the class AddSingleScale method run.

@SuppressWarnings("unchecked")
@Override
public Result run(Database database) {
    for (Relation<?> rel : database.getRelations()) {
        if (TypeUtil.NUMBER_VECTOR_FIELD.isAssignableFromType(rel.getDataTypeInformation())) {
            ScalesResult res = run((Relation<? extends NumberVector>) rel);
            ResultUtil.addChildResult(rel, res);
        }
    }
    return null;
}
Also used : ScalesResult(de.lmu.ifi.dbs.elki.result.ScalesResult)

Aggregations

ScalesResult (de.lmu.ifi.dbs.elki.result.ScalesResult)8 VisualizationTask (de.lmu.ifi.dbs.elki.visualization.VisualizationTask)3 PlotItem (de.lmu.ifi.dbs.elki.visualization.gui.overview.PlotItem)3 ArrayList (java.util.ArrayList)3 LinearScale (de.lmu.ifi.dbs.elki.math.scales.LinearScale)2 ProjectionParallel (de.lmu.ifi.dbs.elki.visualization.projections.ProjectionParallel)2 SimpleParallel (de.lmu.ifi.dbs.elki.visualization.projections.SimpleParallel)2 LabelVisualization (de.lmu.ifi.dbs.elki.visualization.visualizers.visunproj.LabelVisualization)2 NumberVector (de.lmu.ifi.dbs.elki.data.NumberVector)1 DBIDIter (de.lmu.ifi.dbs.elki.database.ids.DBIDIter)1 Relation (de.lmu.ifi.dbs.elki.database.relation.Relation)1 DoubleMinMax (de.lmu.ifi.dbs.elki.math.DoubleMinMax)1 AffineTransformation (de.lmu.ifi.dbs.elki.math.linearalgebra.AffineTransformation)1 ListSizeConstraint (de.lmu.ifi.dbs.elki.utilities.optionhandling.constraints.ListSizeConstraint)1 AffineProjection (de.lmu.ifi.dbs.elki.visualization.projections.AffineProjection)1 Projection1D (de.lmu.ifi.dbs.elki.visualization.projections.Projection1D)1 Projection2D (de.lmu.ifi.dbs.elki.visualization.projections.Projection2D)1 Simple1D (de.lmu.ifi.dbs.elki.visualization.projections.Simple1D)1 Simple2D (de.lmu.ifi.dbs.elki.visualization.projections.Simple2D)1 ClusterStylingPolicy (de.lmu.ifi.dbs.elki.visualization.style.ClusterStylingPolicy)1