polylearn.PolynomialNetworkClassifier

class polylearn.PolynomialNetworkClassifier(degree=2, loss=’squared_hinge’, n_components=2, beta=1, tol=1e-06, fit_lower=’augment’, warm_start=False, max_iter=10000, verbose=False, random_state=None)[source]

Polynomial network for classification.

Parameters:

degree : int >= 2, default: 2

Degree of the polynomial. Corresponds to the order of feature interactions captured by the model. Currently only supports degrees up to 3.

loss : {‘logistic’|’squared_hinge’|’squared’}, default: ‘squared_hinge’

Which loss function to use.

  • logistic: L(y, p) = log(1 + exp(-yp))
  • squared hinge: L(y, p) = max(1 - yp, 0)²
  • squared: L(y, p) = 0.5 * (y - p)²

n_components : int, default: 2

Dimension of the lifted tensor.

beta : float, default: 1

Regularization amount for higher-order weights.

tol : float, default: 1e-6

Tolerance for the stopping condition.

fit_lower : {‘augment’|None}, default: ‘augment’

Whether and how to fit lower-order, non-homogeneous terms.

  • ‘augment’: adds a dummy column (1 everywhere) in order to capture

lower-order terms (including linear terms).

  • None: only learns weights for the degree given.

warm_start : boolean, optional, default: False

Whether to use the existing solution, if available. Useful for computing regularization paths or pre-initializing the model.

max_iter : int, optional, default: 10000

Maximum number of passes over the dataset to perform.

verbose : boolean, optional, default: False

Whether to print debugging information.

random_state : int seed, RandomState instance, or None (default)

The seed of the pseudo random number generator to use for initializing the parameters.

Attributes:

self.U_ : array, shape [n_components, n_features, degree]

The learned weights in the lifted tensor parametrization.

References

Polynomial Networks and Factorization Machines: New Insights and Efficient Training Algorithms. Mathieu Blondel, Masakazu Ishihata, Akinori Fujino, Naonori Ueda. In: Proceedings of ICML 2016. http://mblondel.org/publications/mblondel-icml2016.pdf

On the computational efficiency of training neural networks. Roi Livni, Shai Shalev-Shwartz, Ohad Shamir. In: Proceedings of NIPS 2014.

Methods

decision_function(X) Compute the output of the factorization machine before thresholding.
fit(X, y) Fit polynomial network to training data.
get_params([deep]) Get parameters for this estimator.
predict(X) Predict using the factorization machine
predict_proba(X) Compute probability estimates for the test samples.
score(X, y[, sample_weight]) Returns the mean accuracy on the given test data and labels.
set_params(**params) Set the parameters of this estimator.
__init__(degree=2, loss=’squared_hinge’, n_components=2, beta=1, tol=1e-06, fit_lower=’augment’, warm_start=False, max_iter=10000, verbose=False, random_state=None)[source]
decision_function(X)

Compute the output of the factorization machine before thresholding.

Parameters:

X : {array-like, sparse matrix}, shape = [n_samples, n_features]

Samples.

Returns:

y_scores : array, shape = [n_samples]

Returns predicted values.

fit(X, y)

Fit polynomial network to training data.

Parameters:

X : array-like or sparse, shape = [n_samples, n_features]

Training vectors, where n_samples is the number of samples and n_features is the number of features.

y : array-like, shape = [n_samples]

Target values.

Returns:

self : Estimator

Returns self.

get_params(deep=True)

Get parameters for this estimator.

Parameters:

deep : boolean, optional

If True, will return the parameters for this estimator and contained subobjects that are estimators.

Returns:

params : mapping of string to any

Parameter names mapped to their values.

predict(X)

Predict using the factorization machine

Parameters:

X : {array-like, sparse matrix}, shape = [n_samples, n_features]

Samples.

Returns:

y_pred : array, shape = [n_samples]

Returns predicted values.

predict_proba(X)

Compute probability estimates for the test samples.

Only available if loss=’logistic’.

Parameters:

X : {array-like, sparse matrix}, shape = [n_samples, n_features]

Samples.

Returns:

y_scores : array, shape = [n_samples]

Probability estimates that the samples are from the positive class.

score(X, y, sample_weight=None)

Returns the mean accuracy on the given test data and labels.

In multi-label classification, this is the subset accuracy which is a harsh metric since you require for each sample that each label set be correctly predicted.

Parameters:

X : array-like, shape = (n_samples, n_features)

Test samples.

y : array-like, shape = (n_samples) or (n_samples, n_outputs)

True labels for X.

sample_weight : array-like, shape = [n_samples], optional

Sample weights.

Returns:

score : float

Mean accuracy of self.predict(X) wrt. y.

set_params(**params)

Set the parameters of this estimator.

The method works on simple estimators as well as on nested objects (such as pipelines). The latter have parameters of the form <component>__<parameter> so that it’s possible to update each component of a nested object.

Returns:self :