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 LinearRegressor: | |
def __init__(self, iters, X, y, lr): | |
self.iters = iters | |
self.X = X | |
self.lr = lr | |
self.y = y | |
self.b = 0 | |
self.w = 1 | |
def hypothesis_function(self, x): | |
list_of_hypothesis_functions = [] |
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 plot_histories(*args): | |
''' | |
Plots histories | |
''' | |
epochs1 = np.arange(1, len(pd.DataFrame(args[0].history)) + 1) | |
fig, ax = plt.subplots(len(args), 2, figsize=(16, 7 * len(args))) | |
fig.suptitle('Comparing Model Histories') | |
for i in range(len(args)): | |
loss1 = pd.DataFrame(args[i].history["loss"]) | |
ax[i, 0].set_title(f"Model {i + 1} Loss") |
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
import numpy as np | |
def convolve(image, kernel): | |
# We start off by defining some constants, which are required for this code | |
kernelH, kernelW = kernel.shape | |
imageH, imageW = kernel.shape | |
h, w = imageH + 1 - kernelH, imageW + 1 - kernelW | |
# filter1 creates an index system that calculates the sum of the x and y indices at each point | |
# Shape of filter1 is h x kernelW |
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
import turtle, random | |
from math import * | |
t = turtle.Turtle() | |
turtle.bgcolor("black") | |
t.speed(3000000) | |
t.pensize(5) |
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
import time | |
import matplotlib.pyplot as plt | |
def insertionSort(array): | |
steps = 0 | |
start = time.time() | |
for a in range(1,len(array)): | |
steps+=1 | |
key = array[a] | |
b = a-1 |