'Transform data to polynomial features
Parameters
X : array-like, shape [n_samples, n_features]
The data to transform, row by row.
Returns
XP : np.ndarray shape [n_samples, NP]
The matrix of features, where NP is the number of polynomial
features generated from the combination of inputs.'

def transform(self, X):

    check_is_fitted(self, ['n_input_features_', 'n_output_features_'])
    X = check_array(X, dtype=FLOAT_DTYPES)
    (n_samples, n_features) = X.shape
    if (n_features != self.n_input_features_):
        raise ValueError('X    shape    does    not    match    training    shape')
    XP = np.empty((n_samples, self.n_output_features_), dtype=X.dtype)
    combinations = self._combinations(n_features, self.degree, self.interaction_only, self.include_bias)
    for (i, c) in enumerate(combinations):
        XP[:, i] = X[:, c].prod(1)
    return XP
