DiscriminantAnalysis
Some words about DiscriminantAnalysis.
Available optimizations
There are currently no optimizations available for DiscriminantAnalysis models. Check out Extending fastinference on how to add an optimization!
The DiscriminantAnalysis object
- class fastinference.models.DiscriminantAnalysis.DiscriminantAnalysis(classes, n_features, accuracy=None, name='Model')
Placeholder class for all discriminant analysis models. Currently targeted towards scikit-learns QuadraticDiscriminantAnalysis.
- __init__(classes, n_features, accuracy=None, name='Model')
Constructor of this DiscriminantAnalysis.
- Parameters
classes (list of int) – The class mappings. Each enty maps the given entry to the corresponding index so that the i-th output of the model belongs to class classes[i]. For example with classes = [1,0,2] the second output of the model maps to class 0, the first output to class 1 and the third output to class 2. n_features (int): The number of features this model was trained on.
accuracy (float, optional) – The accuracy of this tree on some test data. Can be used to verify the correctness of the implementation. Defaults to None.
name (str, optional) – The name of this model. Defaults to “Model”.
- classmethod from_dict(data)
Generates a new DiscriminantAnalysis from the given dictionary. It is assumed that the ensemble has previously been stored with the
DiscriminantAnalysis.to_dict()
method.- Parameters
data (dict) – The dictionary from which this DiscriminantAnalysis should be generated.
- Returns
The newly generated DiscriminantAnalysis classifier.
- Return type
- classmethod from_sklearn(sk_model, name='Model', accuracy=None)
Generates a new DiscriminantAnalysis from an sklearn QuadraticDiscriminantAnalysis.
- Parameters
sk_model (QuadraticDiscriminantAnalysis) – A scikit-learn QuadraticDiscriminantAnalysis object.
name (str, optional) – The name of this model. Defaults to “Model”.
accuracy (float, optional) – The accuracy of this tree on some test data. Can be used to verify the correctness of the implementation. Defaults to None.
- Returns
The newly generated DiscriminantAnalysis object.
- Return type
- predict_proba(X)
Applies this DiscriminantAnalysis model to the given data and provides the predicted probabilities for each example in X.
- Parameters
X (numpy.array) – A (N,d) matrix where N is the number of data points and d is the feature dimension. If X has only one dimension then a single example is assumed and X is reshaped via
X = X.reshape(1,X.shape[0])
- Returns
A (N, c) prediction matrix where N is the number of data points and c is the number of classes
- Return type
numpy.array
- to_dict()
Stores this DiscriminantAnalysis model as a dictionary which can be loaded with
DiscriminantAnalysis.from_dict()
.- Returns
The dictionary representation of this DiscriminantAnalysis model.
- Return type
dict