Skip to content

Instantly share code, notes, and snippets.

View sagz's full-sized avatar

Sagar Savla sagz

View GitHub Profile
#Author: Marcel Pinheiro Caraciolo
#Confusion Matrix Generator
#Version: 0.1
#email: caraciol at gmail . com
from pprint import pprint as _pretty_print
import math
class ConfusionMatrix(object):
class DecisionTree(object):
"""
A decision tree object
"""
@staticmethod
def count_results(data, item=True):
"""
count the occurrences of each result in the data set
"""
# Decision Tree Classifier
from sklearn import datasets
from sklearn import metrics
from sklearn.tree import DecisionTreeClassifier
# load the iris datasets
dataset = datasets.load_iris()
# fit a CART model to the data
model = DecisionTreeClassifier()
model.fit(dataset.data, dataset.target)
@sagz
sagz / bug_take3.cpp
Created April 15, 2014 17:50
Compiler bug?
#include <iostream>
template<class Out> Out negate(unsigned long in) {
// This line casts an unsigned long to a signed long.
// 2^63 as an unsigned long is 0x8000000000000000
// Casting 2^63 from unsigned long to signed long should
// produce -2^63 (which is also 0x8000000000000000).
// The twos complement of -2^63 just happens to be -2^63,
// so, (long)(2^63) should always be -2^63, correct?
Out out = -Out(in);
@sagz
sagz / evills
Created April 1, 2014 14:20 — forked from Eugeny/evills
#!/usr/bin/python
# -*- coding: utf-8 -*-
import subprocess
__all__ = ["transform"]
__version__ = '0.3'
__author__ = 'Christoph Burgmer <cburgmer@ira.uka.de>'
__url__ = 'http://github.com/cburgmer/upsidedown'
@sagz
sagz / 2hopSCP.sh
Created March 24, 2014 21:29
You ssh from your computer into serverA. Then you ssh into serverB. How to get files from serverB to your computer without first transferring them to serverA? What if there is not enough space on serverA to do this? You can do a multihop SCP like this-
scp -Cp -o "ProxyCommand ssh $username@$serverA nc $serverB 22" $username@$serverB:/path/to/remote/file ~/path/to/local/folder/
# Example
# scp -Cp -o "ProxyCommand ssh kjani3@newssh.physics.gatech.edu nc cygnus-6.pace.gatech.edu 22" kjani3@cygnus-6.pace.gatech.edu:/nv/hp11/kjani3/scratch/runs/test_precs_q1_m140/test6_precs_q1_m140/test8_precs_q1_m140/test8_precs_q1_m140/betax.x.asc ~/k/
@sagz
sagz / ac3toaac.sh
Last active August 29, 2015 13:57
Convert all files in a folder with ffmpeg
for f in *.MTS; do ffmpeg -i "$f" -ab 448k "${f%.MTS}.aac"; done
@sagz
sagz / pink_stache.py
Created November 22, 2013 23:22
The pink moustache on an ANSI colour capable console/shell. Just include and print before your program starts!
PINK_MOUSTACHE = '\033[35m{0}\033[00m'.format('''
~~~ ~~~~~~~~~. ~~~~~~~~~~ ~~~
~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~. ~~~
~~~ .~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~. ~~~
~~~ ~~~~~~~~~~~~~ Script Name ~~~~~~~~~~~~~ .~~~
~~~~. ,~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~.:~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~.~~~~~~~~~~~~~~~~~~~~~~~~~~~~:
~~~~~~~~~~~~~~~~~~~~~~~~~~. .~~~~~~~~~~~~~~~~~~~~~~~~~:
~~~~~~~~~~~~~~~~~~~~~~. .~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~
@sagz
sagz / .bashrc
Created October 21, 2013 19:25 — forked from tommybutler/.bashrc
# put timestamps in my bash history
export HISTTIMEFORMAT='%F %T '
# don't put duplicate commands into the history
export HISTCONTROL=ignoredups
# record only the most recent duplicated command (see above)
export HISTCONTROL=ignoreboth
# don't record these commands in the history; who cares about ls?
@sagz
sagz / .bashrc
Created October 12, 2013 19:58 — forked from tommybutler/.bashrc
# put timestamps in my bash history
export HISTTIMEFORMAT='%F %T '
# don't put duplicate commands into the history
export HISTCONTROL=ignoredups
# record only the most recent duplicated command (see above)
export HISTCONTROL=ignoreboth
# don't record these commands in the history; who cares about ls?