Skip to content

Instantly share code, notes, and snippets.

View RobotGyal's full-sized avatar
💡
Innovating

Aleia Knight RobotGyal

💡
Innovating
View GitHub Profile
class Node:
def __init__(self, data):
self.left = None
self.right = None
self.data = data
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))
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
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')
version: '3'
services:
web:
build: .
command: python3 manage.py runserver 0.0.0.0:8000
volumes:
- .:/code
ports:
- "8000:8000"
# Pull image
FROM python:3
# Set environment variable
ENV PYTHONUNBUFFERED 1
# Setup working directory
WORKDIR /code
@RobotGyal
RobotGyal / tree.pyde
Created May 3, 2020 15:09
Fractal tree using Processing.py
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)
@RobotGyal
RobotGyal / cantor.pyde
Created May 3, 2020 15:08
Cantor Fractal code for Processing.py
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
@RobotGyal
RobotGyal / mandelbrot.pyde
Created May 3, 2020 15:02
mandelbrot set in processing.py
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)
@RobotGyal
RobotGyal / mandelbrot.pyde
Created May 3, 2020 15:02
mandelbrot set in processing.py
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)