<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Create a SVMModel based on training data</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="svm.setoptions.html">SVM::setOptions</a></div> <div class="next" style="text-align: right; float: right;"><a href="class.svmmodel.html">SVMModel</a></div> <div class="up"><a href="class.svm.html">SVM</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="svm.train" class="refentry"> <div class="refnamediv"> <h1 class="refname">SVM::train</h1> <p class="verinfo">(PECL svm >= 0.1.0)</p><p class="refpurpose"><span class="refname">SVM::train</span> — <span class="dc-title">Create a SVMModel based on training data</span></p> </div> <div class="refsect1 description" id="refsect1-svm.train-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="modifier">public</span> <span class="type"><a href="class.svmmodel.html" class="type SVMModel">SVMModel</a></span> <span class="methodname"><strong>svm::train</strong></span> ( <span class="methodparam"><span class="type">array</span> <code class="parameter">$problem</code></span> [, <span class="methodparam"><span class="type">array</span> <code class="parameter">$weights</code></span> ] )</div> <p class="para rdfs-comment"> Train a support vector machine based on the supplied training data. </p> </div> <div class="refsect1 parameters" id="refsect1-svm.train-parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><em><code class="parameter">problem</code></em></span> <dd> <p class="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. </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">weights</code></em></span> <dd> <p class="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. </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues" id="refsect1-svm.train-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns an SVMModel that can be used to classify previously unseen data. Throws SVMException on error </p> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="svm.setoptions.html">SVM::setOptions</a></div> <div class="next" style="text-align: right; float: right;"><a href="class.svmmodel.html">SVMModel</a></div> <div class="up"><a href="class.svm.html">SVM</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>