Skip to content

Instantly share code, notes, and snippets.

View ghl3's full-sized avatar

George Lewis ghl3

View GitHub Profile
from collections import OrderedDict
import pandas as pd
from dateutil import parser
def forecast_ts_model(res, start, end):
"""
Take a statsmodels.tsa.arima_model.ARIMAResults object
and predict (forecast) the timeseries values
between the "start" and "end" times, which
import json
from plotly import __version__
from plotly.offline import download_plotlyjs, init_notebook_mode, iplot
from plotly import tools, utils
from plotly.graph_objs import Scatter, Marker, Layout, XAxis, YAxis
def get_json_for_js(data):
figure = tools.return_figure_from_figure_or_data(data, True)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ghl3
ghl3 / plot_table.py
Created October 16, 2015 16:13
Plot a table of numeric and nominal features
def plot_table(features, targets):
for idx, feature in enumerate(features.columns):
grouped = loans.groupby(targets)
if idx % 2==0:
fig = plt.figure(figsize=(16,4))
plt.subplot(1, 2, idx % 2 + 1)
@ghl3
ghl3 / ._exam_bonus
Last active November 29, 2015 23:31
We couldn’t find that file to show.
@ghl3
ghl3 / _ImmutableDatabase
Last active March 21, 2023 14:07
Implementation of an immutable database in postgres
We couldn’t find that file to show.
;; From:
;; http://frenchy64.github.io/typed/clojure,/core.typed,/clojure/2013/09/03/core-typed-repl.html
(ns example.typed
(:require [clojure.core.typed :as t]))
(t/cf (t/ann my-inc [Number -> Number]))
(t/cf (defn my-inc [a] (inc a)))
(t/cf (my-inc 1))
@ghl3
ghl3 / conditional_rate.py
Last active August 29, 2015 14:08
Calculate the rate of the jth column given the ith column is true
def conditional_rate(df):
"""
Given a dataframe whose columns are all boolean
valued, return a data frame of size:
n_columns * n_columns
where the ith row and the jth column represents
the rate at which the jth variable is true
given that the ith variable is true.
"""
@ghl3
ghl3 / DataAndModeling
Last active August 29, 2015 14:06
Data and Modeling
Data and Modeling
Boiler plate for manipulating data and modeling using python libraries.
@ghl3
ghl3 / iPythonCell.py
Last active August 29, 2015 14:06
iPython Notebook Common Headers
from __future__ import division
%matplotlib inline
import numpy as np
import pandas as pd
pd.set_option('display.max_rows', 500)
pd.set_option('display.max_columns', 500)