MyMediaLite  3.11
Static Public Member Functions | List of all members
Extensions Class Reference

Extension methods for correlation matrices More...

Static Public Member Functions

static IList< int > GetNearestNeighbors (this ICorrelationMatrix c, int entity_id, uint k)
 Get the k nearest neighbors of a given entity More...
 
static IList< int > GetPositivelyCorrelatedEntities (this ICorrelationMatrix c, int entity_id)
 Get all entities that are positively correlated to an entity, sorted by correlation More...
 
static void ReadAsymmetricCorrelationMatrix (this AsymmetricCorrelationMatrix correlation, StreamReader reader)
 Reads a AsymmetricCorrelationMatrix from the lines of a StreamReader More...
 
static void ReadSymmetricCorrelationMatrix (this SymmetricCorrelationMatrix correlation, StreamReader reader)
 Reads a SymmetricCorrelationMatrix from the lines of a StreamReader More...
 
static void SetZero (this ICorrelationMatrix c)
 Sets all values in a matrix to zero More...
 
static double SumUp (this ICorrelationMatrix correlation, int entity_id, ICollection< int > entities, float q=1.0f)
 Sum up the correlations between a given entity and the entities in a collection More...
 

Detailed Description

Extension methods for correlation matrices

Member Function Documentation

static IList<int> GetNearestNeighbors ( this ICorrelationMatrix  c,
int  entity_id,
uint  k 
)
inlinestatic

Get the k nearest neighbors of a given entity

Parameters
ca correlation matrix
entity_idthe numerical ID of the entity
kthe neighborhood size
Returns
a sorted list containing the numerical IDs of the k nearest neighbors
static IList<int> GetPositivelyCorrelatedEntities ( this ICorrelationMatrix  c,
int  entity_id 
)
inlinestatic

Get all entities that are positively correlated to an entity, sorted by correlation

Parameters
ca correlation matrix
entity_idthe entity ID
Returns
a sorted list of all entities that are positively correlated to entitiy_id
static void ReadAsymmetricCorrelationMatrix ( this AsymmetricCorrelationMatrix  correlation,
StreamReader  reader 
)
inlinestatic

Reads a AsymmetricCorrelationMatrix from the lines of a StreamReader

In the first line, we expect to be the number of entities. All the other lines have the format

  EntityID1 EntityID2 Correlation

where EntityID1 and EntityID2 are non-negative integers and Correlation is a floating point number.

Parameters
correlationa correlation matrix
readerthe StreamReader to read from
static void ReadSymmetricCorrelationMatrix ( this SymmetricCorrelationMatrix  correlation,
StreamReader  reader 
)
inlinestatic

Reads a SymmetricCorrelationMatrix from the lines of a StreamReader

In the first line, we expect to be the number of entities. All the other lines have the format

  EntityID1 EntityID2 Correlation

where EntityID1 and EntityID2 are non-negative integers and Correlation is a floating point number.

Parameters
correlationa correlation matrix
readerthe StreamReader to read from
static void SetZero ( this ICorrelationMatrix  c)
inlinestatic

Sets all values in a matrix to zero

Parameters
ca correlation matrix
static double SumUp ( this ICorrelationMatrix  correlation,
int  entity_id,
ICollection< int >  entities,
float  q = 1.0f 
)
inlinestatic

Sum up the correlations between a given entity and the entities in a collection

Parameters
correlationthe correlation matrix
entity_idthe numerical ID of the entity
entitiesa collection containing the numerical IDs of the entities to compare to
qscore exponent
Returns
the correlation sum

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