Skip to content

Instantly share code, notes, and snippets.

View mertbozkir's full-sized avatar
🔥
Delayed Gratification!

Mert Bozkir mertbozkir

🔥
Delayed Gratification!
View GitHub Profile
@mertbozkir
mertbozkir / LinearRegression.ipynb
Last active May 12, 2022 08:21
Simple Linear Regression with Gradient Descent from Scratch
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mertbozkir
mertbozkir / binary_search.py
Created January 2, 2022 16:15
Binary Search algorithm O(log n) runtime complexity
def search(nums, target) -> int:
high = len(nums) - 1
low, mid = 0, 0
while low <= high:
mid = (high + low)// 2
if nums[mid] < target:
low = mid + 1
@mertbozkir
mertbozkir / Reverse_Integer.py
Last active June 5, 2021 21:10
String approach to reverse integer problem
class Solution:
def reverse(self, x: int) -> int:
ex = str(x)
if ex[0] == "-":
ex2 = ex[1:]
print(ex2[::-1])
if not((-2)**31 < int(ex2[::-1]) < 2**31 - 1):
return 0
return ex[0] + str(int(ex2[::-1]))
else:
@mertbozkir
mertbozkir / maxArea_of_Cake.py
Last active June 4, 2021 15:40
Maximum Area of a Piece of Cake After Horizontal and Vertical Cuts
import numpy as np
class Solution:
def areaEdge(self, h_w: int, Cuts: List[int]) -> int:
Cuts.insert(len(Cuts), h_w)
temp_list = Cuts[:-1]
temp_list.insert(0,0)
Cuts.sort()
temp_list.sort()
@mertbozkir
mertbozkir / Codeland_Username_Validation.py
Last active June 3, 2021 16:41
Codeland Username Validation Solution
def CodelandUsernameValidation(strParam):
if (4<len(strParam)<25) or (strParam[0] != str) or strParam[-1] == "_":
return False
return True
# keep this function call here
print(CodelandUsernameValidation(input()))
"""
@mertbozkir
mertbozkir / fit_ml_algo.py
Last active May 31, 2021 21:40
Function that run ML Algorithms easily
# Function that runs the requested algorithm and returns the accuracy metrics
def fit_ml_algo(algo, X_train, y_train, cv):
# One Pass
model = algo.fit(X_train, y_train)
acc = round(model.score(X_train, y_train) * 100, 2)
# Cross Validation
train_pred = model_selection.cross_val_predict(algo,
X_train,
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.