miml.classifier.mi.apr_classifier.APRClassifier

miml.classifier.mi.apr_classifier.APRClassifier#

class miml.classifier.mi.apr_classifier.APRClassifier#

Bases: object

Classifier for All-Positive Bags using Axis-Aligned Positive Region.

This classifier assigns a positive label to bags that contain instances within a predefined axis-parallel rectangle (APR) defined by the minimum and maximum feature values of positive instances in the training set.

Attributes#

aprlist[np.ndarray of shape (n_labels)]

List containing the minimum and maximum feature values defining the APR.

References#

Dietterich, Thomas G., Richard H. Lathrop, and Tomás Lozano-Pérez. “Solving the multiple instance problem with axis-parallel rectangles.” Artificial intelligence 89.1 (1997): 31-71.

fit(x_train: ndarray, y_train: ndarray) None#

Fit the classifier to the training data.

Parameters#

x_trainndarray of shape (n_bags, n_instances, n_features)

Features values of bags in the training set.

y_trainndarray (n_bags, n_instances, n_labels)

Labels of bags in the training set.

predict(bag: ndarray) int#

Predict the label of the bag

Parameters#

bag: np.ndarray of shape(n_instances, n_features)

Features values of a bag

Returns#

label: int

Predicted label of the bag

predict_proba(x_test: ndarray) ndarray#

Predict probabilities of given data of having a positive label

Parameters#

x_testnp.ndarray of shape (n_bags, n_instances, n_features)

Data to predict probabilities

Returns#

results: np.ndarray of shape (n_instances)

Predicted probabilities for given data