1Algorithm::SVM::DataSetU(s3e)r Contributed Perl DocumentaAtligoonrithm::SVM::DataSet(3)
2
3
4

NAME

6       Algorithm::SVM::DataSet - A DataSet object for the Algorithm::SVM
7       Support Vector Machine.
8

SYNOPSIS

10         use Algorithm::SVM::DataSet;
11
12         # Create a new dataset.
13         $ds = new Algorithm::SVM::DataSet(Label => 1,
14                                           Data  => [ 0.12, 0.25, 0.33, 0.98 ]);
15
16         # Retrieve/set the label.
17         $label = $ds->label();
18         $ds->label(1976);
19
20         # Retrieve/set the attribute with an index of 0.
21         $attr = $ds->attribute(0);
22         $ds->attribute(0, 0.2621);
23

DESCRIPTION

25       Algorithm::SVM::DataSet is a representation of the datasets passed to
26       Algorithm::SVM object for training or classification.  Each dataset has
27       an associated label, which classifies it as being part of a specific
28       group.  A dataset object also has one or more key/value pairs
29       corresponding to the attributes that will be used for classification.
30       Values equal to zero will not be stored, and are returned by default if
31       no key/value pair exists. This sparse format saves memory, and is
32       treated in exactly the same way by libsvm.
33

CONSTRUCTORS

35        $ds = new Algorithm::SVM::DataSet(Label => 1,
36                                          Data  => [ 0.12, 0.25, 0.33, 0.98 ]);
37
38       The Algorithm::SVM::DataSet constructor accepts two optional named
39       parameters: Label and Data.  Label is used to set the class to which
40       the dataset belongs, and Data is used to set any initial values.  Data
41       should be an arrayref of numerical values.  Each value in the arrayref
42       is assumed to have a key corresponding to its index in the array.
43
44         ie) In the above example, 0.12 has a key of 0, 0.25 has a key of 1,
45             0.33 has a key of 2, etc.
46

METHODS

48         $label = $ds->label();
49         $ds->label(1976);
50
51       The label method is used to set or retrieve the DataSets label value.
52       Parameters and return values should be numeric values.
53
54         $attr = $ds->attribute(0);
55         $ds->attribute(0, 0.2621);
56
57       The attribute method is used to set dataset attribute values.  If a
58       single value is provided, the method will return the corresponding
59       value.  If two value are provided, the method will set the first
60       parameter to the value of the second.
61
62         $ds->asArray();
63
64       The asArray method returns the contents of a DataSet object in an
65       efficient way. An optional parameter, $numAttr, can be used to pad the
66       array with zeros if the number of attributes is not known from the
67       beginning (e.g. when creating a word vector on the fly, since all keys
68       not given are automatically assumed to be zero)
69

MAINTAINER

71       Matthew Laird <matt@brinkman.mbb.sfu.ca> Alexander K. Seewald
72       <alex@seewald.at>
73

SEE ALSO

75       Algorithm::SVM
76
77
78
79perl v5.28.1                      2006-01-15        Algorithm::SVM::DataSet(3)
Impressum