Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions reference/svm/book.xml
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- State: experimental -->

<book xml:id="book.svm" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<book xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="book.svm">
<?phpdoc extension-membership="pecl" ?>
<title>Support Vector Machine</title>
<titleabbrev>SVM</titleabbrev>

<preface xml:id="intro.svm">
&reftitle.intro;
<para>
<simpara>
&warn.experimental;
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>
</simpara>
</preface>

&reference.svm.setup;
Expand All @@ -23,7 +22,6 @@
&reference.svm.svmmodel;

</book>

<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
Expand Down
9 changes: 3 additions & 6 deletions reference/svm/configure.xml
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
<?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">
<section xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="svm.installation">
&reftitle.install;

<para>
<simpara>
&pecl.info;
<link xlink:href="&url.pecl.package;svm">&url.pecl.package;svm</link>
</para>
</simpara>

</section>


<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
Expand Down
81 changes: 39 additions & 42 deletions reference/svm/examples.xml
Original file line number Diff line number Diff line change
@@ -1,52 +1,51 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->

<chapter xml:id="svm.examples" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<chapter xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="svm.examples">
&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 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,
<simpara>
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.
</simpara>
<simpara>
Data is supplied in either a file, a stream, or as 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>
</simpara>
<simpara>
-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
</simpara>
<simpara>
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
</simpara>
<simpara>
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 =&gt; value sets for the
feature values pairs.
</para>
<para>
This data is passed to the SVM class's train function, which will return an
</simpara>
<simpara>
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>
</simpara>
<simpara>
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.
</simpara>
<simpara>
Models can be saved and restored as required, using the save and load
functions, which both take a file location.
</simpara>
<para>
<example>
<title>Train from array</title>
Expand Down Expand Up @@ -88,7 +87,6 @@ $model = $svm->train("traindata.txt");
</example>
</para>
</chapter>

<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
Expand All @@ -109,4 +107,3 @@ vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->

16 changes: 7 additions & 9 deletions reference/svm/setup.xml
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
<?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">
<chapter xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="svm.setup">
&reftitle.setup;

<section xml:id="svm.requirements">
&reftitle.required;
<para>
<simpara>
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>
</simpara>
<screen>
<![CDATA[
wget http://www.csie.ntu.edu.tw/~cjlin/cgi-bin/libsvm.cgi?+http://www.csie.ntu.edu.tw/~cjlin/libsvm+tar.gz
Expand All @@ -27,21 +26,20 @@ ldconfig --print | grep libsvm
]]>
</screen>

<para>
<simpara>
This last step should show libsvm is installed.
</para>
</simpara>
</section>

<section xml:id="svm.installation">
&reftitle.install;
<para>
<simpara>
&pecl.info;
<link xlink:href="&url.pecl.package;svm">&url.pecl.package;svm</link>
</para>
</simpara>
</section>

</chapter>

<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
Expand Down
Loading
Loading