org.android.activityminer.logic.evaluation
Class EvaluationHelper

Package class diagram package EvaluationHelper
java.lang.Object
  extended by de.unikassel.android.sdcframework.util.ObservableEventSourceImpl<ObservableProgressData>
      extended by org.android.activityminer.logic.evaluation.EvaluationHelper
All Implemented Interfaces:
ObservableEventSource<ObservableProgressData>, ObserverRegistration<ObservableProgressData>

public class EvaluationHelper
extends ObservableEventSourceImpl<ObservableProgressData>

A class to delegate evaluation processing to.


Field Summary
private  boolean bestResultsOnly
          The flag if only the best results shall be returned.
private  Configuration config
          The current configuration.
private  Context context
          The context.
private  DBManager dbManager
          A reference to the database manager.
private  EvaluationResultCollection evaluationResults
          The evaluation results.
private  List<Set<FeatureTypes>> featureSetsToTest
          The feature sets to test.
private  String lastError
          The last error
private  android.support.v4.util.LongSparseArray<List<Long>> mapSelectedClassId2SampleIds
          A map to store sample (feature vector) identifiers for the selected lass identifiers
private  double maxPredictionTime
          The maximum prediction time for a sample.
private  double minPredictionTime
          The minimum prediction time for a sample.
private  int progress
          The current progress.
private  ObservableProgressData progressData
          The observable progress data
private  int sampleCount
          The total sample count.
private  boolean succeeded
          The success state flag
private  double sumOfAvgPredictionTime
          The sum of average prediction time for a sample.
private  double sumOfAvgTrainingTime
          The sum of average training time for a sample.
private  double threshold
          The accuracy threshold in percent (0%-100%).
private  List<TrainingActivity> trainingActivites
          The training activities for evaluation.
private  ValidationStrategy validationStrategy
          The validation strategy.
 
Constructor Summary
EvaluationHelper(DBManager dbManager, Set<Set<FeatureTypes>> featureSetsToTest, Configuration config, boolean bestResultsOnly, Context context)
          Constructor
 
Method Summary
 long doEvaluate()
          Does run the evaluation for all feature sets
 void evaluate(Set<FeatureTypes> selectedFeatures, Classifier classifier)
          Evaluation for a single feature set.
 EvaluationResultCollection getEvaluationResults()
          Getter for the evaluation results
 String getLastError()
          Getter for the last error
 int getMaxProgress()
          Getter for the maximum progress
private static List<Set<FeatureTypes>> getSetsSortedBySize(Set<Set<FeatureTypes>> featureSets)
          Does sort the feature sets for evaluation by size.
 String getStartProgressMessage()
          Getter for the start progress message
 double getThreshold()
          Getter for the accuracy threshold
 boolean hasSucceeded()
          Getter for the success flag
 boolean isBestResultsOnly()
          Getter for the flag for selection of best results
 void loadSamplesAndCreatePartioning()
          Does load available samples as feature vectors from DB and creates the partitioning for k-fold cross validation.
 boolean saveResultsToFile(String fileName)
          Method to store evaluation result to file.
 void updateProgress(String msg)
          Does publish the current progress with the given message.
 
Methods inherited from class de.unikassel.android.sdcframework.util.ObservableEventSourceImpl
getObservers, hasObservers, notify, onObserverRegistration, onObserverUnregistration, registerEventObserver, removeAllObservers, unregisterEventObserver
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dbManager

private final DBManager dbManager
A reference to the database manager.


config

private Configuration config
The current configuration.


featureSetsToTest

private final List<Set<FeatureTypes>> featureSetsToTest
The feature sets to test.


sampleCount

private int sampleCount
The total sample count.


validationStrategy

private final ValidationStrategy validationStrategy
The validation strategy.


trainingActivites

private List<TrainingActivity> trainingActivites
The training activities for evaluation.


evaluationResults

private final EvaluationResultCollection evaluationResults
The evaluation results.


sumOfAvgTrainingTime

private double sumOfAvgTrainingTime
The sum of average training time for a sample.


sumOfAvgPredictionTime

private double sumOfAvgPredictionTime
The sum of average prediction time for a sample.


minPredictionTime

private double minPredictionTime
The minimum prediction time for a sample.


maxPredictionTime

private double maxPredictionTime
The maximum prediction time for a sample.


progressData

private final ObservableProgressData progressData
The observable progress data


progress

private int progress
The current progress.


succeeded

private boolean succeeded
The success state flag


lastError

private String lastError
The last error


mapSelectedClassId2SampleIds

private final android.support.v4.util.LongSparseArray<List<Long>> mapSelectedClassId2SampleIds
A map to store sample (feature vector) identifiers for the selected lass identifiers


context

private Context context
The context.


bestResultsOnly

private final boolean bestResultsOnly
The flag if only the best results shall be returned.


threshold

private double threshold
The accuracy threshold in percent (0%-100%). If bestResultsOnly is false, this parameter limits the results by a minimal expected overall accuracy value

Constructor Detail

EvaluationHelper

public EvaluationHelper(DBManager dbManager,
                        Set<Set<FeatureTypes>> featureSetsToTest,
                        Configuration config,
                        boolean bestResultsOnly,
                        Context context)
Constructor

Parameters:
dbManager - a reference to the database manager
featureSetsToTest - the set with the feature sets to test
config - the current configuration
bestResultsOnly - flag to limit the result list to the best results (ranked by overall prediction accuracy)
context - the context
Method Detail

getThreshold

public double getThreshold()
Getter for the accuracy threshold

Returns:
the accuracy threshold

isBestResultsOnly

public boolean isBestResultsOnly()
Getter for the flag for selection of best results

Returns:
true if only the best results have been selected, false otherwise

hasSucceeded

public final boolean hasSucceeded()
Getter for the success flag

Returns:
the success flag

getLastError

public final String getLastError()
Getter for the last error

Returns:
the last error

getSetsSortedBySize

private static final List<Set<FeatureTypes>> getSetsSortedBySize(Set<Set<FeatureTypes>> featureSets)
Does sort the feature sets for evaluation by size.

Parameters:
featureSets - the set with the feature sets
Returns:
a list with the feature sets sorted by size in ascending order

getMaxProgress

public final int getMaxProgress()
Getter for the maximum progress

Returns:
the maximum progress steps

getEvaluationResults

public final EvaluationResultCollection getEvaluationResults()
Getter for the evaluation results

Returns:
the evaluation results

doEvaluate

public final long doEvaluate()
Does run the evaluation for all feature sets

Returns:
the count of successfully evaluated feature sets

saveResultsToFile

public final boolean saveResultsToFile(String fileName)
Method to store evaluation result to file.

Parameters:
fileName - the filename
Returns:
true if successful, false otherwise

loadSamplesAndCreatePartioning

public final void loadSamplesAndCreatePartioning()
                                          throws Exception
Does load available samples as feature vectors from DB and creates the partitioning for k-fold cross validation.

Throws:
Exception

evaluate

public final void evaluate(Set<FeatureTypes> selectedFeatures,
                           Classifier classifier)
Evaluation for a single feature set.

Parameters:
selectedFeatures - the selected features for evaluation
classifier - the classifier for evaluation

updateProgress

public final void updateProgress(String msg)
Does publish the current progress with the given message.

Parameters:
msg - the progress message

getStartProgressMessage

public String getStartProgressMessage()
Getter for the start progress message

Returns:
the start message for progress observation