Skip to content

Instantly share code, notes, and snippets.

View noahgift's full-sized avatar
🎯
#mlops

Noah Gift noahgift

🎯
#mlops
View GitHub Profile
version: 0.1
phases:
install:
commands:
- pip install --upgrade pip
- pip install -r requirements.txt
pre_build:
commands:
- echo Pre-build phase...
#Parse a log and yield ONLY one line
def parse_log(path):
with open("logfile.txt") as myfile:
res = myfile.readlines()
for line in res:
yield line
#generator pipeline
stream = parse_log("logfile.txt") # step 1
split_it = (line.split() for line in stream) #step 2
@noahgift
noahgift / pylint_heroku
Created August 27, 2011 23:12
Pylint Heroku
pylint --disable=W0622,W0611,F0401,R0914,W0221,W0222,W0142,F0010,W0703,R0911 -f parseable heroku
@noahgift
noahgift / lazy_functions.ipynb
Last active August 11, 2018 03:19
1minute tip on writing lazy functions
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@noahgift
noahgift / fstrings.ipynb
Last active August 15, 2018 18:08
1minutetip on using F-Strings in Python3. Source blog post: https://paiml.com/blog/fstrings-omt2/
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
(.myrepo) ➜ myrepo git:(master) ✗ make lint
pylint --disable=R,C myrepolib cli web
No config file found, using default configuration
--------------------------------------------------------------------
Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00)
(.myrepo) ➜ myrepo git:(master) ✗ make test
python -m pytest -vv --cov=myrepolib tests/*.py
============================================================ test session starts ============================================================
platform darwin -- Python 3.6.4, pytest-3.3.0, py-1.5.2, pluggy-0.6.0 -- /Users/noahgift/.myrepo/bin/python
cachedir: .cache
rootdir: /Users/noahgift/src/myrepo, inifile:
plugins: cov-2.5.1, nbval-0.7
collected 1 item
tests/test_myrepo.py::test_func PASSED [100%]
for i in range(1,10):
print(f"I like sharing python code this way up to {i} times")
print(f"Ok, tired now")
@noahgift
noahgift / debugging_tips.py
Last active November 10, 2018 20:02
Shows some common ways to debug python
#Python quick and dirty debugging
#1. PDB or IPDB
#this is the most powerful debugging technique
#Can also use ipdb: https://pypi.org/project/ipdb/
def stuff():
#import pdb;pdb.set_trace()
x = 1
y = 2
@noahgift
noahgift / gist:4c6332a0caa83721b3f8a904fca2b0f7
Created October 23, 2019 22:55
sklearn-cross-validate.ipynb
In [107]: from sklearn.linear_model import LogisticRegressionCV
In [108]: model_cv = LogisticRegressionCV(10)
In [109]: model_cv.fit(X_train, y_train)
Out[109]: LogisticRegressionCV(Cs=10, class_weight=None, cv=None, dual=False, fit_intercept=True, intercept_scaling=1.0, max_iter=100, multi_class='ovr', n_jobs=1, penalty='l2', random_state=None, refit=True, scoring=None, solver='lbfgs', tol=0.0001, verbose=0)