<jupyter_start><jupyter_text>Regressions Evy Haan 3/12/2019<jupyter_code>import numpy as np
import matplotlib
import matplotlib.pyplot as plt
import numpy.polynomial.polynomial as poly
from sklearn.model_selection import train_test_split

# render visuzalizations
%matplotlib inline
matplotlib.rcParams['figure.figsize'] = [12.0, 8.0]
# bunch of random data
def gen_data(size):
    X = np.random.rand(size) * 100
    Y = X ** 2 + 7
    Y = Y + np.random.randn(Y.shape[0]) * 300
    return X, Y
X_full, Y_full = gen_data(10)
X_train, X_test, Y_train, Y_test = train_test_split(X_full, Y_full, test_size = 0.2, random_state=42)
plt.plot(X_train, Y_train, 'bo', markersize=5)
plt.title('Training Set')
plt.plot(X_test, Y_test, 'bo', markersize=5)
plt.title('Training Set')
coefs_lin = poly.polyfit(X_train, Y_train, 1)
coefs_sq = poly.polyfit(X_train, Y_train, 2)
coefs_ten = poly.polyfit(X_train, Y_train, 3)
X_line = np.linspace(0,100)
ffit_ln = poly.polyval(X_line, coefs_lin)
ffit_sq = poly.polyval(X_line, coefs_sq)
ffit_ten = poly.polyval(X_line, coefs_ten)        
# clamp values
plt.ylim(min(Y_train - 5000), max(Y_train + 5000))

plt.plot(X_line, ffit_ln, 'g')
plt.plot(X_line, ffit_sq, 'b')
plt.plot(X_line, ffit_ten, 'r')

plt.plot(X_train, Y_train, 'y.', markersize=11)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13685015290519878, 'fraction_numerical': 0.035168195718654434, 'mean_word_length': 5.577889447236181, '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': '445521', 'license': 'MIT', 'n_tokens_mistral': 604, 'n_tokens_neox': 550, 'n_words': 114, 'path': 'Regressions-Demo.ipynb', 'repo_name': 'EvyHaan/data_analysis', 'size': '1308'}