Bio.LogisticRegression module

Code for doing logistic regressions.

Classes:
  • LogisticRegression Holds information for a LogisticRegression classifier.

Functions:
  • train Train a new classifier.

  • calculate Calculate the probabilities of each class, given an observation.

  • classify Classify an observation into a class.

class Bio.LogisticRegression.LogisticRegression

Bases: object

Holds information necessary to do logistic regression classification.

Attributes:
  • beta - List of the weights for each dimension.

__init__(self)

Initialize.

Bio.LogisticRegression.train(xs, ys, update_fn=None, typecode=None)

Train a logistic regression classifier on a training set.

Argument xs is a list of observations and ys is a list of the class assignments, which should be 0 or 1. xs and ys should contain the same number of elements. update_fn is an optional callback function that takes as parameters that iteration number and log likelihood.

Bio.LogisticRegression.calculate(lr, x)

Calculate the probability for each class.

Arguments:
  • lr is a LogisticRegression object.

  • x is the observed data.

Returns a list of the probability that it fits each class.

Bio.LogisticRegression.classify(lr, x)

Classify an observation into a class.