Skip to content

Instantly share code, notes, and snippets.

View EricSchles's full-sized avatar

Eric Schles EricSchles

View GitHub Profile
def get_percent_empty(df):
listing = list(df.isnull().sum()/df.shape[0] != 0)
columns_of_interest = []
cols = df.columns.tolist()
for index, col in enumerate(cols):
if listing[index]:
columns_of_interest.append(col)
return df[columns_of_interest].isnull().sum()/df.shape[0]
numpy
pandas
scipy
sklearn
tensorflow
keras
statsmodels
pomegranate
seaborn
matplotlib
@EricSchles
EricSchles / Output
Created April 15, 2019 20:31 — forked from macournoyer/Output
A Neural Network framework in 25 LOC
$ python xor.py
Training:
Epoch 0 MSE: 1.765
Epoch 100 MSE: 0.015
Epoch 200 MSE: 0.005
* Target MSE reached *
Evaluating:
1 XOR 0 = 1 ( 0.904) Error: 0.096
0 XOR 1 = 1 ( 0.908) Error: 0.092
1 XOR 1 = 0 (-0.008) Error: 0.008
import numpy as np
import pandas as pd
from sklearn import linear_model
from sklearn.model_selection import train_test_split
# In general for the way to do type hinting is very straight forward.
# simply don't instantiate the class to use it as a 'type'
# Here's a generic example:
@EricSchles
EricSchles / twine_upload.sh
Created April 8, 2020 14:31
A little utility for uploading python package updates
python setup.py sdist bdist_wheel
python -m twine upload --repository-url https://test.pypi.org/legacy/ dist/*
python -m twine upload dist/*
@EricSchles
EricSchles / recursive_line_count.py
Created September 10, 2020 16:37
count the number of lines in your jupyter notebooks
from glob import glob
from json import load
def loc(nb):
cells = load(open(nb))["cells"]
return sum(len(c["source"]) for c in cells)
root_folder = "~"
summation = 0
for File in glob(root_folder+"/**/*.ipynb", recursive=True):
pyramid_sum = lambda n: (2*(n**2) - (2*n - 1))
import tensorflow as tf
import numpy as np
import pandas as pd
class ReluDense(tf.Module):
def __init__(self, in_features, out_features, name=None):
super().__init__(name=name)
self.w = tf.Variable(
tf.random.normal([out_features, out_features]), name='w'
)
from tensorflow.keras import Model
import tensorflow as tf
import numpy as np
import pandas as pd
import random
class ReluDense(tf.Module):
def __init__(self, in_features, out_features, name=None):
super().__init__(name=name)
self.w = tf.Variable(
from tensorflow.keras import Model
import tensorflow as tf
import numpy as np
import pandas as pd
import random
class ReluDense(tf.Module):
def __init__(self, in_features, out_features, name=None):
super().__init__(name=name)
self.w = tf.Variable(