Algorithm::ContextVector - Simple implementation based on Data::CosineSimilarity
my $cv = Algorithm::ContextVector->new( top => 300 ); $cs->add_instance( label => 'label1', attributes => { feature1 => 3, feature2 => 1, feature3 => 10 } ); $cs->add_instance( label => [ 'label2', 'label3' ], attributes => { ... } ); $cs->add_instance( label => ..., attributes => ... ); ... $cv->train; my $results = $cv->predict( attributes => { ... } );
Simple implementation based on Data::CosineSimilarity
During the training, keeps the $top most heavy weighted features. Keeps the complete feature set if omitted.
Returns the instance of Algorithm::ContextVector stored in $filename.
Save the $self to $filename using Storable.
Keeps the best features (top N) and norms the vectors.
Returns a hashref with the labels as the keys and the cosines as the values.
Antoine Imbert, <antoine.imbert at gmail.com>
<antoine.imbert at gmail.com>
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Algorithm::ContextVector, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Algorithm::ContextVector
CPAN shell
perl -MCPAN -e shell install Algorithm::ContextVector
For more information on module installation, please visit the detailed CPAN module installation guide.