CWeightingFunction Class

# CWeightingFunction Class Reference

[CADIHash.h Index] [CADIHash.h Hierarchy]

a universally usable class for weighting More...

`#include <../libInvertedFile/include/CWeightingFunction.h>`

## Public Members

- double getQueryFactor ()
- virtual void preCalculate ()
- CWeightingFunction (const CAcInvertedFile* inAccessor=0, CQueryNormalizer* inQueryNormalizer=0, CQueryNormalizer* inThisNormalizer=0)
- void setAccessor (const CAcInvertedFile*)
- void setNormalizers (CQueryNormalizer* inQueryNormalizer, CQueryNormalizer* inThisNormalizer)
- void setID (TID)
- TID getID ()
- void setRelevanceSum (double inPositiveRelevanceSum, double inNegativeRelevanceSum)
- virtual void addQueryFeature (double inRelevanceLevel, const CDocumentFrequencyElement& inQueryFeature)
- virtual double getTermFrequency ()
- virtual double subApply (const double inDocumentFrequency, const double inNormalizingFactor)
- virtual double apply (const CDocumentFrequencyElement& inResultFeature)
- double applyOnThis ()
- virtual CWeightingFunction* constructNew (TID inID)
- virtual CWeightingFunction* clone ()
- friend class CSortByDFTimesLogICF_WF

## Protected Members

- double mPositiveRelevanceSum
- double mNegativeRelevanceSum
- double mPositiveTermFrequency
- double mNegativeTermFrequency
- int mFeatureDescription
- TID mID
- const CAcInvertedFile* mAccessor
- mutable CQueryNormalizer* mQueryNormalizer
- mutable CQueryNormalizer* mThisNormalizer
- double mQueryFactor
- double mDocumentFactor

## Detailed Description

a universally usable class for weighting. The rationale is, that we want to implement very flexible feature weighting, so flexible that it does not necessarily have anything to do with the initial concept of feature weighting.

The scenario: We have query/feedback from the user. That is: We have a list of images with either positive or negative relevance for the user. Each of these images contains a list of features.

Now we want to combine the different features. What we usually need to know is: how many images where in the positive feedback, and how many images where in the negative feedback.

## double getQueryFactor()

The query factor contains all informatio which depends only on the query. (for efficiency)

## virtual void preCalculate()

Calculate the QueryFactor.

## CWeightingFunction(const CAcInvertedFile* inAccessor=0, CQueryNormalizer.html">CQueryNormalizer* inQueryNormalizer=0, CQueryNormalizer.html">CQueryNormalizer* inThisNormalizer=0)

Constructor:

Parameters:

  inQueryNormalizer: | FIXME
  inThisNormalizer: | FIXME
  inAccessor: | the accessor containing this \ (for getting information about single documents)

## void setAccessor(const CAcInvertedFile*)

Set the accessor (should not be needed)

## void setNormalizers(CQueryNormalizer.html">CQueryNormalizer* inQueryNormalizer, CQueryNormalizer.html">CQueryNormalizer* inThisNormalizer)

Set the query normalizer (should not be needed);

## void setID(TID)

Set the ID of this feature

## TID getID()

get the ID of this feature

## void setRelevanceSum(double inPositiveRelevanceSum, double inNegativeRelevanceSum)

Setting the relevance sum, that is the sum of the absolute values of all relevance levels of all documents of the query

for rocchio we need this sum to be once calculated for positive, once for negative feedback images

## virtual void addQueryFeature(double inRelevanceLevel, const CDocumentFrequencyElement& inQueryFeature)

Add a feature. A feature will be a document frequency element out of the feature file.

## virtual double getTermFrequency()

Giving a pseudo term frequency for normalization

## virtual double subApply(const double inDocumentFrequency, const double inNormalizingFactor)

Apply this on a document frequency

## virtual double apply(const CDocumentFrequencyElement& inResultFeature)

Preparing the right parameters for subApply: Apply this on another feature

## double applyOnThis()

Preparing the right parameters for subApply: Apply this on itself

## virtual CWeightingFunction* constructNew(TID inID)

For the "prototype pattern": Kinda virtual copy constructor:

## virtual CWeightingFunction* clone()

For the "prototype pattern": Kinda virtual copy constructor: Gamma/Helm/Johnson/Vlissides p. 107

This is a new version of constructNew which manages to live without the setID function

## double mPositiveRelevanceSum

This value depends on all the elements of the query, whichhave a positive user-assigned relevance.

i.e. not necessarily only on the elements which contain this feature, so it has to be explicitly set using the function setRelevanceSum from the outside.

If relevance=+-1 then this is the number of positive images in the query

## double mNegativeRelevanceSum

This value depends on all the elements of the query, whichhave a negative user-assigned relevance.

i.e. not necessarily only on the elements which contain this feature, so it has to be explicitly set using the function setRelevanceSum from the outside.

If relevance=+-1 then this is the number of negative images in the query

## int mFeatureDescription

At present the feature description is a simple integer which expresses if the feature is a histogram feature or not and if it is a texture feature or not. We probably will use more elaborate descriptions in the future.

## const CAcInvertedFile* mAccessor

The accessor for the file on which the query is performed

## mutable CQueryNormalizer* mQueryNormalizer

FIXME THERE IS A GOOD DESCRIPTION MISSING FOR THE NEXT

## mutable CQueryNormalizer* mThisNormalizer

A normalizer for apply on self

## double mQueryFactor

The query usually will separate into a part which is equal for all the query and a part which is to be calculated for each document. The part which stays constant

Author: Wolfgang Müller Documentation generated by muellerw@pc7170 on Son Okt 8 16:04:40 CEST 2000 | Kdoc