Skip to content

Instantly share code, notes, and snippets.

View joshdorrington's full-sized avatar

Josh Dorrington joshdorrington

View GitHub Profile
@joshdorrington
joshdorrington / hmm_hmmlearn.py
Created March 22, 2018 12:03
A side by side comparison of hmmlearn and pomegranate HMMs on a chaotic dataset
#run in python 2.7
from hmmlearn.hmm import GaussianHMM
data=np.fromfile("np_input_file.txt").reshape([200001,6])
#MODEL PARAMS
K=3
iter_num=3000
convergence_tolerance=0.001
stat_vec_tol=0.999
import numpy as np
import pandas as pd
from pomegranate import *
#IMPORT THE SAME DATA FROM 2 FILE FORMATS USING 2 METHODS
pd_data_df=pd.read_csv("pd_input_file.txt",engine="python", delimiter="\\t",names=['x1','x2','x3','x4','x5','x6'])
pd_data=pd_data_df.values.reshape([1,200001,6])
np_data=np.fromfile("np_input_file.txt").reshape([1,200001,6])
#IF ALL 3 OF THESE STATEMENTS ARE TRUE THEN THE DATA SHOULD BE TOTALLY INDISTINGUISHABLE FROM EACH OTHER:
@joshdorrington
joshdorrington / plot_cherry_blossom_data.py
Created March 30, 2021 22:51
This is how I made my cherry_blossom plot
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.offsetbox import OffsetImage, AnnotationBbox
from matplotlib.cbook import get_sample_data
def imscatter(x, y, image, ax=None, zoom=1,alpha=1):
if ax is None:
ax = plt.gca()
try:
image = plt.imread(image)
import numpy as np
import xarray as xr
from scipy.interpolate import griddata
import napari
import matplotlib.pyplot as plt
from vispy.color import Colormap
import cmocean.cm as cm
# Make land colormap with transparent ocean:
cmap = plt.cm.gist_earth