<jupyter_start><jupyter_text>Normalize features<jupyter_code>import numpy as np
"""
np.linalg.norm : Numpy provides a function to implement the feature of 2-norm
"""
def normalize_features(feature_matrix):
    norms = np.linalg.norm(feature_matrix, axis=0)
    normalized_features = feature_matrix / norms
    return(normalized_features, norms)
"""
np.poly1d : Numpy provides a function to print the polynomials in a pretty way
"""
def print_coefficients(model):
    #Get the degree of the polynomial
    deg = len(model.coefficients['value'])-1
    
    #Get learned parameters as a list
    w = list(model.coefficients['value'])
    
    #This function for pretty printing needs the parameter in the reverse order
    print 'Learned polynomial for degree ' + str(deg) + ' : '
    w.reverse()
    print np.poly1d(w)
"""
Write wrapper for translating from string (i.e. feature name) to numpy array from data
"""
def string_numpyndarray(feature_matrix, ):
    return<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09547738693467336, 'fraction_numerical': 0.005025125628140704, 'mean_word_length': 4.32620320855615, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '329197', 'license': 'MIT', 'n_tokens_mistral': 307, 'n_tokens_neox': 298, 'n_words': 95, 'path': 'solvers/preprocessing_data.ipynb', 'repo_name': 'VijayDaultani/ml_kernels', 'size': '995'}