.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Algorithm::SVM::DataSet 3pm" .TH Algorithm::SVM::DataSet 3pm "2020-11-08" "perl v5.32.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Algorithm::SVM::DataSet \- A DataSet object for the Algorithm::SVM Support Vector Machine. .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use Algorithm::SVM::DataSet; \& \& # Create a new dataset. \& $ds = new Algorithm::SVM::DataSet(Label => 1, \& Data => [ 0.12, 0.25, 0.33, 0.98 ]); \& \& # Retrieve/set the label. \& $label = $ds\->label(); \& $ds\->label(1976); \& \& # Retrieve/set the attribute with an index of 0. \& $attr = $ds\->attribute(0); \& $ds\->attribute(0, 0.2621); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Algorithm::SVM::DataSet is a representation of the datasets passed to Algorithm::SVM object for training or classification. Each dataset has an associated label, which classifies it as being part of a specific group. A dataset object also has one or more key/value pairs corresponding to the attributes that will be used for classification. Values equal to zero will not be stored, and are returned by default if no key/value pair exists. This sparse format saves memory, and is treated in exactly the same way by libsvm. .SH "CONSTRUCTORS" .IX Header "CONSTRUCTORS" .Vb 2 \& $ds = new Algorithm::SVM::DataSet(Label => 1, \& Data => [ 0.12, 0.25, 0.33, 0.98 ]); .Ve .PP The Algorithm::SVM::DataSet constructor accepts two optional named parameters: Label and Data. Label is used to set the class to which the dataset belongs, and Data is used to set any initial values. Data should be an arrayref of numerical values. Each value in the arrayref is assumed to have a key corresponding to its index in the array. .PP .Vb 2 \& ie) In the above example, 0.12 has a key of 0, 0.25 has a key of 1, \& 0.33 has a key of 2, etc. .Ve .SH "METHODS" .IX Header "METHODS" .Vb 2 \& $label = $ds\->label(); \& $ds\->label(1976); .Ve .PP The label method is used to set or retrieve the DataSets label value. Parameters and return values should be numeric values. .PP .Vb 2 \& $attr = $ds\->attribute(0); \& $ds\->attribute(0, 0.2621); .Ve .PP The attribute method is used to set dataset attribute values. If a single value is provided, the method will return the corresponding value. If two value are provided, the method will set the first parameter to the value of the second. .PP .Vb 1 \& $ds\->asArray(); .Ve .PP The asArray method returns the contents of a DataSet object in an efficient way. An optional parameter, \f(CW$numAttr\fR, can be used to pad the array with zeros if the number of attributes is not known from the beginning (e.g. when creating a word vector on the fly, since all keys not given are automatically assumed to be zero) .SH "MAINTAINER" .IX Header "MAINTAINER" Matthew Laird Alexander K. Seewald .SH "SEE ALSO" .IX Header "SEE ALSO" Algorithm::SVM