<jupyter_start><jupyter_text>Extra stuff<jupyter_code>%matplotlib inline

import numpy as np
import matplotlib.pyplot as plt
from math import cos, sin, pi

def rot(a):
    return np.array([[cos(a), -sin(a)], [sin(a),cos(a)]])

def get_cov(a, b, angle):
    T=np.matmul(rot(angle), np.array([[a,0],[0,b]]))
    return np.matmul(T, T.T)  

#Z=np.random.rand(100,100)
mean1 = [0,0]
cov1 = get_cov(0.6, 3, angle=pi/4)
print(cov1)
mean2 = [10,10]
cov2 = get_cov(0.6, 3, angle=3*pi/4)
mean3 = [0,10]
#cov3 = [[1,0], [0,0.2]]
cov3 = get_cov(0.6, 3, angle=0)
print(cov3)
x1, y1 = np.random.multivariate_normal(mean1, cov1, 100000).T
x2, y2 = np.random.multivariate_normal(mean2, cov2, 100000).T
x3, y3 = np.random.multivariate_normal(mean3, cov3, 100000).T
x=np.hstack([x1,x2, x3])
y=np.hstack([y1,y2, y3])
#plt.imshow(Z)
plt.hist2d(x, y, bins=100, cmap='Blues', range=[[-4,14],[-4,15]]);
from sklearn.datasets import make_blobs
X,y = make_blobs(100, 3, centers=4, random_state=2, cluster_std=1.5)
X -= np.min(X)
#plt.scatter(X[:, 0], X[:, 1], c=y, s=50, cmap='rainbow');
# Print fitted parameters of a model
def print_parameters(model):
    for key in dir(model):
        if key[0] != '_' and key[-1] == '_':
            print(key, getattr(model, key))
from sklearn.naive_bayes import GaussianNB
from sklearn.naive_bayes import MultinomialNB
model = GaussianNB()
#model = MultinomialNB()
model.fit(X, y);
print_parameters(model)
rng = np.random.RandomState(0)
Xnew = [-6, -14] + [14, 18] * rng.rand(2000,2)
ynew = model.predict(Xnew)
plt.scatter(X[:, 0], X[:, 1], c=y, s=50, cmap='RdBu')
lim = plt.axis()
plt.scatter(Xnew[:, 0], Xnew[:, 1], c=ynew, s=20, cmap='RdBu', alpha=0.1)
plt.axis(lim)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.2064139941690962, 'fraction_numerical': 0.07405247813411078, 'mean_word_length': 5.150537634408602, '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': '277945', 'license': 'MIT', 'n_tokens_mistral': 842, 'n_tokens_neox': 775, 'n_words': 162, 'path': 'course-page/extra.ipynb', 'repo_name': 'ored95/data-analysis-course', 'size': '1715'}