Containers from the C++ Standard Template Library (STL) are used throughout for maximum ease of integration with existing code bases.
string name;
double rating_val;
rating one_rating;
vector< rating > my_ratings;
// loop over all rating items and set name and rating value
one_rating.add( name , value );
my_ratings.push_back( one_rating ); // add rating to vector
Ratings are fairly robust objects -- for example, ratings return a
recognizable bad value if a requested rating element is not
found. More on how eigenspace handles rating objects will be
discussed in the Eigenspace section.
// load names of rating items used to generate
// the space into a list
list< string > names;
// construct a space with the list and the maximum
// magnitude of useable ratings
eigenspace< DynamicND > space( names, 10.0 );
// simple example of loading the number of clusters for each
// dimension -- this a technical detail and can be hidden from
// the application if necessary
vector< size_t > cuts( 3 );
cuts[0] = 5; cuts[1] = 3; cuts[2] = 2;
bool success = space.set_strategy_dimensions( 3, cuts );
// generate the space with a vector of ratings filled earlier --
// returns the number of actual ratings used.
int useable = space.generate( my_ratings );
// example error checking
if( useable != my_ratings.size() )
cerr << "Found some bad ratings" << endl;
string my_savefile = "saveme.space";
space.save( my_savefile );
Eigenspace also provides some high level statistical procedures
for determining the mean and variance of ratings for each rating
element within each user cluster.
// load a space object from disk
eigenspace< DynamicND > space( my_savefile );
rating one_rating;
// fill in rating for a user
profile my_profile = space.get_profile( one_rating );
string my_cluster = my_profile.prime_cluster();
Profile can easily be extended to handle multiple clusters with
differing weights for a single user. Then, a call to
prime_cluster() would return the cluster id with highest weight.