This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Node: | |
def __init__(self, data): | |
self.left = None | |
self.right = None | |
self.data = data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def min_sq_error(y, x, w1, w0): | |
y_pred = [w1*i+w0 for i in x] | |
sum_squared_error = sum((y_pred-y)**2) | |
N = len(y) | |
mse = sum_squared_error/N | |
return mse | |
print("MSE via my calculations: ", min_sq_error(y, x, 0.05034768176424329, 0.6504410345649969)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
w1 = 0.05034768176424329 | |
w0 = 0.6504410345649969 | |
y_pred = w1*x+w0 | |
plt.scatter(x, y) | |
plt.plot([min(x), max(x)], [min(y_pred), max(y_pred)], 'r') # regression line |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def slope_intercept_LR(x, y, step, epochs): | |
x_bar = np.mean(x) # 1 | |
y_bar = np.mean(y) # 2 | |
xy_bar = np.mean(x*y) # 3 | |
x_squared_bar = np.mean(x**2) # 4 | |
x_bar_squared = (np.mean(x))**2 #5 | |
w1 = (xy_bar - (x_bar * y_bar))/(x_squared_bar-x_bar_squared) | |
w0 = (-w1*x_bar)+y_bar | |
print('Slope is / Weight 1 :', w1) | |
print('Intercept / Weight 2 is:', w0, '\n') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3' | |
services: | |
web: | |
build: . | |
command: python3 manage.py runserver 0.0.0.0:8000 | |
volumes: | |
- .:/code | |
ports: | |
- "8000:8000" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Pull image | |
FROM python:3 | |
# Set environment variable | |
ENV PYTHONUNBUFFERED 1 | |
# Setup working directory | |
WORKDIR /code |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
global theta | |
def setup(): | |
size(500,500) | |
def draw(): | |
background(255) | |
theta = map(mouseX,0,width,0,PI/2); | |
translate(width/2, height) | |
branch(100, theta) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def setup(): | |
size(500,500) | |
cantor(10, 20, width-20); | |
def cantor(x, y, len): | |
strokeWeight(3) | |
if len >=1: | |
line(x, y, x+len, y) | |
y+=20 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
i = di = dj = 0 # deriviatives? | |
fn1, fn2, fn3 = random(20), random(20), random(20) # for colors | |
f = 10 | |
def setup(): | |
global zmx1, zmx2, zmy1, zmy2 | |
size(500, 500) | |
zmx1 = int(width / 4) | |
zmx2 = 2 | |
zmy1 = int(height / 4) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
i = di = dj = 0 # deriviatives? | |
fn1, fn2, fn3 = random(20), random(20), random(20) # for colors | |
f = 10 | |
def setup(): | |
global zmx1, zmx2, zmy1, zmy2 | |
size(500, 500) | |
zmx1 = int(width / 4) | |
zmx2 = 2 | |
zmy1 = int(height / 4) |