Skip to content

Instantly share code, notes, and snippets.

View iamaziz's full-sized avatar
🎲

Aziz Alto iamaziz

🎲
View GitHub Profile
@iamaziz
iamaziz / k_means.py
Last active June 15, 2019 04:23
Vanilla k_means algorithm with zero import (for any number of dimensions)
def distance(u, v):
"""
Calculates Euclidean distance between two point
distance = square_root( sum(u_i - v_i)^2 )
u: [float, float], point1
v: [float, float], point2
"""
sum_ = sum((u[i] - v[i]) ** 2 for i in range(len(u)))
return sum_ ** (1 / 2)
@iamaziz
iamaziz / code_book_python_algorithms.py
Created September 21, 2019 01:57
Code Book: read source code just like reading a book.
# --- Code Book: Python Algorithms
# --- Source : github.com/keon/algorithms.git
#========================================================================================================================
# :: tree/path_sum.py ::
#========================================================================================================================
| 1| """
| 2| Given a binary tree and a sum, determine if the tree has a root-to-leaf
| 3| path such that adding up all the values along the path equals the given sum.
| 4|
@iamaziz
iamaziz / metaprogramming.md
Last active May 6, 2020 05:07
Note on metaprogramming and metacalss in Python
Date: 4/27/2020

Why need metaprogramming? (maybe metaclass?)

Scenario:

  • I want to have a single Interface Class that has a Base Implementation Class with multiple instance implementations for other Inheriting Classes
@iamaziz
iamaziz / videocolorizercolab.ipynb
Last active April 4, 2022 03:57
VideoColorizerColab.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@iamaziz
iamaziz / copy-of-imagecolorizercolab.ipynb
Last active May 12, 2020 21:56
ImageColorizerColab.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Classical Programming vs. Machine Learning Programming:

image

e.g.

image

source:

@iamaziz
iamaziz / nyc_to_sharqiyahdata_with_love.ipynb
Last active May 15, 2020 05:35
nyc_to_sharqiyahdata_with_love.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@iamaziz
iamaziz / count-qura-an-words-v1.ipynb
Last active May 20, 2020 00:58
Count Qura'an Words - v1
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@iamaziz
iamaziz / redshift_hook.py
Created October 31, 2020 01:04
Redshift Database Hook (adapter)
from __future__ import annotations
from functools import lru_cache, wraps
from psycopg2 import connect
from pandas import read_sql, DataFrame
class RedshiftDB:
"""Redshift Database Hook
USAGE:
@iamaziz
iamaziz / clone_table_between_redshift_databases.ipynb
Created November 12, 2020 05:00
Clone table from one redshift database "cluster" to another via S3 (in Python)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.