Skip to content

Instantly share code, notes, and snippets.

View minesh1291's full-sized avatar
πŸš–
On The Journey to Neverland

Minesh A. Jethva minesh1291

πŸš–
On The Journey to Neverland
View GitHub Profile
@minesh1291
minesh1291 / hmm_3.py
Created May 23, 2019 12:12 — forked from kangeugine/hmm_3.py
HMM Problem #2
logprob, seq = model.decode(np.array([[1,2,0]]).transpose())
print(math.exp(logprob))
print(seq)
logprob, seq = model.decode(np.array([[2,2,2]]).transpose())
print(math.exp(logprob))
print(seq)
@minesh1291
minesh1291 / hmm_4.py
Created May 23, 2019 12:55 — forked from kangeugine/hmm_4.py
HMM: Problem 3, estimating parameters
import os
import urllib
import numpy as np
from numpy.lib.stride_tricks import as_strided
import matplotlib.pyplot as plt
import scipy
from scipy.io import wavfile
from sklearn.model_selection import StratifiedShuffleSplit
from hmmlearn import hmm
@minesh1291
minesh1291 / hmm_5.py
Created May 23, 2019 12:56 — forked from kangeugine/hmm_5.py
HMM: Problem 3 Feature Engineering
#######################
# feature engineering #
#######################
def stft(x, fftsize=64, overlap_pct=.5):
#Modified from http://stackoverflow.com/questions/2459295/stft-and-istft-in-python
hop = int(fftsize * (1 - overlap_pct))
w = scipy.hanning(fftsize + 1)[:-1]
raw = np.array([np.fft.rfft(w * x[i:i + fftsize]) for i in range(0, len(x) - fftsize, hop)])
return raw[:, :(fftsize // 2)]
@minesh1291
minesh1291 / hmm_6.py
Created May 29, 2019 14:11 — forked from kangeugine/hmm_6.py
HMM Problem 3 Build Model
#######################
# split training data #
#######################
sss = StratifiedShuffleSplit(n_splits=2, test_size=0.1, random_state=0)
sss.get_n_splits(all_obs, all_labels)
for n,i in enumerate(all_obs):
all_obs[n] /= all_obs[n].sum(axis=0)
@minesh1291
minesh1291 / cluster.py
Created June 4, 2019 13:33 — forked from mparker2/cluster.py
some numpy functions for dynamic time warping
import numpy as np
from scipy.spatial.distance import cdist
from .dtw import dtw
from .lb import envelope, lb_keogh_cdist, lb_keogh_from_bounds
from .window import window_ts
def dtw_nearest_neighbours(query, db, bound_reach, step_size, subseq=False):
assert query.ndim == 1
assert db.ndim == 2
assert query.flags.contiguous
@minesh1291
minesh1291 / jupyter_shortcuts.md
Created June 25, 2019 17:05 — forked from kidpixo/jupyter_shortcuts.md
Keyboard shortcuts for ipython notebook 3.1.0 / jupyter

Toc

Keyboard shortcuts

The IPython Notebook has two different keyboard input modes. Edit mode allows you to type code/text into a cell and is indicated by a green cell border. Command mode binds the keyboard to notebook level actions and is indicated by a grey cell border.

MacOS modifier keys:

  • ⌘ : Command
@minesh1291
minesh1291 / gist:9b27f179378153dc890e89c846b8c72a
Created June 27, 2019 12:38 — forked from bradediger/gist:1168054
Fixed-width fonts for Gmail in Firefox
Since Gmail discontinued the "Fixed-width fonts" lab, here's a CSS hack to use a
monospace font for incoming mail:
1. Install the dotjs extension:
https://addons.mozilla.org/en-US/firefox/addon/dotjs/
2. Put this in ~/.css/mail.google.com.css:
/* Read messages in fixed-width font */
@minesh1291
minesh1291 / probabilities_to_one_hot_vectors.py
Created September 7, 2019 07:26 — forked from CMCDragonkai/probabilities_to_one_hot_vectors.py
Conversion of Keras/Tensorflow Probabilities to One Hot Vectors #python
# pred_batch shape is (N, CLASS_COUNT), where N is the batch size
# it is returned by Keras as a probabilities/logits
# this converts the probabilities to a 1 hot vector
pred_batch = model.predict_on_batch(image_batch)
pred_batch = (pred_batch == pred_batch.max(axis=1)).astype(int)
@minesh1291
minesh1291 / map_reduce_dask_dataframe.py
Created September 7, 2019 07:31 — forked from CMCDragonkai/map_reduce_dask_dataframe.py
Map Reduce with Dask Dataframes #dask
import functools
import dask
import dask.dataframe as dd
import pandas as pd
pdf = pd.DataFrame({
'x': range(0, 100),
'y': range(0, 100),
'z': range(0, 100)
})
@minesh1291
minesh1291 / decorators.py
Created September 7, 2019 07:31 — forked from CMCDragonkai/decorators.py
Decorators in Python #python
import functools
def prepost(func=None, *, prefix=''):
def prepost_(func):
@functools.wraps(func)
def wrapper(*args, **kwargs):
print(f'{prefix} start')
result = func(*args, **kwargs)
print(f'{prefix} end')
return result