SOMHunter Core
sh::ScoreModel Class Reference

#include <scores.h>

Public Member Functions

 ScoreModel (const DatasetFrames &p)
 
bool operator== (const ScoreModel &other) const
 
float operator[] (FrameId i) const
 
void reset (float val=1.0F)
 
float adjust (FrameId i, float prob)
 Multiplies the relevance score with the provided value. More...
 
float adjust (size_t temp, FrameId i, float prob)
 Multiplies the relevance score of temporal part with the provided value. More...
 
float set (FrameId i, float prob)
 Hard-sets the score with the provided value (normalization required). More...
 
const float * v () const
 Pointer to the begin of the data. More...
 
const float * temp (size_t temp) const
 
size_t size () const
 Returns number of scores stored. More...
 
void apply_temporals (size_t depth, const DatasetFrames &_dataset_frames, const float power)
 Transforms temporal inverse score into temporal scores and aggregates into full image scores. More...
 
void normalize (size_t depth=MAX_TEMPORAL_SIZE)
 Normalizes the score distribution. More...
 
void normalize (float *scores, size_t size)
 
void invalidate_cache ()
 
void reset_mask ()
 
bool is_masked (FrameId ID) const
 Returns the current value for the frame. More...
 
bool set_mask (FrameId ID, bool val)
 Sets the mask value for the frame. More...
 
void apply_bayes (std::set< FrameId > likes, const std::set< FrameId > &screen, const PrimaryFrameFeatures &features)
 Applies relevance feedback rescore based on the Bayesian update rule. More...
 
const std::vector< FrameId > & top_n (const DatasetFrames &_dataset_frames, size_t _size, size_t from_vid_limit=0, size_t from_shot_limit=0) const
 Gets the images with the highest scores but respecting the provided limits. More...
 
std::vector< FrameIdtop_n_with_context (const DatasetFrames &_dataset_frames, size_t _size, size_t from_vid_limit, size_t from_shot_limit) const
 Gets the images with the highest scores while respecting the provided limits and each frame is wrapped by it's context based on the number of frames per line. More...
 
std::vector< FrameIdweighted_sample (size_t _size, float pow=1) const
 Samples n random frames from the current scores distribution. More...
 
FrameId weighted_example (const std::vector< FrameId > &subset) const
 Samples a random frame from the current scores distribution. More...
 
size_t frame_rank (FrameId i) const
 Returns the current rank of the provided frame (starts from 0). More...
 

Static Public Member Functions

static StdVector< std::pair< FrameId, float > > sort_by_score (const StdVector< float > &scores)
 Sorts images by given score vector. More...
 

Private Attributes

std::vector< float > _scores
 Current score distribution for the frames. More...
 
StdMatrix< float > _temporal_scores
 
std::vector< bool > _mask
 Frames mask telling what frames should be placed inside the results. More...
 
std::vector< FrameId_topn_cache
 
bool _cache_dirty
 
std::vector< FrameId_topn_ctx_cache
 
bool _cache_ctx_dirty
 

Constructor & Destructor Documentation

◆ ScoreModel()

sh::ScoreModel::ScoreModel ( const DatasetFrames p)
inline

Member Function Documentation

◆ adjust() [1/2]

float ScoreModel::adjust ( FrameId  i,
float  prob 
)

Multiplies the relevance score with the provided value.

Does not update temporal scores.

Here is the call graph for this function:

◆ adjust() [2/2]

float ScoreModel::adjust ( size_t  temp,
FrameId  i,
float  prob 
)

Multiplies the relevance score of temporal part with the provided value.

Here is the call graph for this function:

◆ apply_bayes()

void ScoreModel::apply_bayes ( std::set< FrameId likes,
const std::set< FrameId > &  screen,
const PrimaryFrameFeatures features 
)

Applies relevance feedback rescore based on the Bayesian update rule.

Here is the call graph for this function:

◆ apply_temporals()

void ScoreModel::apply_temporals ( size_t  depth,
const DatasetFrames _dataset_frames,
const float  power 
)

Transforms temporal inverse score into temporal scores and aggregates into full image scores.

Depth parameter defines depth of temporal query

Here is the call graph for this function:

◆ frame_rank()

size_t ScoreModel::frame_rank ( FrameId  i) const

Returns the current rank of the provided frame (starts from 0).

◆ invalidate_cache()

void sh::ScoreModel::invalidate_cache ( )
inline

◆ is_masked()

bool sh::ScoreModel::is_masked ( FrameId  ID) const
inline

Returns the current value for the frame.

◆ normalize() [1/2]

void ScoreModel::normalize ( float *  scores,
size_t  size 
)
Here is the call graph for this function:

◆ normalize() [2/2]

void ScoreModel::normalize ( size_t  depth = MAX_TEMPORAL_SIZE)

Normalizes the score distribution.

Here is the call graph for this function:

◆ operator==()

bool ScoreModel::operator== ( const ScoreModel other) const

◆ operator[]()

float sh::ScoreModel::operator[] ( FrameId  i) const
inline

◆ reset()

void ScoreModel::reset ( float  val = 1.0F)
Here is the call graph for this function:

◆ reset_mask()

void sh::ScoreModel::reset_mask ( )
inline
Here is the call graph for this function:

◆ set()

float ScoreModel::set ( FrameId  i,
float  prob 
)

Hard-sets the score with the provided value (normalization required).

Here is the call graph for this function:

◆ set_mask()

bool sh::ScoreModel::set_mask ( FrameId  ID,
bool  val 
)
inline

Sets the mask value for the frame.

Here is the call graph for this function:

◆ size()

size_t sh::ScoreModel::size ( ) const
inline

Returns number of scores stored.

◆ sort_by_score()

std::vector< std::pair< FrameId, float > > ScoreModel::sort_by_score ( const StdVector< float > &  scores)
static

Sorts images by given score vector.

◆ temp()

const float* sh::ScoreModel::temp ( size_t  temp) const
inline
Here is the call graph for this function:

◆ top_n()

const std::vector< FrameId > & ScoreModel::top_n ( const DatasetFrames _dataset_frames,
size_t  _size,
size_t  from_vid_limit = 0,
size_t  from_shot_limit = 0 
) const

Gets the images with the highest scores but respecting the provided limits.

Here is the call graph for this function:

◆ top_n_with_context()

std::vector< FrameId > ScoreModel::top_n_with_context ( const DatasetFrames _dataset_frames,
size_t  _size,
size_t  from_vid_limit,
size_t  from_shot_limit 
) const

Gets the images with the highest scores while respecting the provided limits and each frame is wrapped by it's context based on the number of frames per line.

Here is the call graph for this function:

◆ v()

const float* sh::ScoreModel::v ( ) const
inline

Pointer to the begin of the data.

◆ weighted_example()

FrameId ScoreModel::weighted_example ( const std::vector< FrameId > &  subset) const

Samples a random frame from the current scores distribution.

◆ weighted_sample()

std::vector< FrameId > ScoreModel::weighted_sample ( size_t  _size,
float  pow = 1 
) const

Samples n random frames from the current scores distribution.

Member Data Documentation

◆ _cache_ctx_dirty

bool sh::ScoreModel::_cache_ctx_dirty
mutableprivate

◆ _cache_dirty

bool sh::ScoreModel::_cache_dirty
mutableprivate

◆ _mask

std::vector<bool> sh::ScoreModel::_mask
private

Frames mask telling what frames should be placed inside the results.

true <=> present in the result set false <=> filtered out

◆ _scores

std::vector<float> sh::ScoreModel::_scores
private

Current score distribution for the frames.

◆ _temporal_scores

StdMatrix<float> sh::ScoreModel::_temporal_scores
private

◆ _topn_cache

std::vector<FrameId> sh::ScoreModel::_topn_cache
mutableprivate

◆ _topn_ctx_cache

std::vector<FrameId> sh::ScoreModel::_topn_ctx_cache
mutableprivate

The documentation for this class was generated from the following files: