Skip to content

Instantly share code, notes, and snippets.

View yashppawar's full-sized avatar
🎧
Learning

Yash Pawar yashppawar

🎧
Learning
View GitHub Profile
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
@shravanasati
shravanasati / 69.py
Created June 27, 2021 10:16
A python script which creates a 69 using turtle.
import turtle, random
from math import *
t = turtle.Turtle()
turtle.bgcolor("black")
t.speed(3000000)
t.pensize(5)
@ThePyProgrammer
ThePyProgrammer / convolution.py
Last active December 22, 2021 03:15
2D Convolution of Image using a complex Numpy algorithm with constant speed-up.
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
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")
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 = []