Algori...DataSet(3pm)

πŸ’– Algori...DataSet(3pm) β€” User Contributed Perl Documentation πŸ’–

okay bestie, sit DOWN, because this is the little data-holder object that feeds your Support Vector Machine. it's from Algorithm::SVM, it's a Perl module, and honestly? it's giving quiet-supportive-bestie energy. she holds the data, she holds the label, she does not complain. πŸŽ€


✨ NAME ✨

Algorithm::SVM::DataSet β€” a DataSet object for the Algorithm::SVM Support Vector Machine. no cap, that's literally her whole job description. πŸ’…


🌈 SYNOPSIS 🌈

here's the vibe in code form, bestie:

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);

like… she's little. she's cute. she's carrying your entire classification problem on her back. πŸ™ˆ


πŸ¦‹ DESCRIPTION πŸ¦‹

so Algorithm::SVM::DataSet is the representation of the datasets you hand over to an Algorithm::SVM object β€” for training or for classification. main character data storage, fr fr. πŸ’–

every dataset has an associated label, and that label is what classifies it as part of a specific group. so like… she knows what team she's on. πŸ‘‘

and a dataset object also has one or more key/value pairs corresponding to the attributes that will be used for classification. it's a whole little dictionary of vibes, one number at a time. ✨

⚠️ okay important, do not skip this: values equal to zero will not be stored, and they're returned by default if no key/value pair exists. it's a sparse format, and it's out here saving memory like an absolute icon. libsvm treats it in exactly the same way, so you're not being weird β€” you're being efficient. periodt. πŸ’…

πŸŽ€ CONSTRUCTORS πŸŽ€

the moment of creation, bestie:

$ds = new Algorithm::SVM::DataSet(Label => 1,
                                  Data  => [ 0.12, 0.25, 0.33, 0.98 ]);

the Algorithm::SVM::DataSet constructor takes two optional named parameters: Label and Data.

  • Label β€” sets the class this dataset belongs to. yes, she needs to know her people. 🫢
  • Data β€” sets any initial values. it should be an arrayref of numerical values, and every value inside that arrayref is assumed to have a key that corresponds to its index in the array.

so, lowkey the cutest part:

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.

index go brrr, keys assign themselves, no extra work from you. we love a self-sufficient queen. 🌸


πŸ’… METHODS πŸ’…

the label method

$label = $ds->label();
$ds->label(1976);

the label method is how you set or retrieve the DataSets label value. parameters and return values should be numeric values. that's it, that's the whole method. simple, iconic, does what it says. ⭐

the attribute method

$attr = $ds->attribute(0);
$ds->attribute(0, 0.2621);

the attribute method is used to set dataset attribute values, and she's a dual-threat girly:

  • give her a single value and she returns the corresponding value. handing it to you. no notes. 🎁
  • give her two values and she sets the first parameter to the value of the second. glow-up achieved. ✨

the asArray method

$ds->asArray();

the asArray method returns the contents of a DataSet object in an efficient way. queen of optimization, we stan. πŸ”₯

there's an optional parameter, $numAttr, and you can use it to pad the array with zeros when the number of attributes isn't known from the beginning. for example, when you're creating a word vector on the fly, since all keys not given are automatically assumed to be zero. mystery keys? zero. absent keys? still zero. she fills in the blanks for you, bestie. πŸ’œ


🌟 MAINTAINER 🌟

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

shoutout to the maintainers, keeping the lights on since forever. 🫢


πŸ‘€ SEE ALSO πŸ‘€

  • Algorithm::SVM β€” go read it, bestie, this DataSet only makes sense next to her.

and that's the whole page, fr fr. this was perl v5.42.3, dated 2026-08-19, and it's part of the User Contributed Perl Documentation, delivered to you with so much love. go build something cute with it. mwah. πŸ˜­πŸ’–πŸŽ€πŸ¦‹βœ¨

πŸ“¦ where this page comes from