Skip to content

Instantly share code, notes, and snippets.

View kristiewirth's full-sized avatar

Kristie Wirth kristiewirth

View GitHub Profile
@kristiewirth
kristiewirth / bayesian_experiment_analysis_v2.py
Created January 17, 2023 22:59
Experiment analysis using bayesian techniques
from numpy import mean, quantile
from scipy.stats import beta
################# Parameters #################
control_successes = 10
control_failures = 20
treatment_successes = 40
treatment_failures = 23
##############################################
@kristiewirth
kristiewirth / template-bash-profile
Last active December 5, 2022 18:27
A template for a bash_profile with helpful additions
# Navigating quickly to commonly used directories (change to your own)
export CDPATH=.:~:/Users/kristiewirth/Documents:/Users/kristiewirth/Documents/work
# Changing command line beginning to just be directory and $
export PS1="\W/ $ "
# Expanding bash completion
if [ -f /etc/bash_completion ]; then
. /etc/bash_completion
elif [ -f /opt/local/etc/profile.d/bash_completion.sh ]; then
@kristiewirth
kristiewirth / alfred-snippets-to-csv.py
Created September 1, 2021 17:13
Convert Alfred snippets export to CSV file
import os
import pandas as pd
import json
# Update these for your use case
folder = 'FOLDER'
csv_filename = 'CSV_FILENAME'
concated_df = pd.DataFrame()
@kristiewirth
kristiewirth / simplified_model_building.py
Last active December 15, 2021 17:58
Simplified bare bones script for building predictive models
import datto as dt
import pandas as pd
import spacy
from featurestore import FeatureStore
from sklearn.ensemble import RandomForestClassifier
from sklearn.feature_extraction.text import ENGLISH_STOP_WORDS, TfidfVectorizer
from sklearn.metrics import (
accuracy_score,
mean_squared_error,
median_absolute_error,
import re
import numpy as np
from langdetect import detect
from sklearn.feature_extraction.text import TfidfVectorizer
from sklearn.metrics.pairwise import linear_kernel
from toolz.functoolz import pipe
def find_non_sentences(sentences: list, nlp):
non_sentences = []
####
# Source: some commands from https://medium.com/@waxzce/keeping-macos-clean-this-is-my-osx-brew-update-cli-command-6c8f12dc1731
# Run: $ `bash update-all-the-things.sh`
####
# Update command line tools
softwareupdate --all --install --force
# Clean up brew
brew update && brew upgrade && brew cleanup -s
# Interstate must be a unique prime number
interstate = 227
percent_in_control = 0.5
identity_id = 4545136090
assignment_number = identity_id % interstate
lane_divider = interstate * percent_in_control
if assignment_number > lane_divider:
condition = 'treatment'
WITH birth_events AS
(SELECT identity_id, MIN(timestamp) AS first_timestamp
FROM fact_experiment_birth_events
-- Experiment name chosen
WHERE experiment_name LIKE '%experiment-1%'
GROUP BY identity_id),
death_events AS
(SELECT identity_id, MIN(timestamp) AS first_timestamp
-- Table with chosen metric
from flask import Flask, jsonify, request
import pandas as pd
# Intialize app
app = Flask(__name__)
# Need the liveness & readiness routes in order to pass Kubernetes checks
@app.route('/liveness')
def liveness():
return "alive"
FROM python:3.6
COPY /requirements.txt /app/requirements.txt
COPY /src/app.py /app/src/app.py
WORKDIR /app/src
RUN pip install -r /app/requirements.txt
ENTRYPOINT ["python", "app.py"]