Skip to content

Instantly share code, notes, and snippets.

@ForteXX-2020
ForteXX-2020 / 0004_OLSregression(2)
Created January 15, 2021 02:38
0004_OLSregression(2)
from pylab import plt
import numpy as np
def f(x):
return 3 * x ** 3 - 4 * x ** 2
x = np.linspace(-2, 4, 25)
y = f(x)
@ForteXX-2020
ForteXX-2020 / 0004_OLSregression
Created January 14, 2021 21:22
0004_OLSregression
from pylab import plt
import numpy as np
def f(x):
return 3 * x ** 3 - 4 * x ** 2
x = np.linspace(-2, 4, 25)
y = f(x)
@ForteXX-2020
ForteXX-2020 / 0003_create_testdata
Last active January 13, 2021 09:21
0003_create_testdata
from pylab import plt
import numpy as np
def f(x):
return 3 * x ** 3 - 4 * x ** 2
x = np.linspace(-2, 4, 25)
y = f(x)
@ForteXX-2020
ForteXX-2020 / 0002_reinforcement
Last active January 12, 2021 22:01
0002_reinforcement
import numpy as np
ssp = [1, 1, 1, 1, 0]
def epoch():
asp = [1, 0]
tr = 0
for _ in range(100):
a = np.random.choice(asp)
s = np.random.choice(ssp)
if a == s:
@ForteXX-2020
ForteXX-2020 / 0001_clustering
Last active January 12, 2021 04:42
0001_clustering
from pylab import plt, mpl
from sklearn.cluster import KMeans
from sklearn.datasets import make_blobs
x, y = make_blobs(n_samples=200, centers=5,
random_state=500, cluster_std=1.25)
model = KMeans(n_clusters=5, random_state=0)
model.fit(x)
KMeans(n_clusters=5, random_state=0)