<jupyter_start><jupyter_text>---  Unemployment and Highly Correlated Crime Types<jupyter_code>df_kycdMonth = pd.read_csv('kycd_monthly.csv')
df_kycdMonth.columns = ['Month', 'KYCD', 'Count']
df_of = pd.read_csv('kycd_OfnsDesc.csv')
criminal_kycds = [236, 232, 358]  # Best
labels = {236: 'DANGEROUS WEAPONS', 232: 'POSSESSION OF STOLEN PROPERTY', 358: 'OFFENSES INVOLVING FRAUD'}
# criminal_kycds = [361, 118, 359]  # Second Best
# df_of.sort_values(by='Counts', ascending=False).head(30)
df_of.sort_values(by='Counts', ascending=False).head(9).KY_CD.values
df_of[df_of.KY_CD.isin([341, 578, 344, 351, 109, 235, 361, 105, 107])]

DF = df_of[df_of.KY_CD.isin(criminal_kycds)]
DF
dic = {}
for code in criminal_kycds:
    dic[code] = smooth(x, normalize(df_kycdMonth[df_kycdMonth.KYCD==code].Count.values), 1)
plt.figure(figsize=(20, 10))
plt.plot(X, smooth_unemploy, c='black', linewidth=20, alpha=.2, label = 'Smoothed Unemployment Rate')

# plt.scatter(X, m_vals, s=100, alpha=.5, c='steelblue', label = 'Monthly Crime Incidents')
# plt.plot(X, m_smooth_avg, c='skyblue', alpha=.7, linewidth=4, label = 'Smoothed Crime Signal')

for k, v in dic.items():
    plt.plot(X, v, alpha=.7, linewidth=5, label = 'Smoothed ' + labels[k].capitalize() + ' Signal')


plt.xlim(xmin=0, xmax=len(m_vals))
plt.ylim(ymin=-4, ymax=4)
plt.xticks(np.arange(0, 121, 12).tolist(), np.arange(2006, 2017).tolist())
plt.yticks([])

coef, p_value = pearsonr(ue_vals, m_vals)

plt.ylabel('Normalized Values Per Month', fontsize = 20)
plt.xlabel('Time, Graphed by Months', fontsize = 20)
# plt.title('NYC Crime Over Time', fontsize = 30)
plt.title('Coefficient of Correlation Between Unemployment Rate and Crime: ' + str(np.round(coef, 3)) + 
         '\n p value representing percent chance that this occurred by chance: ' + str(np.array([p_value]))[3:-1],
          fontsize=20)
plt.legend(fontsize = 20, loc=0)

plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.17064315352697096, 'fraction_numerical': 0.05394190871369295, 'mean_word_length': 5.674740484429066, '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': '235694', 'license': 'MIT', 'n_tokens_mistral': 879, 'n_tokens_neox': 761, 'n_words': 164, 'path': 'plots/unempoly_crime_sub.ipynb', 'repo_name': 'leedtan/SparklesSunshinePuppies', 'size': '1928'}