dynex_qboost package

Submodules

dynex_qboost.qboost module

class dynex_qboost.qboost.AllStumpsClassifier(X, y)[source]

Bases: dynex_qboost.qboost.EnsembleClassifier

Ensemble classifier with one decision stump for each feature.

class dynex_qboost.qboost.DecisionStumpClassifier(X, y, feature_index)[source]

Bases: object

Decision tree classifier that operates on a single feature with a single splitting rule.

The index of the feature used in the decision rule is stored relative to the original data frame.

predict(X)[source]

Predict class.

Parameters

X (array) – 2D array of feature vectors. Note that the array contains all features, while the weak classifier itself will make a prediction based only a single feature.

Returns

Array of class labels.

class dynex_qboost.qboost.EnsembleClassifier(weak_classifiers, weights, weak_classifier_scaling, offset=1e-09)[source]

Bases: object

Ensemble of weak classifiers.

fit_offset(X)[source]

Fit offset value based on class-balanced feature vectors.

Currently, this assumes that the feature vectors in X correspond to an even split between both classes.

get_selected_features()[source]

Return list of features corresponding to the selected weak classifiers.

predict(X)[source]

Compute ensemble prediction.

Note that this function returns the numerical value of the ensemble predictor, not the class label. The predicted class is sign(predict()).

predict_class(X)[source]

Compute ensemble prediction of class label.

score(X, y)[source]

Compute accuracy score on given data.

squared_error(X, y)[source]

Compute squared error between predicted and true labels.

Provided for testing purposes.

class dynex_qboost.qboost.QBoostClassifier(X, y, lam, weak_clf_scale=None, drop_unused=True, num_reads=10000, annealing_time=300, mainnet=True)[source]

Bases: dynex_qboost.qboost.EnsembleClassifier

Construct an ensemble classifier using quadratic loss minimization.

report_baseline(X, y)[source]

Report accuracy of weak classifiers.

This provides context for interpreting the performance of the boosted classifier.

dynex_qboost.qboost.qboost_lambda_sweep(X, y, lambda_vals, val_fraction=0.4, verbose=False, **kwargs)[source]

Run QBoost using a series of lambda values and check accuracy against a validation set.

Parameters
  • X (array) – 2D array of feature vectors.

  • y (array) – 1D array of class labels (+/- 1).

  • lambda_vals (array) – Array of values for regularization parameter, lambda.

  • val_fraction (float) – Fraction of given data to set aside for validation.

  • verbose (bool) – Print out diagnostic information to screen.

  • kwargs – Passed to QBoost.__init__.

Returns

QBoost instance with best validation score. lambda:

Lambda value corresponding to the best validation score.

Return type

QBoostClassifier

Module contents