Skip to content

Instantly share code, notes, and snippets.

@rspeare
rspeare / parallel_pandas_apply.py
Last active Dec 19, 2019
Cute Parallel Pandas Apply example
View parallel_pandas_apply.py
from joblib import Parallel, delayed
import functools
import pandas as pd
def parallel_apply(partition_col=None, n_partitions=None):
"""
This decorator wraps any transformer function that takes in a pandas dataframe as some keyword argument, "data",
and returns a pandas dataframe.
Signature must be:
@rspeare
rspeare / logistic_reg.py
Last active Apr 3, 2021
Sklearn Logistic Regression wrapper for Active Learning and p-value estimation
View logistic_reg.py
from sklearn.linear_model import LogisticRegression
import numpy as np
import scipy.stats as stat
from scipy.sparse import issparse
class ActiveLearningLogisticRegression(LogisticRegression):
""" Wrapper class for scikit-learn's Logistic Regression classifier.
New Attributes:
---------------
View Active Learning through Fisher Information Gain.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@rspeare
rspeare / p_values_for_logreg.py
Last active Jun 30, 2022
P values for sklearn logistic regression
View p_values_for_logreg.py
from sklearn import linear_model
import numpy as np
import scipy.stats as stat
class LogisticReg:
"""
Wrapper Class for Logistic Regression which has the usual sklearn instance
in an attribute self.model, and pvalues, z scores and estimated
errors for each coefficient in
@rspeare
rspeare / p_values_for_logreg
Created Oct 16, 2017
P values for sklearn logistic regression