svMathematica: A Machine Learning Mathematica package
svMathematica is a Wolfram Mathematica package implementing support vector-based learning algorithms.
Download the latest release
svMathematica-1.0Latest News
Jul 6th, 2009: svMathematica 1.0 is available for download.Install instructions
Download and uncompress the package in a directory contained in Mathematica's $Path variable. Suggested choices for a user-based installation are as in the
following table:
| OS | Directory |
|---|---|
| Mac OS X | ~/Library/Mathematica/Applications |
| Linux | ~/.Mathematica/Applications |
where ~ denotes the user's home directory in Mac OS X and Linux.
Analogously, suggested choices for a system-wide installation are as follows:
| OS | Directory |
|---|---|
| Mac OS X | /Library/Mathematica/Applications |
| Linux | ~/AddOns/Applications |
where ~ denotes the Mathematica root directory.
The algorithms implemented in svMathemtica are based on external solvers that must be previouvsly installed in the correct location. In brackets there are my default locations.
(/usr/local/bin)(/usr/local/bin)/opt/local/bin
Using the package
The package is loaded as follows
<<svMathematica`
The graphics routines to plot samples are: svmClassificationSamplePlot and svmRegressionSamplePlot. The first one plots classification samples and the second one is for regression samples.
grClassPoints = svmClassificationSamplePlot[pattern, label,Frame -> True]
grRegrPoints = svmRegressionSamplePlot[pattern, label, Frame ->True]
There are also routines to plot the classifier function or the regression function, respectively (The first argument in both routines will be explained after this example):
grClassifier = svmDecisionFunctionPlot[classifier, {x, 0, 1}, {y, 0, 1}, margin -> False];
Show[grClassPoints,grClassifier]
grRegressor = Plot[regressor, {x, 0, 1}, PlotRange -> All, AspectRatio -> 1/GoldenRatio, Frame -> True];
Show[grRegrPoints,grRegressor]
To get the classification function the routine is:
classifier = svmClassification[pattern, label, implementation -> svmClassificationPython, kernel -> "linear"]
Function[{svMathematica`Private`q$}, -1.09075 - 39.8389 {0.12426, 0.0648096}.svMathematica`Private`q$ + 50.1273 {0.222514, 0.326598}.svMathematica`Private`q$ - 10.2883 {0.996295, 0.450105}.svMathematica`Private`q$]
To get the regression function the routine is (kernel options is set for using a Gaussian kernel of parameter 0.4):
regressor = svmRegression[pattern, label, kernel -> {"Gaussian",0.4}];
>> Output suppressed here because it's too long <<
To know what options are provided by routines use Options:
Options[svmClassification]
{c -> \[Infinity], kernel -> "linear", bVarThreshold -> 0.0001,
implementation -> svmClassificationPython, verbose -> False,
classifierOutput -> "real", classifierInput -> "pattern"}
Send comments to malchiodi[at]dsi[dot]unimi[dot]it.
Dario Malchiodi