This section includes information for using the pure Python API of bob.learn.linear.
Database specifications for an evaluation protocol based on the Iris Flower databases from Fisher’s original work.
Returns the data subset given a particular protocol
Parameters
protocol (string): one of the valid protocols supported by this interface
subset (string): one of ‘train’ or ‘test’
- classes (list of string): a list of strings containing the names of the
- classes from which you want to have the data from
- variables (list of strings): a list of strings containg the names of the
- variables (features) you want to have data from
Returns:
- data (numpy.ndarray): The data for all the classes and variables nicely
- packed into one numpy 3D array. One depth represents the data for one class, one row is one example, one column a given feature.
A simple pre-processing that applies Z-normalization to the input features
Estimates the mean and standard deviation from a data set
Parameters:
- X (numpy.ndarray): A 2D numpy ndarray in which the rows represent examples
- while the columns, features of the data you want to estimate normalization parameters on
Returns:
- numpy.ndarray: A 1D numpy ndarray containing the estimated mean over
- dimension 1 (columns) of the input data X
- numpy.ndarray: A 1D numpy ndarray containing the estimated unbiased
- standard deviation over dimension 1 (columns) of the input data X
Applies the given norm to the input data set
Parameters:
- X (numpy.ndarray): A 3D numpy ndarray in which the rows represent examples
- while the columns, features of the data set you want to normalize. Every depth corresponds to data for a particular class
- norm (tuple): A tuple containing two 1D numpy ndarrays corresponding to the
- normalization parameters extracted with estimated_norm() above.
Returns:
- numpy.ndarray: A 3D numpy ndarray with the same dimensions as the input
- array X, but with its values normalized according to the norm input.
Helper function that generates a single 1D numpy.ndarray with labels which are good targets for stock logistic regression.
Parameters:
- X (numpy.ndarray): The input data matrix. This must be a numpy.ndarray
- with 3 dimensions or an iterable containing 2 numpy.ndarrays with 2 dimensions each. Each correspond to the data for one of the two classes, every row corresponds to one example of the data set, every column, one different feature.
Returns:
- numpy.ndarray: With a single dimension, containing suitable labels for all
- rows and for all classes defined in X (depth).
Helper function to add a bias column to the input array X
Parameters:
- X (numpy.ndarray): The input data matrix. This must be a numpy.ndarray
- with 2 dimension wheres every row corresponds to one example of the data set, every column, one different feature.
Returns:
- numpy.ndarray: The same input matrix X with an added (prefix) column of
- ones.
A class to handle all run-time aspects for Multiclass Log. Regression
Parameters:
- machines (iterable): An iterable over any number of machines that will be
- stored.
Predicts the class of each row of X
Parameters:
- X (numpy.ndarray): The input data matrix. This must be a numpy.ndarray
- with 3 dimensions or an iterable containing 2 numpy.ndarrays with 2 dimensions each. Each correspond to the data for one of the two classes, every row corresponds to one example of the data set, every column, one different feature.
Returns:
- numpy.ndarray: A 1D numpy.ndarray with as many entries as rows in the
- input 2D array X, representing g(x), the class predictions for the current machine.
A class to handle all training aspects for Multiclass Log. Regression
Parameters:
regularizer (float): A regularization parameter
Trains multiple logistic regression classifiers to handle the multiclass problem posed by X
- X (numpy.ndarray): The input data matrix. This must be a numpy.ndarray
- with 3 dimensions or an iterable containing 2 numpy.ndarrays with 2 dimensions each. Each correspond to the data for one of the input classes, every row corresponds to one example of the data set, every column, one different feature.
Returns:
Machine: A trained multiclass machine.
Calculates the classification error rate for an N-class classification problem
Parameters: