Class ExpressionFitnessFunction
- java.lang.Object
-
- org.jgap.gp.GPFitnessFunction
-
- org.aksw.limes.core.ml.algorithm.eagle.core.IGPFitnessFunction
-
- org.aksw.limes.core.ml.algorithm.eagle.core.ExpressionFitnessFunction
-
- All Implemented Interfaces:
Serializable,IFitnessFunction
public class ExpressionFitnessFunction extends IGPFitnessFunction
Implementation of our custom FitnessFunction. As we're using theDeltaFitnessEvaluatorhigher fitness values mean the individual is less fit! ReImplementation onExcutionEngineFIXME fix QualityMeasures to work on Mappings!
- Author:
- Klaus Lyko, Tommaso Soru (tsoru@informatik.uni-leipzig.de)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected doublecrossProductstatic StringfScoreprotected LinkSpecGeneticLearnerConfigm_configprotected IQualitativeMeasuremeasurestatic Stringprecisionstatic Stringrecallprotected AMappingreferenceFragment of optimal Mapping used during evolution.protected ACachesCprotected ACachetCprotected ACachetrimmedSourceCacheprotected ACachetrimmedTargetCache
-
Constructor Summary
Constructors Modifier Constructor Description protectedExpressionFitnessFunction(LinkSpecGeneticLearnerConfig a_config)Needed for subclasses.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddToReference(AMapping m)Method to add instances to reference?.doublecalculateRawFitness(org.jgap.gp.IGPProgram p)Calculates the fitness of the given GPProgram p.doublecalculateRawMeasure(org.jgap.gp.IGPProgram p)voiddestroy()protected doubleevaluate(org.jgap.gp.IGPProgram a_subject)voidfillCachesIncrementally(AMapping matches)static ExpressionFitnessFunctiongetInstance(LinkSpecGeneticLearnerConfig a_config, IQualitativeMeasure measure, AMapping reference)AMappinggetMapping(ACache sourceCache, ACache targetCache, LinkSpecification spec)To calculate Mappings based on LSLinkSpecificationgetMetric(org.jgap.gp.IGPProgram p)AMappinggetReferenceMapping()ACachegetSourceCache()Get full caches used by this learner.ACachegetTargetCache()Get full caches used by this learner.voidsetCaches(ACache sC, ACache tC)voidsetReferenceMapping(AMapping referenceData)As we assume referenceData only holding matches.voidsetUseFullCaches(boolean value)If we want to use Full Caches instead.voidtrimKnowledgeBases(AMapping trainingData)Method to scale down caches according to given training data.
-
-
-
Field Detail
-
fScore
public static final String fScore
- See Also:
- Constant Field Values
-
recall
public static final String recall
- See Also:
- Constant Field Values
-
precision
public static final String precision
- See Also:
- Constant Field Values
-
m_config
protected LinkSpecGeneticLearnerConfig m_config
-
reference
protected AMapping reference
Fragment of optimal Mapping used during evolution. Note that it should only hold matches!
-
sC
protected ACache sC
-
tC
protected ACache tC
-
trimmedSourceCache
protected ACache trimmedSourceCache
-
trimmedTargetCache
protected ACache trimmedTargetCache
-
measure
protected IQualitativeMeasure measure
-
crossProduct
protected double crossProduct
-
-
Constructor Detail
-
ExpressionFitnessFunction
protected ExpressionFitnessFunction(LinkSpecGeneticLearnerConfig a_config)
Needed for subclasses.
-
-
Method Detail
-
getInstance
public static ExpressionFitnessFunction getInstance(LinkSpecGeneticLearnerConfig a_config, IQualitativeMeasure measure, AMapping reference)
-
evaluate
protected double evaluate(org.jgap.gp.IGPProgram a_subject)
- Specified by:
evaluatein classorg.jgap.gp.GPFitnessFunction
-
calculateRawFitness
public double calculateRawFitness(org.jgap.gp.IGPProgram p)
Calculates the fitness of the given GPProgram p. This is done as follows: 1.1 get the Metric Expression by executing (as object) the first chromosome. 1.2 get the mapping links with these settings 2. Calculate either recall, precision or f-score and return 1 minus it. The evolution could produce non wanted individuals especially those who compare properties which are not part of the PropertyMapping (set in the ExpressionConfiguration). In such cases setp 1.1 throws an IllegalStateException. As a result the fitness value would be set to rather bad one.- Parameters:
p- GPProgram fitness is calculated for.- Returns:
- Double value. The closer to 0 the better.
-
calculateRawMeasure
public double calculateRawMeasure(org.jgap.gp.IGPProgram p)
-
getSourceCache
public ACache getSourceCache()
Get full caches used by this learner.- Returns:
- HybridCache of the source endpoint.
-
getTargetCache
public ACache getTargetCache()
Get full caches used by this learner.- Returns:
- HybridCache of the target endpoint.
-
destroy
public void destroy()
-
getMapping
public AMapping getMapping(ACache sourceCache, ACache targetCache, LinkSpecification spec)
Description copied from interface:IFitnessFunctionTo calculate Mappings based on LS- Returns:
-
trimKnowledgeBases
public void trimKnowledgeBases(AMapping trainingData)
Method to scale down caches according to given training data.- Parameters:
trainingData- Mapping holding data instances a user has evaluated. That may include non-matches.
-
setUseFullCaches
public void setUseFullCaches(boolean value)
If we want to use Full Caches instead.- Parameters:
value-
-
getMetric
public LinkSpecification getMetric(org.jgap.gp.IGPProgram p)
-
getReferenceMapping
public AMapping getReferenceMapping()
-
setReferenceMapping
public void setReferenceMapping(AMapping referenceData)
As we assume referenceData only holding matches. Learner may have to set it separately.- Parameters:
referenceData- A Mapping holding all matches.
-
addToReference
public void addToReference(AMapping m)
Method to add instances to reference?.- Specified by:
addToReferencein classIGPFitnessFunction- Parameters:
m- Mapping of matches, designated as such by an oracle.
-
fillCachesIncrementally
public void fillCachesIncrementally(AMapping matches)
- Specified by:
fillCachesIncrementallyin classIGPFitnessFunction
-
-