<jupyter_start><jupyter_text>Get data<jupyter_code>data = get_fremont_data()
data.resample("W").sum().plot()
pivoted = data.pivot_table('Total',index=data.index.time,columns=data.index.date)
pivoted.plot(legend=False,alpha=0.05)
pivoted.T.shape<jupyter_output><empty_output><jupyter_text>Principal component analysis<jupyter_code>x = pivoted.fillna(0).T.values
x.shape
x2 = PCA(2,svd_solver='full').fit_transform(x)
plt.scatter(x2[:,0],x2[:,1])

gmm = GaussianMixture(2)
gmm.fit(x)
labels = gmm.predict(x)
labels
plt.scatter(x2[:,0],x2[:,1],c=labels,cmap='rainbow')
plt.colorbar()
pivoted.T[labels == 0].T.plot(legend=False,alpha=0.05)
pivoted.T[labels == 1].T.plot(legend=False,alpha=0.05)
dayofweek = pd.DatetimeIndex(pivoted.columns).dayofweek
plt.scatter(x2[:,0],x2[:,1],c=dayofweek,cmap='rainbow')
plt.colorbar()
dates = pd.DatetimeIndex(pivoted.columns)
dates[(labels == 0) & (dayofweek < 5)]<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.19719827586206898, 'fraction_numerical': 0.03125, 'mean_word_length': 9.556818181818182, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 9, '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': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '600364', 'license': 'MIT', 'n_tokens_mistral': 418, 'n_tokens_neox': 402, 'n_words': 37, 'path': 'Analysis.ipynb', 'repo_name': 'crocha700/JupyterWorkflow', 'size': '928'}