<jupyter_start><jupyter_text>Developing a Complex Model for Regression TestingThe purpose of this notebook is to establish a complex model that we can generate training and test data to practice our regression skills.  We want some number of inputs, which can range from 0 to 10.  Some are more important than others.  Some will have dependence.  Let's start with importing the necessary modules.<jupyter_code>%matplotlib inline
import numpy as np
import scipy.stats as st
import matplotlib.pyplot as plt<jupyter_output><empty_output><jupyter_text>Our first parameter will be alpha.  It varies 0->10.  It will be the first order parameter for the model.  A weibull is added for some 'spice'<jupyter_code>xa = np.linspace(0,10,100)
w1 = st.weibull_min(1.79, loc=6.0, scale=2.0)
def alpha(x):
    return(0.1 * x - 0.5 * w1.cdf(x))
f = plt.plot(xa,alpha(xa))<jupyter_output><empty_output><jupyter_text>Now we'll introduce beta, another parameter.<jupyter_code>xb = np.linspace(0,10,100)
n1 = st.norm(loc=5.0, scale=2.0)
def beta(y):
    return(1.5 * n1.pdf(y))
f = plt.plot(xb,beta(xb))
xx, yy = np.meshgrid(xa,xb)
z = alpha(xx) + beta(yy)
fig, ax = plt.subplots()
CS = ax.contour(xa, xb, z)
l = ax.clabel(CS, inline=1, fontsize=10)
plt.plot(xa,alpha(xa)+beta(9))
plt.plot(xa,alpha(xa)+beta(5))<jupyter_output><empty_output><jupyter_text>Now to add a third variable, gamma.<jupyter_code>xg = np.linspace(0,10,100)
def gamma(z):
    return((np.exp(0.036*z) - 1.0) * np.cos(2*z/np.pi))
plt.plot(xg, gamma(xg))<jupyter_output><empty_output><jupyter_text>The ResponseNow we have our function.<jupyter_code>def response(a,b,g):
    out = alpha(a) + beta(b) + gamma(g)
    return(out)
plt.plot(xa,response(xa,8,0))
plt.plot(xa,response(xa,8,5))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1405099150141643, 'fraction_numerical': 0.03456090651558073, 'mean_word_length': 5.565055762081784, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 22, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '667479', 'license': 'MIT', 'n_tokens_mistral': 720, 'n_tokens_neox': 692, 'n_words': 172, 'path': 'ComplexModel.ipynb', 'repo_name': 'sawyerap/PythonDataViz', 'size': '1765'}