You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.pod
+61-54Lines changed: 61 additions & 54 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,11 +1,12 @@
1
1
=head1 NAME
2
2
3
-
Algorithm::LibLinear - A Perl binding for LIBLINEAR, a library for classification/regressionusing linear SVM and logistic regression.
3
+
Algorithm::LibLinear - A Perl binding for LIBLINEAR, a library for classification, regression, and outlier detection using linear Support Vector Machines (SVM) and logistic regression
4
4
5
5
=head1 SYNOPSIS
6
6
7
7
use Algorithm::LibLinear;
8
-
# Constructs a model for L2-regularized L2 loss support vector classification.
8
+
9
+
# Instantiate a learner for L2-regularized L2-loss support vector classification (SVC).
9
10
my $learner = Algorithm::LibLinear->new(
10
11
cost => 1,
11
12
epsilon => 0.01,
@@ -15,15 +16,20 @@ Algorithm::LibLinear - A Perl binding for LIBLINEAR, a library for classificatio
15
16
+{ label => -1, weight => 1, },
16
17
],
17
18
);
18
-
# Loads a training data set from DATA filehandle.
19
+
20
+
# Load a training dataset from the DATA filehandle.
19
21
my $data_set = Algorithm::LibLinear::DataSet->load(fh => \*DATA);
Constructor. You can set several named parameters:
53
+
Constructor. Accepts the following optional named parameters, also accessible via getter methods of the same name.
48
54
49
55
=over 4
50
56
51
57
=item bias
52
58
53
-
Bias term to be added to prediction result (i.e., C<-B> option for LIBLINEAR's C<train> command.).
54
-
55
-
This parameter makes sense only when its value is positive.
59
+
The bias term added to feature vectors (corresponding to the C<-B> option of the LIBLINEAR C<train> command). This term is active only when its value is positive.
56
60
57
61
=item cost
58
62
59
-
Penalty cost for misclassification (C<-c>.)
63
+
The penalty parameter C (corresponding to the C<-c> option).
60
64
61
65
=item epsilon
62
66
63
-
Termination criterion (C<-e>.)
64
-
65
-
Default value of this parameter depends on the value of C<solver>.
67
+
The tolerance of the termination criterion (corresponding to the C<-e> option). The default depends on the chosen C<solver>.
66
68
67
69
=item loss_sensitivity
68
70
69
-
Epsilon in loss function of SVR (C<-p>.)
71
+
The epsilon parameter (p) in the loss function of Support Vector Regression (SVR), corresponding to the C<-p> option.
70
72
71
73
=item nu
72
74
73
-
Nu parameter of one-class SVM (C<-n>.)
75
+
The nu parameter for one-class SVM (corresponding to the C<-n> option).
74
76
75
77
=item regularize_bias
76
78
77
-
Whether to regularize the bias term (C<-R>, negated.)
79
+
A boolean indicating whether to include the bias term in regularization (corresponding to the negation of the C<-R> option). Defaults to true.
80
+
81
+
=item recalculate_weights
82
+
83
+
A boolean indicating whether to recalculate class weights dynamically. This option is valid only for the dual solvers of L2-regularized L1- or L2-loss Support Vector Classifiers (C<L2R_L1LOSS_SVC_DUAL> and C<L2R_L2LOSS_SVC_DUAL>).
78
84
79
85
=item solver
80
86
81
-
Kind of solver (C<-s>.)
87
+
The solver type to use (corresponding to the C<-s> option).
Weights to adjust the cost parameter of different classes (C<-wi>.)
133
+
An array reference used to adjust the penalty cost for specific classes (corresponding to the C<-wi> option).
128
134
129
-
For example,
135
+
For example:
130
136
131
137
my $learner = Algorithm::LibLinear->new(
132
138
weights => [
133
139
+{ label => 1, weight => 0.5 },
134
-
+{ label => 2, weight => 1 },
140
+
+{ label => 2, weight => 1.0 },
135
141
+{ label => 3, weight => 0.5 },
136
142
],
137
143
);
138
144
139
-
is giving a doubling weight for class 2. This means that samples belonging to class 2 have stronger effect than other samples belonging class 1 or 3 on learning.
145
+
This configuration doubles the penalty weight for class 2, making samples belonging to class 2 have twice the influence on training compared to those in classes 1 or 3.
140
146
141
-
This option is useful when the number of training samples of each class is not balanced.
147
+
This option is particularly useful for addressing class imbalance in the training dataset.
Evaluates training parameter using N-fold cross validation method.
148
-
Given data set will be split into N parts. N-1 of them will be used as a training set and the rest 1 part will be used as a test set.
149
-
The evaluation iterates N times using each different part as a test set. Then average accuracy is returned as result.
153
+
Evaluates training performance using N-fold cross-validation.
154
+
The dataset is partitioned into N equal-sized folds. For each fold, the model is trained on the remaining N-1 folds and evaluated on the held-out fold.
155
+
156
+
Returns the average classification accuracy for classification solvers, or the mean squared error (MSE) for regression solvers.
Shorthand alias for C<find_parameters> only works on C<cost> parameter.
156
-
Notice that C<loss_sensitivity> is affected too when C<update> is set.
162
+
A convenience wrapper around C<find_parameters> that tunes only the C<cost> parameter. Note that if C<update> is enabled, the C<loss_sensitivity> parameter may also be updated in the process.
Finds the best parameters by N-fold cross validation. If C<initial_cost> or C<initial_loss_sensitivity> is a negative, the value is automatically calculated.
161
-
Works only for 3 solvers: C<'L2R_LR'>, C<'L2R_L2LOSS_SVC'> and C<'L2R_L2LOSS_SVR'>. Error will be thrown for otherwise.
166
+
Finds the optimal hyperparameters using N-fold cross-validation. If C<initial_cost> or C<initial_loss_sensitivity> is negative, its optimal value is automatically determined.
167
+
168
+
This method is supported only by the C<'L2R_LR'>, C<'L2R_L2LOSS_SVC'>, and C<'L2R_L2LOSS_SVR'> solvers. It throws an exception if called when using any other solver.
162
169
163
-
When C<update> is set true, the instance is updated to use the found parameters. This behaviour is disabled by default.
170
+
If the C<update> parameter is true, the learner instance is updated in-place with the discovered parameters. This is disabled by default.
164
171
165
-
Return value is an ArrayRef containing 3 values: found C<cost>, found C<loss_sensitivity> (only if solver is C<'L2R_L2LOSS_SVR'>) and mean accuracy of cross validation with the found parameters.
172
+
Returns an array reference containing three elements: the optimal C<cost>, the optimal C<loss_sensitivity> (which is C<undef> unless the solver is C<'L2R_L2LOSS_SVR'>), and the evaluation metric (average accuracy or MSE) achieved with these parameters.
166
173
167
174
=head2 train(data_set => $data_set)
168
175
169
-
Executes training and returns a trained L<Algorithm::LibLinear::Model> instance.
170
-
C<data_set> is same as the C<cross_validation>'s.
176
+
Trains a model on the provided dataset and returns an L<Algorithm::LibLinear::Model> instance.
177
+
The C<data_set> argument must be an L<Algorithm::LibLinear::DataSet> instance.
0 commit comments