Skip to content

Instantly share code, notes, and snippets.

View nipunbatra's full-sized avatar

Nipun Batra nipunbatra

View GitHub Profile
"""
========================================
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
import subprocess,time
import shutil
import time
#Number of lines to tail
NUMLINES_TAIL="1000"
FILE_PATH="/home/nipun/Desktop/OZW_log.txt"
SLEEP_TIME=20
while True:
{
"metadata": {
"name": "HMM_Viterbi"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
@nipunbatra
nipunbatra / adaboost.pynb
Last active December 14, 2015 10:09
ADABoost
{
"metadata": {
"name": "AdaBoost"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
{
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
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 <[email protected]>
#
# 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
import requests
files = {'Data': open(filename, 'rb')}
r = requests.post('http://sensoract.iiitd.edu.in:9004', files=files)
print r
import glob
import os
import time
import MySQLdb
DATA_PATH='/home/nipun/Desktop/'
THRESHOLD_TIME=300
connection = MySQLdb.Connect(host='', user='root', passwd='password', db='smart_meter_data',local_infile = 1)
cursor = connection.cursor()
folders=os.listdir(DATA_PATH)
'''Importing the functions to be unit tested'''
from smart_meter import create_header_row
from nose import with_setup
'''Creating a setup method to initialize variables which can be used more than once during multiple tests'''
def setup_lists():
global parameter_list, parameter_numbers
parameter_list=["timestamp","W","W1","A1"]
parameter_numbers=[1,2]