sebaba/utils.py
def map_polynomial_features(x, degree = 2):
    """
    Function to map variables into an n degree polynomial features

    Parameters
    --------------------------------------------------
        x     : ndarray of shape (n_samples, n_features)
        degree: int the nth degree polynomial to map features

    Returns
    --------------------------------------------------
        feature_map: ndarray of shape (n_samples, n_features quadratic terms)
    """
    m = x.shape[0]
    n = x.shape[1]
    x = np.hstack((np.ones((m, 1)), x))

    feature_map = list()
    for i in range(m):
        for k, v in enumerate(it.combinations_with_replacement(x[i], degree)):
            if k == 0:
                pass
            else:
                feature_map.append(np.product(v))

    return np.array(feature_map).reshape(m, -1)

    Function to map variables into an n degree polynomial features

    Parameters
    --------------------------------------------------
        x     : ndarray of shape (n_samples, n_features)
        degree: int the nth degree polynomial to map features

    Returns
    --------------------------------------------------
        feature_map: ndarray of shape (n_samples, n_features quadratic terms)
    
Function to map variables into an n degree polynomial features
Parameters

x     : ndarray of shape (n_samples, n_features)
degree: int the nth degree polynomial to map features

Returns

ndarray of shape (n_samples, n_features quadratic terms)
Function to map variables into an n degree polynomial features Parameters x : ndarray of shape ( n_samples n_features ) degree : int the nth degree polynomial to map features Returns ndarray of shape ( n_samples n_features quadratic terms )
def map_polynomial_features(x, degree = 2):
    m = x.shape[0]
    n = x.shape[1]
    x = np.hstack((np.ones((m, 1)), x))
    feature_map = list()
    for i in range(m):
        for k, v in enumerate(it.combinations_with_replacement(x[i], degree)):
            if k == 0:
                pass
            else:
                feature_map.append(np.product(v))
    return np.array(feature_map).reshape(m, -1)
def map_polynomial_features ( x , degree = 2 ) : m = x . shape [ 0 ] n = x . shape [ 1 ] x = np . hstack ( ( np . ones ( ( m , 1 ) ) , x ) ) feature_map = list ( ) for i in range ( m ) : for k , v in enumerate ( it . combinations_with_replacement ( x [ i ] , degree ) ) : if k == 0 : pass else : feature_map . append ( np . product ( v ) ) return np . array ( feature_map ) . reshape ( m , - 1 )
Function to map variables into an n degree polynomial features
Parameters
Function to map variables into an n degree polynomial features Parameters
"""
    Function to map variables into an n degree polynomial features

    Parameters
    --------------------------------------------------
        x     : ndarray of shape (n_samples, n_features)
        degree: int the nth degree polynomial to map features

    Returns
    --------------------------------------------------
        feature_map: ndarray of shape (n_samples, n_features quadratic terms)
    """
x
degree