Skip to content

Instantly share code, notes, and snippets.

View nipunbatra's full-sized avatar

Nipun Batra nipunbatra

View GitHub Profile
(base) ➜  prog-ml.github.io git:(main) ✗ pip install black[jupyter]
zsh: no matches found: black[jupyter]
(base) ➜  prog-ml.github.io git:(main) ✗ black notebooks/introduction/simpson.ipynb 
Skipping .ipynb files as Jupyter dependencies are not installed.
You can fix this by running ``pip install black[jupyter]``
No Python files are present to be formatted. Nothing to do 😴
(base) ➜  prog-ml.github.io git:(main) ✗ which black
/Users/nipun/miniconda3/bin/black
(base) ➜  prog-ml.github.io git:(main) ✗ pip install 'black[jupyter]'              
Before PR After PR
Screenshot 2022-03-29 at 4 31 53 PM image
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@nipunbatra
nipunbatra / chunking.ipynb
Created June 14, 2019 09:42
chunking-data
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
from nilmtk import DataSet
ds = DataSet("/home/nipunbatra-pc/Downloads/iawe.h5")
elec = ds.buildings[1].elec
elec.meters[0].load(chunksize=10)
next(elec.meters[0].load(chunksize=10))
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# pegasos.py
#
# Copyright 2013 nipun batra <nipunb@iiitd.ac.in>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
ps aux|grep sparse-transfer-cv-static-matrix.py|awk '{print $2}'|xargs kill -9
"""
========================================
Unfair Casino Problem using Discrete HMM
========================================
This script shows how to use Decoding in a Discrete(Multinomial) HMM, which means
given the model parameters and an observed sequence we wish to find the most likely hidden state sequence
generating the same.
It uses the model given in http://www.rose-hulman.edu/~shibberu/MA490/MA490HMM.html#Example_Dishonest_Casino_
One may also refer to a great lecture series at http://vimeo.com/7175217

We've all seen those weird looking mathematics equations that pop up when we hear about Fourier transforms. In this blog post, we'll programatically try and develop an intuitive understanding into the whole process. While I'll be using the scientific Python stack in this blog post, code in Matlab, R should not be that different.

Goal: Given a time series signal, we'll try and decompose it into various contituent freqencies.

First, let us assume that we are doing some signal acquisition and we can sample at 100 Hz frequency (100 times per second). We collect data for 10 seconds. So, we have a total of 1000 samples.

Samples collection duration (T) = 10s
Sampling frequency (Fs) =100Hz