Adding SVM documentation

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@311126 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Ian Barber 2011-05-17 12:38:28 +00:00
parent 140520df70
commit 2bfd4f3161
19 changed files with 1490 additions and 0 deletions

42
reference/svm/book.xml Normal file
View file

@ -0,0 +1,42 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<book xml:id="book.svm" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>Support Vector Machine</title>
<titleabbrev>SVM</titleabbrev>
<preface xml:id="intro.svm">
&reftitle.intro;
<para>
LibSVM is an efficient solver for SVM classification and regression problems. The svm extension wraps this in a PHP interface for easy use in PHP scripts.
</para>
</preface>
&reference.svm.setup;
&reference.svm.examples;
&reference.svm.svm;
&reference.svm.svmmodel;
</book>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->

View file

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<section xml:id="svm.installation" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
&reftitle.install;
<para>
&pecl.info;
<link xlink:href="&url.pecl.package;svm">&url.pecl.package;svm</link>
</para>
</section>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->

View file

@ -0,0 +1,5 @@
&reference.svm.svm.construct;
&reference.svm.svm.crossvalidate;
&reference.svm.svm.getoptions;
&reference.svm.svm.setoptions;
&reference.svm.svm.train;

View file

@ -0,0 +1,4 @@
&reference.svm.svmmodel.construct;
&reference.svm.svmmodel.load;
&reference.svm.svmmodel.predict;
&reference.svm.svmmodel.save;

View file

@ -0,0 +1,93 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision: 294364 $ -->
<chapter xml:id="svm.examples" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
&reftitle.examples;
<para>
The basic process is to define parameters, supply training data to generate a model on, then make predictions based on the model. There are a default set of parameters that should get some results with most any input, so we'll start by looking at the data.
</para>
<para>
Data is supplied in either a file, a stream, or as an an array. If supplied in a file or a stream, it must contain one line per training example, which must be formatted as an integer class (usually 1 and -1) followed by a series of feature/value pairs, in increasing feature order. The features are integers, the values floats, usually scaled 0-1. For example:
</para>
<para>
-1 1:0.43 3:0.12 9284:0.2
</para>
<para>
In a document classification problem, say a spam checker, each line would represent a document. There would be two classes, -1 for spam, 1 for ham. Each feature would represent some word, and the value would represent that importance of that word to the document (perhaps the frequency count, with the total scaled to unit length). Features that were 0 (e.g. the word did not appear in the document at all) would simply not be included.
</para>
<para>
In array mode, the data must be passed as an array of arrays. Each sub-array must have the class as the first element, then key => value sets for the feature values pairs.
</para>
<para>
This data is passed to the SVM class's train function, which will return an SVM model is successful.
</para>
<para>
Once a model has been generated, it can be used to make predictions about previously unseen data. This can be passed as an array to the model's predict function, in the same format as before, but without the label. The response will be the class.
</para>
<para>
Models can be saved and restored as required, using the save and load functions, which both take a file location.
</para>
<para>
<example>
<title>Train from array</title>
<programlisting role="php">
<![CDATA[
<?php
$data = array(
array(-1, 1 => 0.43, 3 => 0.12, 9284 => 0.2),
array(1, 1 => 0.22, 5 => 0.01, 94 => 0.11),
);
$svm = new SVM();
$model = $svm->train($data);
$data = array(1 => 0.43, 3 => 0.12, 9284 => 0.2);
$result = $model->predict($data);
var_dump($result);
$model->save('model.svm');
?>
]]>
</programlisting>
&example.outputs.similar;
<screen>
<![CDATA[
int(-1)
]]>
</screen>
</example>
<example>
<title>Train from a file</title>
<programlisting role="php">
<![CDATA[
<?php
$svm = new SVM();
$model = $svm->train("traindata.txt");
?>
]]>
</programlisting>
</example>
</para>
</chapter>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->

72
reference/svm/setup.xml Normal file
View file

@ -0,0 +1,72 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<chapter xml:id="svm.setup" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
&reftitle.setup;
<section xml:id="svm.requirements">
&reftitle.required;
<para>
Libsvm itself is required, and is available through some package management - libsvm-devel for RPM based system or libsvm-dev for Debian based ones. Alternatively it is available direct from the website. If installing from the <link xlink:href="&url.svm;">official website</link> then some steps will need to be taken as the package does not install automatically. For example, assuming the latest version is 3.1:
</para>
<screen>
<![CDATA[
wget http://www.csie.ntu.edu.tw/~cjlin/cgi-bin/libsvm.cgi?+http://www.csie.ntu.edu.tw/~cjlin/libsvm+tar.gz
tar xvzf libsvm-3.1.tar.gz
cd libsvm-3.1
make lib
cp libsvm.so.1 /usr/lib
ln -s libsvm.so.1 libsvm.so
ldconfig
ldconfig --print | grep libsvm
]]>
</screen>
<para>
This last step should show libsvm is installed.
</para>
</section>
<section xml:id="svm.installation">
&reftitle.install;
<para>
&pecl.info;
<link xlink:href="&url.pecl.package;svm">&url.pecl.package;svm</link>
</para>
</section>
<section xml:id="svm.configuration">
&reftitle.runtime;
&no.config;
</section>
<section xml:id="svm.resources">
&reftitle.resources;
&no.resource;
<para>
</para>
</section>
</chapter>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->

366
reference/svm/svm.xml Normal file
View file

@ -0,0 +1,366 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<phpdoc:classref xml:id="class.svm" xmlns:phpdoc="http://php.net/ns/phpdoc" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude">
<title>The SVM class</title>
<titleabbrev>SVM</titleabbrev>
<partintro>
<!-- {{{ svm intro -->
<section xml:id="svm.intro">
&reftitle.intro;
<para>
</para>
</section>
<!-- }}} -->
<section xml:id="svm.synopsis">
&reftitle.classsynopsis;
<!-- {{{ Synopsis -->
<classsynopsis>
<ooclass><classname>SVM</classname></ooclass>
<!-- {{{ Class synopsis -->
<classsynopsisinfo>
<ooclass>
<classname>SVM</classname>
</ooclass>
</classsynopsisinfo>
<!-- }}} -->
<classsynopsisinfo role="comment">Constants</classsynopsisinfo>
<fieldsynopsis>
<modifier>const</modifier>
<type>integer</type>
<varname linkend="svm.constants.c-svc">SVM::C_SVC</varname>
<initializer>0</initializer>
</fieldsynopsis>
<fieldsynopsis>
<modifier>const</modifier>
<type>integer</type>
<varname linkend="svm.constants.nu-svc">SVM::NU_SVC</varname>
<initializer>1</initializer>
</fieldsynopsis>
<fieldsynopsis>
<modifier>const</modifier>
<type>integer</type>
<varname linkend="svm.constants.one-class">SVM::ONE_CLASS</varname>
<initializer>2</initializer>
</fieldsynopsis>
<fieldsynopsis>
<modifier>const</modifier>
<type>integer</type>
<varname linkend="svm.constants.epsilon-svr">SVM::EPSILON_SVR</varname>
<initializer>3</initializer>
</fieldsynopsis>
<fieldsynopsis>
<modifier>const</modifier>
<type>integer</type>
<varname linkend="svm.constants.nu-svr">SVM::NU_SVR</varname>
<initializer>4</initializer>
</fieldsynopsis>
<fieldsynopsis>
<modifier>const</modifier>
<type>integer</type>
<varname linkend="svm.constants.kernel-linear">SVM::KERNEL_LINEAR</varname>
<initializer>0</initializer>
</fieldsynopsis>
<fieldsynopsis>
<modifier>const</modifier>
<type>integer</type>
<varname linkend="svm.constants.kernel-poly">SVM::KERNEL_POLY</varname>
<initializer>1</initializer>
</fieldsynopsis>
<fieldsynopsis>
<modifier>const</modifier>
<type>integer</type>
<varname linkend="svm.constants.kernel-rbf">SVM::KERNEL_RBF</varname>
<initializer>2</initializer>
</fieldsynopsis>
<fieldsynopsis>
<modifier>const</modifier>
<type>integer</type>
<varname linkend="svm.constants.kernel-sigmoid">SVM::KERNEL_SIGMOID</varname>
<initializer>3</initializer>
</fieldsynopsis>
<fieldsynopsis>
<modifier>const</modifier>
<type>integer</type>
<varname linkend="svm.constants.kernel-precomputed">SVM::KERNEL_PRECOMPUTED</varname>
<initializer>4</initializer>
</fieldsynopsis>
<fieldsynopsis>
<modifier>const</modifier>
<type>integer</type>
<varname linkend="svm.constants.opt-type">SVM::OPT_TYPE</varname>
<initializer>101</initializer>
</fieldsynopsis>
<fieldsynopsis>
<modifier>const</modifier>
<type>integer</type>
<varname linkend="svm.constants.opt-kernel-type">SVM::OPT_KERNEL_TYPE</varname>
<initializer>102</initializer>
</fieldsynopsis>
<fieldsynopsis>
<modifier>const</modifier>
<type>integer</type>
<varname linkend="svm.constants.opt-degree">SVM::OPT_DEGREE</varname>
<initializer>103</initializer>
</fieldsynopsis>
<fieldsynopsis>
<modifier>const</modifier>
<type>integer</type>
<varname linkend="svm.constants.opt-shrinking">SVM::OPT_SHRINKING</varname>
<initializer>104</initializer>
</fieldsynopsis>
<fieldsynopsis>
<modifier>const</modifier>
<type>integer</type>
<varname linkend="svm.constants.opt-propability">SVM::OPT_PROPABILITY</varname>
<initializer>105</initializer>
</fieldsynopsis>
<fieldsynopsis>
<modifier>const</modifier>
<type>integer</type>
<varname linkend="svm.constants.opt-gamma">SVM::OPT_GAMMA</varname>
<initializer>201</initializer>
</fieldsynopsis>
<fieldsynopsis>
<modifier>const</modifier>
<type>integer</type>
<varname linkend="svm.constants.opt-nu">SVM::OPT_NU</varname>
<initializer>202</initializer>
</fieldsynopsis>
<fieldsynopsis>
<modifier>const</modifier>
<type>integer</type>
<varname linkend="svm.constants.opt-eps">SVM::OPT_EPS</varname>
<initializer>203</initializer>
</fieldsynopsis>
<fieldsynopsis>
<modifier>const</modifier>
<type>integer</type>
<varname linkend="svm.constants.opt-p">SVM::OPT_P</varname>
<initializer>204</initializer>
</fieldsynopsis>
<fieldsynopsis>
<modifier>const</modifier>
<type>integer</type>
<varname linkend="svm.constants.opt-coef-zero">SVM::OPT_COEF_ZERO</varname>
<initializer>205</initializer>
</fieldsynopsis>
<fieldsynopsis>
<modifier>const</modifier>
<type>integer</type>
<varname linkend="svm.constants.opt-c">SVM::OPT_C</varname>
<initializer>206</initializer>
</fieldsynopsis>
<fieldsynopsis>
<modifier>const</modifier>
<type>integer</type>
<varname linkend="svm.constants.opt-cache-size">SVM::OPT_CACHE_SIZE</varname>
<initializer>207</initializer>
</fieldsynopsis>
<classsynopsisinfo role="comment">Methods</classsynopsisinfo>
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.svm')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[1])" />
</classsynopsis>
<!-- }}} -->
</section>
<!-- {{{ svm constants -->
<section xml:id="svm.constants">
&reftitle.constants;
<section xml:id="svm.constants.types">
<title>SVM Constants</title>
<variablelist>
<varlistentry xml:id="svm.constants.c-svc">
<term><constant>SVM::C_SVC</constant></term>
<listitem>
<para>The basic C_SVC SVM type. The default, and a good starting point</para>
</listitem>
</varlistentry>
<varlistentry xml:id="svm.constants.nu-svc">
<term><constant>SVM::NU_SVC</constant></term>
<listitem>
<para>The NU_SVC type uses a different, more flexible, error weighting</para>
</listitem>
</varlistentry>
<varlistentry xml:id="svm.constants.one-class">
<term><constant>SVM::ONE_CLASS</constant></term>
<listitem>
<para>One class SVM type. Train just on a single class, using outliers as negative examples</para>
</listitem>
</varlistentry>
<varlistentry xml:id="svm.constants.epsilon-svr">
<term><constant>SVM::EPSILON_SVR</constant></term>
<listitem>
<para>A SVM type for regression (predicting a value rather than just a class)</para>
</listitem>
</varlistentry>
<varlistentry xml:id="svm.constants.nu-svr">
<term><constant>SVM::NU_SVR</constant></term>
<listitem>
<para>A NU style SVM regression type</para>
</listitem>
</varlistentry>
<varlistentry xml:id="svm.constants.kernel-linear">
<term><constant>SVM::KERNEL_LINEAR</constant></term>
<listitem>
<para>A very simple kernel, can work well on large document classification problems</para>
</listitem>
</varlistentry>
<varlistentry xml:id="svm.constants.kernel-poly">
<term><constant>SVM::KERNEL_POLY</constant></term>
<listitem>
<para>A polynomial kernel</para>
</listitem>
</varlistentry>
<varlistentry xml:id="svm.constants.kernel-rbf">
<term><constant>SVM::KERNEL_RBF</constant></term>
<listitem>
<para>The common Gaussian RBD kernel. Handles non-linear problems well and is a good default for classification</para>
</listitem>
</varlistentry>
<varlistentry xml:id="svm.constants.kernel-sigmoid">
<term><constant>SVM::KERNEL_SIGMOID</constant></term>
<listitem>
<para>A kernel based on the sigmoid function. Using this makes the SVM very similar to a two layer sigmoid based neural network</para>
</listitem>
</varlistentry>
<varlistentry xml:id="svm.constants.kernel-precomputed">
<term><constant>SVM::KERNEL_PRECOMPUTED</constant></term>
<listitem>
<para>A precomputed kernel - currently unsupported.</para>
</listitem>
</varlistentry>
<varlistentry xml:id="svm.constants.opt-type">
<term><constant>SVM::OPT_TYPE</constant></term>
<listitem>
<para>The options key for the SVM type</para>
</listitem>
</varlistentry>
<varlistentry xml:id="svm.constants.opt-kernel-type">
<term><constant>SVM::OPT_KERNEL_TYPE</constant></term>
<listitem>
<para>The options key for the kernel type</para>
</listitem>
</varlistentry>
<varlistentry xml:id="svm.constants.opt-degree">
<term><constant>SVM::OPT_DEGREE</constant></term>
<listitem>
<para></para>
</listitem>
</varlistentry>
<varlistentry xml:id="svm.constants.opt-shrinking">
<term><constant>SVM::OPT_SHRINKING</constant></term>
<listitem>
<para>Training parameter, boolean, for whether to use the shrinking heuristics</para>
</listitem>
</varlistentry>
<varlistentry xml:id="svm.constants.opt-propability">
<term><constant>SVM::OPT_PROBABILITY</constant></term>
<listitem>
<para>Training parmater, boolean, for whether to use probability estimates</para>
</listitem>
</varlistentry>
<varlistentry xml:id="svm.constants.opt-gamma">
<term><constant>SVM::OPT_GAMMA</constant></term>
<listitem>
<para>Algorithm parameter for Poly, RBF and Sigmoid kernel types.</para>
</listitem>
</varlistentry>
<varlistentry xml:id="svm.constants.opt-nu">
<term><constant>SVM::OPT_NU</constant></term>
<listitem>
<para>The option key for the nu parameter, only used in the NU_ SVM types</para>
</listitem>
</varlistentry>
<varlistentry xml:id="svm.constants.opt-eps">
<term><constant>SVM::OPT_EPS</constant></term>
<listitem>
<para>The option key for the Epsilon parameter, used in epsilon regression</para>
</listitem>
</varlistentry>
<varlistentry xml:id="svm.constants.opt-p">
<term><constant>SVM::OPT_P</constant></term>
<listitem>
<para>Training parameter used by Episilon SVR regression</para>
</listitem>
</varlistentry>
<varlistentry xml:id="svm.constants.opt-coef-zero">
<term><constant>SVM::OPT_COEF_ZERO</constant></term>
<listitem>
<para>Algorithm parameter for poly and sigmoid kernels</para>
</listitem>
</varlistentry>
<varlistentry xml:id="svm.constants.opt-c">
<term><constant>SVM::OPT_C</constant></term>
<listitem>
<para>The option for the cost parameter that controls tradeoff between errors and generality </para>
</listitem>
</varlistentry>
<varlistentry xml:id="svm.constants.opt-cache-size">
<term><constant>SVM::OPT_CACHE_SIZE</constant></term>
<listitem>
<para>Memory cache size, in MB</para>
</listitem>
</varlistentry>
</variablelist>
</section>
</section>
<!-- }}} -->
</partintro>
&reference.svm.entities.svm;
</phpdoc:classref>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->

View file

@ -0,0 +1,56 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="svm.construct" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>SVM::__construct</refname>
<refpurpose>Construct a new SVM object</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<methodname>SVM::__construct</methodname>
<void />
</methodsynopsis>
<para>
Constructs a new SVM object ready to accept training data.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
&no.function.parameters;
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Throws SVMException if the libsvm library could not be loaded
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->

View file

@ -0,0 +1,86 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="svm.crossvalidate" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>SVM::crossvalidate</refname>
<refpurpose>Test training params on subsets of the training data.</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>float</type><methodname>svm::crossvalidate</methodname>
<methodparam><type>array</type><parameter>problem</parameter></methodparam>
<methodparam><type>int</type><parameter>number_of_folds</parameter></methodparam>
</methodsynopsis>
<para>
Crossvalidate can be used to test the effectiveness of the current parameter set on a subset of the training data. Given a problem set and a n "folds", it separates the problem set into n subsets, and the repeatedly trains on one subset and tests on another. While the accuracy will generally be lower than a SVM trained on the enter data set, the accuracy score returned should be relatively useful, so it can be used to test different training parameters.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>problem</parameter></term>
<listitem>
<para>
The problem data. This can either be in the form of an array, the URL of an SVMLight formatted file, or a stream to an opened SVMLight formatted datasource.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>number_of_folds</parameter></term>
<listitem>
<para>
The number of sets the data should be divided into and cross tested. A higher number means smaller training sets and less reliability. 5 is a good number to start with.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
The correct percentage, expressed as a floating point number from 0-1. In the case of NU_SVC or EPSILON_SVR kernels the mean squared error will returned instead.
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><methodname>SVM::train</methodname></member>
</simplelist>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->

View file

@ -0,0 +1,56 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="svm.getoptions" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>SVM::getOptions</refname>
<refpurpose>Return the current training parameters</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>array</type><methodname>SVM::getOptions</methodname>
<void />
</methodsynopsis>
<para>
Retrieve an array containing the training parameters. The parameters will be keyed on the predefined SVM constants.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
&no.function.parameters;
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns an array of configuration settings.
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->

View file

@ -0,0 +1,65 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="svm.setoptions" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>SVM::setOptions</refname>
<refpurpose>Set training parameters</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>boolean</type><methodname>SVM::setOptions</methodname>
<methodparam><type>array</type><parameter>params</parameter></methodparam>
</methodsynopsis>
<para>
Set one or more training parameters.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>params</parameter></term>
<listitem>
<para>
An array of training parameters, keyed on the SVM constants.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Return true on success, throws SVMException on error.
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->

View file

@ -0,0 +1,80 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="svm.train" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>SVM::train</refname>
<refpurpose>Create a SVMModel based on training data</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>SVMModel</type><methodname>svm::train</methodname>
<methodparam><type>array</type><parameter>problem</parameter></methodparam>
<methodparam choice="opt"><type>array</type><parameter>weights</parameter></methodparam>
</methodsynopsis>
<para>
Train a support vector machine based on the supplied training data.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>problem</parameter></term>
<listitem>
<para>
The problem can be provided in three different ways.
An array, where the data should start with the class label (usually 1 or -1) then followed by a sparse data set of dimension => data pairs.
A URL to a file containing a SVM Light formatted problem, with the each line being a new training example, the start of each line containing the class (1, -1) then a series of tab separated data values shows as key:value.
A opened stream pointing to a data source formatted as in the file above.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>weights</parameter></term>
<listitem>
<para>
Weights are an optional set of weighting parameters for the different classes, to help account for unbalanced training sets. For example, if the classes were 1 and -1, and -1 had significantly more example than one, the weight for -1 could be 0.5. Weights should be in the range 0-1.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns an SVMModel that can be used to classify previously unseen data.
Throws SVMException on error
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->

View file

@ -0,0 +1,112 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<phpdoc:classref xml:id="class.svmexception" xmlns:phpdoc="http://php.net/ns/phpdoc" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude">
<title>The SVMException class</title>
<titleabbrev>SVMException</titleabbrev>
<partintro>
<!-- {{{ svmexception intro -->
<section xml:id="svmexception.intro">
&reftitle.intro;
<para>
The exception object thrown on errors from the SVM and SVMModel classes.
</para>
</section>
<!-- }}} -->
<section xml:id="svmexception.synopsis">
&reftitle.classsynopsis;
<!-- {{{ Synopsis -->
<classsynopsis>
<ooclass><classname>SVMException</classname></ooclass>
<!-- {{{ Class synopsis -->
<classsynopsisinfo>
<ooclass>
<classname>SVMException</classname>
</ooclass>
<ooclass>
<modifier>extends</modifier>
<classname>Exception</classname>
</ooclass>
</classsynopsisinfo>
<!-- }}} -->
<classsynopsisinfo role="comment">Properties</classsynopsisinfo>
<classsynopsisinfo role="comment">Methods</classsynopsisinfo>
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.svmexception')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[1])" />
<classsynopsisinfo role="comment">Inherited methods</classsynopsisinfo>
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.exception')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[1])" />
</classsynopsis>
<!-- }}} -->
</section>
<!-- {{{ svmexception properties -->
<section xml:id="svmexception.props">
&reftitle.properties;
<variablelist>
<varlistentry xml:id="svmexception.props.message">
<term><varname>message</varname></term>
<listitem>
<para></para>
</listitem>
</varlistentry>
<varlistentry xml:id="svmexception.props.code">
<term><varname>code</varname></term>
<listitem>
<para></para>
</listitem>
</varlistentry>
<varlistentry xml:id="svmexception.props.file">
<term><varname>file</varname></term>
<listitem>
<para></para>
</listitem>
</varlistentry>
<varlistentry xml:id="svmexception.props.line">
<term><varname>line</varname></term>
<listitem>
<para></para>
</listitem>
</varlistentry>
</variablelist>
</section>
<!-- }}} -->
</partintro>
&reference.svm.entities.svmexception;
</phpdoc:classref>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->

View file

@ -0,0 +1,67 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<phpdoc:classref xml:id="class.svmmodel" xmlns:phpdoc="http://php.net/ns/phpdoc" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude">
<title>The SVMModel class</title>
<titleabbrev>SVMModel</titleabbrev>
<partintro>
<!-- {{{ svmmodel intro -->
<section xml:id="svmmodel.intro">
&reftitle.intro;
<para>
The SVMModel is the end result of the training process. It can be used to classify previously unseen data.
</para>
</section>
<!-- }}} -->
<section xml:id="svmmodel.synopsis">
&reftitle.classsynopsis;
<!-- {{{ Synopsis -->
<classsynopsis>
<ooclass><classname>SVMModel</classname></ooclass>
<!-- {{{ Class synopsis -->
<classsynopsisinfo>
<ooclass>
<classname>SVMModel</classname>
</ooclass>
</classsynopsisinfo>
<!-- }}} -->
<classsynopsisinfo role="comment">Methods</classsynopsisinfo>
<xi:include xpointer="xmlns(db=http://docbook.org/ns/docbook) xpointer(id('class.svmmodel')/db:refentry/db:refsect1[@role='description']/descendant::db:methodsynopsis[1])" />
</classsynopsis>
<!-- }}} -->
</section>
</partintro>
&reference.svm.entities.svmmodel;
</phpdoc:classref>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->

View file

@ -0,0 +1,75 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="svmmodel.construct" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>SVMModel::__construct</refname>
<refpurpose>Construct a new SVMModel</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<methodname>SVMModel::__construct</methodname>
<methodparam choice="opt"><type>string</type><parameter>filename</parameter></methodparam>
</methodsynopsis>
<para>
Build a new SVMModel. Models will usually be created from the SVM::train function, but then saved models may be restored directly.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>filename</parameter></term>
<listitem>
<para>
The filename for the saved model file this model should load.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Throws SVMException on error
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><methodname>SVMModel::load</methodname></member>
</simplelist>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->

View file

@ -0,0 +1,76 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="svmmodel.load" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>SVMModel::load</refname>
<refpurpose>Load a saved SVM Model</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>boolean</type><methodname>SVMModel::load</methodname>
<methodparam><type>string</type><parameter>filename</parameter></methodparam>
</methodsynopsis>
<para>
Load a model file ready for classification or regression.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>filename</parameter></term>
<listitem>
<para>
The filename of the model.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Throws SVMException on error.
Returns true on success.
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><methodname>SVMModel::save</methodname></member>
</simplelist>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->

View file

@ -0,0 +1,77 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="svmmodel.predict" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>SVMModel::predict</refname>
<refpurpose>Predict a value for previously unseen data</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>float</type><methodname>SVMModel::predict</methodname>
<methodparam><type>array</type><parameter>data</parameter></methodparam>
</methodsynopsis>
<para>
This function accepts an array of data and attempts to predict the class or regression value based on the model extracted from previously trained data.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>data</parameter></term>
<listitem>
<para>
The array to be classified. This should be a series of key => value pairs in increasing key order, but not necessarily continuous.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Float the predicted value. This will be a class label in the case of classification, a real value in the case of regression.
Throws SVMException on error
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><methodname>SVM::train</methodname></member>
</simplelist>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->

View file

@ -0,0 +1,76 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="svmmodel.save" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>SVMModel::save</refname>
<refpurpose>Save a model to a file</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>boolean</type><methodname>SVMModel::save</methodname>
<methodparam><type>string</type><parameter>filename</parameter></methodparam>
</methodsynopsis>
<para>
Save the model data to a file, for later use.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>filename</parameter></term>
<listitem>
<para>
The file to save the model to.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Throws SVMException on error.
Returns true on success.
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><methodname>SVMModel::load</methodname></member>
</simplelist>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->

View file

@ -0,0 +1,48 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!--
Do NOT translate this file
-->
<versions>
<!-- Methods -->
<function name='svm::__construct' from='PECL svm &gt;= 0.1.0'/>
<function name='svm::getoptions' from='PECL svm &gt;= 0.1.0'/>
<function name='svm::setoptions' from='PECL svm &gt;= 0.1.0'/>
<function name='svm::train' from='PECL svm &gt;= 0.1.0'/>
<function name='svm::crossvalidate' from='PECL svm &gt;= 0.1.0'/>
<function name='svmmodel::__construct' from='PECL svm &gt;= 0.1.0'/>
<function name='svmmodel::save' from='PECL svm &gt;= 0.1.0'/>
<function name='svmmodel::load' from='PECL svm &gt;= 0.1.00.1.0'/>
<function name='svmmodel::predict' from='PECL svm &gt;= 0.1.0'/>
<function name='svmexception::__clone' from='PECL svm &gt;= 0.1.0'/>
<function name='svmexception::__construct' from='PECL svm &gt;= 0.1.0'/>
<function name='svmexception::getmessage' from='PECL svm &gt;= 0.1.0'/>
<function name='svmexception::getcode' from='PECL svm &gt;= 0.1.0'/>
<function name='svmexception::getfile' from='PECL svm &gt;= 0.1.0'/>
<function name='svmexception::getline' from='PECL svm &gt;= 0.1.0'/>
<function name='svmexception::gettrace' from='PECL svm &gt;= 0.1.0'/>
<function name='svmexception::gettraceasstring' from='PECL svm &gt;= 0.1.0'/>
<function name='svmexception::__tostring' from='PECL svm &gt;= 0.1.0'/>
</versions>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->