<jupyter_start><jupyter_text>Quick Code to Model Cases in Durham CountyCase numbers downloaded from https://durhampublichealth-durhamnc.hub.arcgis.com/I'm using the 7 day moving average to eliminate most of the noise<jupyter_code>import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
from lmfit.models import LorentzianModel, GaussianModel


plt.style.use('seaborn-whitegrid')
plt.rc('figure', autolayout=True)
plt.rc(
    'axes',
    labelweight='bold',
    labelsize='large',
    titleweight='bold',
    titlesize=14,
    titlepad=10)
df = pd.read_csv('Durham_County.csv', names = ['date', 'dateindex', 'cases'])
df.dropna(axis=0, inplace=True)


df.shape
sns.lineplot(x='dateindex', y='cases', data=df)
cases_array = df['cases'].to_numpy()
dates_array = df['dateindex'].to_numpy()


model = LorentzianModel()
params = model.guess(cases_array, x=dates_array)
params.add('amplitude',value=45000,min=1,max=100000)
params.add('center', value=45, min=30,max=60)
params.add('sigma', value=10.5, min=1,max=200)
##params.add('fwhm',min=1,max=100)
params.add('height',value = 30, min=0.5,max=500)

print(params)
result = model.fit(cases_array, params, x=dates_array)
result.plot_fit()
x_predict = np.linspace(1,101,num=100)

fit = result.eval(x=x_predict)

plt.figure(figsize=(10,6))
plt.plot(x_predict,fit,'-',linewidth=2,label='Prediction')
plt.plot(dates_array, cases_array,linewidth=3,label='Cases')
plt.axhline(y=60,color='k', dashes=(5,2,1,2))
plt.xlabel('Days Since Dec 1')
plt.ylabel('7 Day Case Average')
plt.legend(fontsize=14)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.163125, 'fraction_numerical': 0.04, 'mean_word_length': 7.21025641025641, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 1, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '261329', 'license': 'MIT', 'n_tokens_mistral': 658, 'n_tokens_neox': 600, 'n_words': 111, 'path': 'COVID modelling.ipynb', 'repo_name': 'joshfuchs/DataScience_projects', 'size': '1600'}