Skip to content

Instantly share code, notes, and snippets.

View hoffm386's full-sized avatar

Erin R Hoffman hoffm386

View GitHub Profile
@hoffm386
hoffm386 / ml_example_full_pipeline.py
Created March 26, 2020 02:54
Example of an ML workflow in scikit-learn where all steps have been added to the pipeline
# Step 0: import relevant packages
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.pipeline import Pipeline
from sklearn.compose import ColumnTransformer
from sklearn.preprocessing import OneHotEncoder
from sklearn.base import BaseEstimator, TransformerMixin
from sklearn.linear_model import LinearRegression
@hoffm386
hoffm386 / ml_example_preprocessing_pipeline.py
Created March 26, 2020 02:37
Example of an ML workflow in scikit-learn where both preprocessing steps have been added to the pipeline
# Step 0: import relevant packages
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.pipeline import Pipeline
from sklearn.compose import ColumnTransformer
from sklearn.preprocessing import OneHotEncoder
from sklearn.base import BaseEstimator, TransformerMixin
from sklearn.linear_model import LinearRegression
@hoffm386
hoffm386 / ml_example_ohe_pipeline.py
Created March 26, 2020 02:08
Example of an ML workflow in scikit-learn where only the one-hot encoder has been added to the pipeline
# Step 0: import relevant packages
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.pipeline import Pipeline
from sklearn.compose import ColumnTransformer
from sklearn.preprocessing import OneHotEncoder
from sklearn.linear_model import LinearRegression
# Step 1: load all data into X and y
@hoffm386
hoffm386 / ml_example_without_pipelines.py
Created March 26, 2020 01:33
Example of an ML workflow in scikit-learn without pipelines
# Step 0: import relevant packages
import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import OneHotEncoder
from sklearn.linear_model import LinearRegression
# Step 1: load all data into X and y
antelope_df = pd.read_csv("antelope.csv")
X = antelope_df.drop("spring_fawn_count", axis=1)
@hoffm386
hoffm386 / glitch.json
Created October 1, 2019 19:28
Example configuration file for deploying a Flask app on Glitch
{
"install": "pip3 install --user -r pip-requirements.txt",
"start": "PYTHONUNBUFFERED=true python3 app.py",
"watch": {
"ignore": [
"\\.pyc$"
],
"install": {
"include": [
"pip-requirements.txt"
@hoffm386
hoffm386 / weirdness.rb
Created July 24, 2019 19:38
Backspace literal example
params[:id]
@hoffm386
hoffm386 / background.js
Created April 22, 2017 20:11 — forked from danharper/background.js
Bare minimum Chrome extension to inject a JS file into the given page when you click on the browser action icon. The script then inserts a new div into the DOM.
// this is the background code...
// listen for our browerAction to be clicked
chrome.browserAction.onClicked.addListener(function (tab) {
// for the current tab, inject the "inject.js" file & execute it
chrome.tabs.executeScript(tab.ib, {
file: 'inject.js'
});
});