Every aspect of your product should contribute to one of these 5 principles:
- Small
- Fast
- Reproducible
- Transparent
- Frictionless
import hashlib | |
import time | |
class Block: | |
def __init__(self, data, previous_hash=None): | |
self.data = data | |
self.previous_hash = previous_hash | |
self.nonce = 0 | |
self.hash = self.calculate_hash() |
from collections import defaultdict, deque | |
class Model: | |
def __init__(self): | |
self.counts = defaultdict(lambda: {"f": 0, "d": 0}) | |
self.last_six = deque(maxlen=6) | |
self.num_correct = 0 | |
self.num_predictions = 0 |
import math | |
def numerize(num, precision=1): | |
if num == 0: | |
return "0" | |
num = float(f"{num:.3g}") | |
m = int(math.log10(abs(num)) // 3) | |
numf = f"{num / 1000.0**m:.{precision}f}".rstrip("0").rstrip(".") | |
return f"{numf}{['', 'K', 'M', 'B', 'T', 'G'][m]}" |
# data / ml | |
numpy | |
pandas | |
scikit-learn | |
shap | |
sqlalchemy | |
lightgbm | |
# inspection | |
tqdm |
import string | |
import collections | |
from typing import List | |
# https://leetcode.com/problems/rotate-array/ | |
def rotate(nums: List[int], k: int) -> None: | |
k = k % len(nums) | |
nums[:] = nums[-k:] + nums[:-k] | |
return nums |
# -*- coding: utf-8 -*- | |
import os | |
import hashlib | |
import pandas as pd | |
def read_sql_cache(sql, con, ttl=None, dirname="_cache", **kwargs): | |
""" | |
pd.read_sql but with a time to live (ttl) cache. |
I hereby claim:
To claim this, I am signing this object:
Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1')) | |
choco install chrome | |
choco install git | |
choco install cmder | |
choco install vscode | |
choco install anaconda3 | |
conda config --add channels conda-forge | |
conda install black hyperopt lightgbm loguru mlxtend pandas-profiling pyarrow shap tokei | |
Start-Process "chrome.exe" "https://www.lfd.uci.edu/~gohlke/pythonlibs/#xgboost" |
# -*- coding: utf-8 -*- | |
import os | |
import re | |
pat = '\w*(?=\.git$)' | |
with open('git.sh', mode='w') as f: | |
f.write('#!/usr/bin/env bash\n') |