Skip to content

Instantly share code, notes, and snippets.

View kshirsagarsiddharth's full-sized avatar
🎯
Focusing

kshirsagarsiddharth

🎯
Focusing
View GitHub Profile
@kshirsagarsiddharth
kshirsagarsiddharth / simple_generator.py
Created July 27, 2020 07:26
example of a generator function
def generator_function():
value = 1
print("This is printed first")
yield value
value += 1
print("This is printed second")
yield value
value += 1
@scwood
scwood / hash.py
Last active March 15, 2023 16:20
python hash table using linear probing
class HashTable(object):
def __init__(self):
self.max_length = 8
self.max_load_factor = 0.75
self.length = 0
self.table = [None] * self.max_length
def __len__(self):
return self.length
@Leon-Ray
Leon-Ray / lrCostFunction
Last active January 31, 2022 22:40
Vectorized logistic regression with regularization using gradient descent for the Coursera course Machine Learning. Cost function (J) and partial derivatives of the cost w.r.t. each parameter in theta (grad).
len = size(theta);
J = 1/m*(-y'*log(sigmoid(X*theta))-(1-y)'*log(1-sigmoid(X*theta))) + lambda/(2*m)*sum(theta(2:len).^2);
grad = 1./m*((sigmoid(X*theta)-y)'*X);
temp = theta;
temp(1) = 0;
grad = grad + (lambda/m.*temp)';