Algorithm-SVMLight
view release on metacpan or search on metacpan
lib/Algorithm/SVMLight.pm view on Meta::CPAN
=item read_model($file)
Reads a model that has previously been written with C<write_model()>:
my $m = Algorithm::SVMLight->new();
$m->read_model($file);
The model file is read using SVMLight's C<read_model()> C function, so
if you want to, you could initially create the model with one of
SVMLight's command-line tools like C<svm_learn>.
=item get_linear_weights()
After training a linear model (or reading in a model file), this
method will return a reference to an array containing the linear
weights of the model. This can be useful for model inspection, to see
which features are having the greatest impact on decision-making.
my $arrayref = $m->get_linear_weights();
The first element (position 0) of the array will be the threshold
C<b>, and the rest of the elements will be the weights themselves.
Thus from 1 upward, the indices align with SVMLight's internal
indices.
If the model has not yet been trained, or if the kernel type is not
linear, an exception will be thrown.
=item feature_names()
Returns a list of feature names that have been fed to
C<add_instance()> as keys of the C<attribute> parameter, or in a
scalar context the number of such names.
=item num_features()
Returns the number of features known to this model. Note that if you
use C<add_instance_i()> or C<read_instances()>, some of the features
may never actually have been I<seen> before, because you could add
instances with only indices 2, 5, and 37, never having added any
instances with the indices in between, but C<num_features()> will
return 37 in this case. This is because after training, an instance
could be passed to the C<predict()> method with real values for these
previously unseen features. If you just use C<add_instance()>
instead, you'll probably never run into this issue, and in a scalar
context C<num_features()> will look just like C<feature_names()>.
=item num_instances()
Returns the number of training instances known to the model. It
should be fine to call this method either before or after training
actually occurs.
=back
=head1 SEE ALSO
L<Algorithm::NaiveBayes>, L<AI::DecisionTree>
L<http://svmlight.joachims.org/>
=head1 AUTHOR
Ken Williams, E<lt>kwilliams@cpan.orgE<gt>
=head1 COPYRIGHT AND LICENSE
The C<Algorithm::SVMLight> perl interface is copyright (C) 2005-2008
Thomson Legal & Regulatory, and written by Ken Williams. It is free
software; you can redistribute it and/or modify it under the same
terms as C<perl> itself.
Thorsten Joachims and/or Cornell University of Ithaca, NY control the
copyright of SVMLight itself - you will find full copyright and
license information in its distribution. You are responsible for
obtaining an appropriate license for SVMLight if you intend to use
C<Algorithm::SVMLight>. In particular, please note that SVMLight "is
granted free of charge for research and education purposes. However
you must obtain a license from the author to use it for commercial
purposes."
To avoid any copyright clashes, the F<SVMLight.patch> file distributed
here is granted under the same license terms as SVMLight itself.
=cut
( run in 0.788 second using v1.01-cache-2.11-cpan-df04353d9ac )