Skip to content

Instantly share code, notes, and snippets.

View drmingle's full-sized avatar

Damian Mingle drmingle

View GitHub Profile
@drmingle
drmingle / Loading Features from Dictionaries.md
Last active April 30, 2018 06:39
This transformer turns lists of mappings (dict-like objects) of feature names to feature values into Numpy arrays or scipy.sparse matrices for use with scikit-learn estimators.
title author date
Loading Features From Dictionaries
Damian Mingle
04/30/2018

Preliminaries

from sklearn.feature_extraction import DictVectorizer
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
title author date
Loading scikit-learn's Boston Housing Dataset
Damian Mingle
04/30/2018

Preliminaries

# Load library
@drmingle
drmingle / saving machine learning models.md
Created April 30, 2018 23:49
two conventional ways to save models using scikit-learn
title author date
Saving Machine Learning Models
Damian Mingle
04/30/2018

Let's take a look at two conventional ways to save models using scikit-learn

  1. a pickle string
  2. a pickled model as a file.

Preliminaries

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
title author date
Add Padding Around String
Damian Mingle
05/04/2018

Generate Text

text = 'Data Science is important stuff!'
title author date
Create All Combinations of a List
Damian Mingle
05/04/2018

Preliminary

from itertools import combinations_with_replacement
title author date
any(), all(), max(), min(), sum()
Damian
05/04/2018

Generate Data

data = [340, 564, 250, 120, 230]
title author date
Apply Operations Over Items In A List
Damian Mingle
05/04/2018

The map() method

# Create a list of patients who have expired