<jupyter_start><jupyter_text>https://www.quantopian.com/clone_notebook?id=5775279c7887ddffb0000013http://statsmodels.sourceforge.net/devel/generated/statsmodels.regression.linear_model.OLS.html<jupyter_code>import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline
import pandas as pd
import statsmodels.api as sm
from statsmodels import regression
from scipy import poly1d
Y = [1,3,4,5,2,3,4]
X0 = range(1,8)
X = sm.add_constant(X)
X
model = sm.OLS(Y,X)
results = model.fit()
results.params
model_prediction = results.params[0] + results.params[1]*X
model_prediction
results.tvalues
print(results.t_test([1, 0]))
print(results.f_test(np.identity(2)))
plt.scatter(X0, Y)
#model_prediction.plot()<jupyter_output><empty_output><jupyter_text>Numpy polyfit<jupyter_code>length = 1000
order = 2
z = np.random.randn(length)
z_sum = np.cumsum(z)
x2 = np.arange(length)

z_sum_fit2 = np.polyfit(x2, z_sum, order)  # returns coefficients of fit
xs = np.linspace(-0.25, length, length*2)     # generate values for fit

plt.plot(x2, z_sum)
plt.plot(xs, poly1d(z_sum_fit2)(xs), 'r')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13399280575539568, 'fraction_numerical': 0.044964028776978415, 'mean_word_length': 6.783216783216783, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 1, 'lorem ipsum': 0, 'www.': 1, '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': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '243017', 'license': 'MIT', 'n_tokens_mistral': 470, 'n_tokens_neox': 444, 'n_words': 80, 'path': 'Scipy/Statsmodels.ipynb', 'repo_name': 'afcarl/Useful-python', 'size': '1112'}