Softmax Regression
An implementation of softmax regression for classification, which is a multiclass generalization of logistic regression.
Available Predicates
- initModelNoTrain/3
- initModelWithTrain/8
- classifyPoint/3
- classifyMatrix/8
- computeAccuracy/6
- featureSize/1
- parameters/3
- train/7
initModelNoTrain/3
Initializes the softmax_regression model without training.
Be sure to use Train before calling Classif or ComputeAccuracy, otherwise the results may be meaningless.
%% part of the predicate definition
initModelNoTrain( +integer, +integer,
+integer).
Parameters
Name | Type | Description | Default |
---|---|---|---|
inputSize | +integer | Size of the input feature vector. | 0 |
numClasses | +integer | Number of classes for classification. | 0 |
fitIntercept | +integer(bool) | add intercept term or not. | (0)false |
initModelWithTrain/8
Initializes the softmax_regression model and trains it.
%% part of the predicate definition
initModelWithTrain( +pointer(float_array), +integer, +integer,
+pointer(float_array), +integer,
+integer, +float32,
+integer).
Parameters
Name | Type | Description | Default |
---|---|---|---|
data | +matrix | Input training features. Each column associate with one sample. | - |
labels | +vector | Labels associated with the feature data. | - |
numClasses | +integer | Number of classes for classification. | 0 |
lambda | +float | L2-regularization constant. | 0.0001 |
fitIntercept | +integer(bool) | add intercept term or not. | (0)false |
classifyPoint/3
Classify the given point.
%% part of the predicate definition
classifyPoint( +pointer(float_array), +integer,
[-integer]).
Parameters
Name | Type | Description | Default |
---|---|---|---|
point | +vector | Point to be classified. | - |
predictedLabel | -integer | Predicted class label of the point. | - |
classifyMatrix/8
Classify the given points, returning class probabilities and predicted class label for each point.
%% part of the predicate definition
classifyMatrix( +pointer(float_array), +integer, +integer,
-pointer(float_array), -integer,
-pointer(float_array), -integer, -integer).
Parameters
Name | Type | Description | Default |
---|---|---|---|
data | +matrix | Matrix of data points to be classified. | - |
predictedLabels | -vector | Predicted labels for each point. | - |
probabilities | -matrix | Class probabilities for each point. | - |
computeAccuracy/6
Computes accuracy of the learned model given the feature data and the labels associated with each data point.
Predictions are made using the provided data and are compared with the actual labels.
%% part of the predicate definition
computeAccuracy( +pointer(float_array), +integer, +integer,
+pointer(float_array), +integer,
[-float32]).
Parameters
Name | Type | Description | Default |
---|---|---|---|
data | +matrix | Matrix of data points using which predictions are made. | - |
predictedLabels | -vector | Vector of labels associated with the data. | - |
accuracy | -float | - | - |
featureSize/1
Gets the features size of the training data.
%% part of the predicate definition
featureSize([-integer]).
Parameters
Name | Type | Description | Default |
---|---|---|---|
featureSize | -integer | Get the features size of the training data. | - |
parameters/3
Get the model parameters.
%% part of the predicate definition
parameters(-pointer(float_array), -integer, -integer).
Parameters
Name | Type | Description | Default |
---|---|---|---|
parameters | -matrix | Get the model parameters. | - |
train/7
Trains the softmax regression model with the given training data.
%% part of the predicate definition
train( +pointer(float_array), +integer, +integer,
+pointer(float_array), +integer,
+integer,
[-float32]).
Parameters
Name | Type | Description | Default |
---|---|---|---|
data | +matrix | Input training features. Each column associate with one sample. | - |
labels | +vector | Labels associated with the feature data. | - |
numClasses | +integer | Number of classes for classification. | 0 |
finalPointValue | -float | Objective value of final point | - |
Connected Links/Resources
If you want a more detailed explanation, then go to the python documentation. There is most of the time a good explanation on how the methods work and what the parameters do.
added some of the links from the python documentation