Search in sources :

Example 1 with ScoreResult

use of au.gov.asd.tac.constellation.views.analyticview.results.ScoreResult in project constellation by constellation-app.

the class MaxScoreAggregator method aggregate.

@Override
public ScoreResult aggregate(final List<ScoreResult> results) {
    final ScoreResult combinedResults = new ScoreResult();
    final ScoreResult aggregateResult = new ScoreResult();
    if (CollectionUtils.isEmpty(results)) {
        return aggregateResult;
    }
    aggregateResult.setIgnoreNullResults(results.stream().anyMatch(result -> result.isIgnoreNullResults()));
    results.forEach(scoreResult -> combinedResults.combine(scoreResult));
    combinedResults.getResult().forEach((key, value) -> {
        final Map<String, Float> aggregateScores = new HashMap<>();
        aggregateScores.put(SCORE_NAME, value.getNamedScores().values().stream().reduce(Math::max).orElse(0.0F));
        aggregateResult.add(new ElementScore(key.getElementType(), key.getElementId(), key.getIdentifier(), false, aggregateScores));
    });
    return aggregateResult;
}
Also used : List(java.util.List) ElementScore(au.gov.asd.tac.constellation.views.analyticview.results.ScoreResult.ElementScore) Map(java.util.Map) ScoreResult(au.gov.asd.tac.constellation.views.analyticview.results.ScoreResult) ServiceProvider(org.openide.util.lookup.ServiceProvider) HashMap(java.util.HashMap) CollectionUtils(org.apache.commons.collections4.CollectionUtils) AnalyticResult(au.gov.asd.tac.constellation.views.analyticview.results.AnalyticResult) HashMap(java.util.HashMap) ElementScore(au.gov.asd.tac.constellation.views.analyticview.results.ScoreResult.ElementScore) ScoreResult(au.gov.asd.tac.constellation.views.analyticview.results.ScoreResult)

Example 2 with ScoreResult

use of au.gov.asd.tac.constellation.views.analyticview.results.ScoreResult in project constellation by constellation-app.

the class MeanScoreAggregator method aggregate.

@Override
public ScoreResult aggregate(final List<ScoreResult> results) {
    final ScoreResult combinedResults = new ScoreResult();
    final ScoreResult aggregateResult = new ScoreResult();
    if (CollectionUtils.isEmpty(results)) {
        return aggregateResult;
    }
    aggregateResult.setIgnoreNullResults(results.stream().anyMatch(result -> result.isIgnoreNullResults()));
    results.forEach(scoreResult -> combinedResults.combine(scoreResult));
    combinedResults.getResult().forEach((key, value) -> {
        final Map<String, Float> aggregateScores = new HashMap<>();
        aggregateScores.put(SCORE_NAME, value.getNamedScores().values().stream().reduce((x, y) -> x + y).orElse(0.0F) / value.getNamedScores().size());
        aggregateResult.add(new ElementScore(key.getElementType(), key.getElementId(), key.getIdentifier(), false, aggregateScores));
    });
    return aggregateResult;
}
Also used : List(java.util.List) ElementScore(au.gov.asd.tac.constellation.views.analyticview.results.ScoreResult.ElementScore) Map(java.util.Map) ScoreResult(au.gov.asd.tac.constellation.views.analyticview.results.ScoreResult) ServiceProvider(org.openide.util.lookup.ServiceProvider) HashMap(java.util.HashMap) CollectionUtils(org.apache.commons.collections4.CollectionUtils) AnalyticResult(au.gov.asd.tac.constellation.views.analyticview.results.AnalyticResult) HashMap(java.util.HashMap) ElementScore(au.gov.asd.tac.constellation.views.analyticview.results.ScoreResult.ElementScore) ScoreResult(au.gov.asd.tac.constellation.views.analyticview.results.ScoreResult)

Example 3 with ScoreResult

use of au.gov.asd.tac.constellation.views.analyticview.results.ScoreResult in project constellation by constellation-app.

the class ScoreAnalyticPlugin method computeResultsFromGraph.

protected final void computeResultsFromGraph(final GraphReadMethods graph, final PluginParameters parameters) {
    result = new ScoreResult();
    result.setIgnoreNullResults(ignoreDefaultValues());
    int graphElementCount = 0;
    int identifierAttributeId = Graph.NOT_FOUND;
    final Set<GraphElementType> graphElementTypes = getAnalyticAttributes(parameters).stream().map(attribute -> attribute.getElementType()).collect(Collectors.toSet());
    for (final GraphElementType graphElementType : graphElementTypes) {
        switch(graphElementType) {
            case VERTEX:
                graphElementCount = graph.getVertexCount();
                identifierAttributeId = VisualConcept.VertexAttribute.IDENTIFIER.get(graph);
                break;
            case TRANSACTION:
                graphElementCount = graph.getTransactionCount();
                identifierAttributeId = VisualConcept.TransactionAttribute.IDENTIFIER.get(graph);
                break;
            default:
                break;
        }
        for (int graphElementPosition = 0; graphElementPosition < graphElementCount; graphElementPosition++) {
            final int graphElementId;
            if (graphElementType == GraphElementType.VERTEX) {
                graphElementId = graph.getVertex(graphElementPosition);
            } else {
                graphElementId = graphElementType == GraphElementType.TRANSACTION ? graph.getTransaction(graphElementPosition) : Graph.NOT_FOUND;
            }
            final String identifier = graph.getStringValue(identifierAttributeId, graphElementId);
            final Map<String, Float> namedScores = new HashMap<>();
            boolean isNull = true;
            for (final SchemaAttribute analyticAttribute : getAnalyticAttributes(parameters)) {
                final int scoreAttributeId = analyticAttribute.get(graph);
                if (scoreAttributeId == Graph.NOT_FOUND) {
                    throw new RuntimeException("Expected attribute not found on graph: " + analyticAttribute.getName());
                }
                final float score = graph.getFloatValue(scoreAttributeId, graphElementId);
                final float defaultScore = (float) graph.getAttributeDefaultValue(scoreAttributeId);
                if (isNull) {
                    isNull = ignoreDefaultValues() && score == defaultScore;
                }
                namedScores.put(analyticAttribute.getName(), score);
            }
            result.add(new ElementScore(graphElementType, graphElementId, identifier, isNull, namedScores));
        }
    }
}
Also used : GraphWriteMethods(au.gov.asd.tac.constellation.graph.GraphWriteMethods) SchemaTransactionType(au.gov.asd.tac.constellation.graph.schema.type.SchemaTransactionType) TRANSACTION(au.gov.asd.tac.constellation.graph.GraphElementType.TRANSACTION) ReadableGraph(au.gov.asd.tac.constellation.graph.ReadableGraph) ElementScore(au.gov.asd.tac.constellation.views.analyticview.results.ScoreResult.ElementScore) RecordStore(au.gov.asd.tac.constellation.graph.processing.RecordStore) SchemaTransactionTypeUtilities(au.gov.asd.tac.constellation.graph.schema.type.SchemaTransactionTypeUtilities) MultiChoiceParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.MultiChoiceParameterType.MultiChoiceParameterValue) ScoreResult(au.gov.asd.tac.constellation.views.analyticview.results.ScoreResult) HashMap(java.util.HashMap) SchemaFactory(au.gov.asd.tac.constellation.graph.schema.SchemaFactory) VisualConcept(au.gov.asd.tac.constellation.graph.schema.visual.concept.VisualConcept) ArrayList(java.util.ArrayList) Level(java.util.logging.Level) Graph(au.gov.asd.tac.constellation.graph.Graph) HashSet(java.util.HashSet) SchemaFactoryUtilities(au.gov.asd.tac.constellation.graph.schema.SchemaFactoryUtilities) VERTEX(au.gov.asd.tac.constellation.graph.GraphElementType.VERTEX) Plugin(au.gov.asd.tac.constellation.plugins.Plugin) PluginInteraction(au.gov.asd.tac.constellation.plugins.PluginInteraction) PluginParameter(au.gov.asd.tac.constellation.plugins.parameters.PluginParameter) Map(java.util.Map) SubgraphUtilities(au.gov.asd.tac.constellation.graph.utilities.SubgraphUtilities) GraphReadMethods(au.gov.asd.tac.constellation.graph.GraphReadMethods) PluginExecution(au.gov.asd.tac.constellation.plugins.PluginExecution) PluginRegistry(au.gov.asd.tac.constellation.plugins.PluginRegistry) SchemaAttribute(au.gov.asd.tac.constellation.graph.schema.attribute.SchemaAttribute) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters) MultiChoiceParameterType(au.gov.asd.tac.constellation.plugins.parameters.types.MultiChoiceParameterType) GraphElementType(au.gov.asd.tac.constellation.graph.GraphElementType) Set(java.util.Set) ParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.ParameterValue) StoreGraph(au.gov.asd.tac.constellation.graph.StoreGraph) GraphRecordStoreUtilities(au.gov.asd.tac.constellation.graph.processing.GraphRecordStoreUtilities) Logger(java.util.logging.Logger) PluginException(au.gov.asd.tac.constellation.plugins.PluginException) Collectors(java.util.stream.Collectors) AnalyticResult(au.gov.asd.tac.constellation.views.analyticview.results.AnalyticResult) InvocationTargetException(java.lang.reflect.InvocationTargetException) Objects(java.util.Objects) List(java.util.List) AnalyticConcept(au.gov.asd.tac.constellation.graph.schema.analytic.concept.AnalyticConcept) HashMap(java.util.HashMap) ElementScore(au.gov.asd.tac.constellation.views.analyticview.results.ScoreResult.ElementScore) ScoreResult(au.gov.asd.tac.constellation.views.analyticview.results.ScoreResult) GraphElementType(au.gov.asd.tac.constellation.graph.GraphElementType) SchemaAttribute(au.gov.asd.tac.constellation.graph.schema.attribute.SchemaAttribute)

Example 4 with ScoreResult

use of au.gov.asd.tac.constellation.views.analyticview.results.ScoreResult in project constellation by constellation-app.

the class AppendScoreAggregator method aggregate.

@Override
public ScoreResult aggregate(final List<ScoreResult> results) throws AnalyticException {
    final ScoreResult aggregateResult = new ScoreResult();
    if (CollectionUtils.isEmpty(results)) {
        return aggregateResult;
    }
    aggregateResult.setIgnoreNullResults(results.stream().anyMatch(result -> result.isIgnoreNullResults()));
    results.forEach(scoreResult -> aggregateResult.combine(scoreResult));
    return aggregateResult;
}
Also used : List(java.util.List) AnalyticException(au.gov.asd.tac.constellation.views.analyticview.utilities.AnalyticException) ScoreResult(au.gov.asd.tac.constellation.views.analyticview.results.ScoreResult) ServiceProvider(org.openide.util.lookup.ServiceProvider) CollectionUtils(org.apache.commons.collections4.CollectionUtils) AnalyticResult(au.gov.asd.tac.constellation.views.analyticview.results.AnalyticResult) ScoreResult(au.gov.asd.tac.constellation.views.analyticview.results.ScoreResult)

Example 5 with ScoreResult

use of au.gov.asd.tac.constellation.views.analyticview.results.ScoreResult in project constellation by constellation-app.

the class MinScoreAggregator method aggregate.

@Override
public ScoreResult aggregate(final List<ScoreResult> results) {
    final ScoreResult combinedResults = new ScoreResult();
    final ScoreResult aggregateResult = new ScoreResult();
    if (CollectionUtils.isEmpty(results)) {
        return aggregateResult;
    }
    aggregateResult.setIgnoreNullResults(results.stream().anyMatch(result -> result.isIgnoreNullResults()));
    results.forEach(scoreResult -> combinedResults.combine(scoreResult));
    combinedResults.getResult().forEach((key, value) -> {
        final Map<String, Float> aggregateScores = new HashMap<>();
        aggregateScores.put(SCORE_NAME, value.getNamedScores().values().stream().reduce(Math::min).orElse(0.0F));
        aggregateResult.add(new ElementScore(key.getElementType(), key.getElementId(), key.getIdentifier(), false, aggregateScores));
    });
    return aggregateResult;
}
Also used : List(java.util.List) ElementScore(au.gov.asd.tac.constellation.views.analyticview.results.ScoreResult.ElementScore) Map(java.util.Map) ScoreResult(au.gov.asd.tac.constellation.views.analyticview.results.ScoreResult) ServiceProvider(org.openide.util.lookup.ServiceProvider) HashMap(java.util.HashMap) CollectionUtils(org.apache.commons.collections4.CollectionUtils) AnalyticResult(au.gov.asd.tac.constellation.views.analyticview.results.AnalyticResult) HashMap(java.util.HashMap) ElementScore(au.gov.asd.tac.constellation.views.analyticview.results.ScoreResult.ElementScore) ScoreResult(au.gov.asd.tac.constellation.views.analyticview.results.ScoreResult)

Aggregations

AnalyticResult (au.gov.asd.tac.constellation.views.analyticview.results.AnalyticResult)6 ScoreResult (au.gov.asd.tac.constellation.views.analyticview.results.ScoreResult)6 List (java.util.List)6 ElementScore (au.gov.asd.tac.constellation.views.analyticview.results.ScoreResult.ElementScore)5 HashMap (java.util.HashMap)5 Map (java.util.Map)5 CollectionUtils (org.apache.commons.collections4.CollectionUtils)5 ServiceProvider (org.openide.util.lookup.ServiceProvider)5 Graph (au.gov.asd.tac.constellation.graph.Graph)1 GraphElementType (au.gov.asd.tac.constellation.graph.GraphElementType)1 TRANSACTION (au.gov.asd.tac.constellation.graph.GraphElementType.TRANSACTION)1 VERTEX (au.gov.asd.tac.constellation.graph.GraphElementType.VERTEX)1 GraphReadMethods (au.gov.asd.tac.constellation.graph.GraphReadMethods)1 GraphWriteMethods (au.gov.asd.tac.constellation.graph.GraphWriteMethods)1 ReadableGraph (au.gov.asd.tac.constellation.graph.ReadableGraph)1 StoreGraph (au.gov.asd.tac.constellation.graph.StoreGraph)1 GraphRecordStoreUtilities (au.gov.asd.tac.constellation.graph.processing.GraphRecordStoreUtilities)1 RecordStore (au.gov.asd.tac.constellation.graph.processing.RecordStore)1 SchemaFactory (au.gov.asd.tac.constellation.graph.schema.SchemaFactory)1 SchemaFactoryUtilities (au.gov.asd.tac.constellation.graph.schema.SchemaFactoryUtilities)1