Skip to content

Instantly share code, notes, and snippets.

View musically-ut's full-sized avatar
🐙
🐢 🎣 🐠

Utkarsh Upadhyay musically-ut

🐙
🐢 🎣 🐠
View GitHub Profile
@musically-ut
musically-ut / bench_semi_supervised_n_iter.py
Last active July 7, 2017 06:35 — forked from jnothman/bench_semi_supervised_n_iter
Benchmarking `sklearn.semi_supervised` `n_iter_` as a function of model and data characteristics
import numpy as np
from sklearn import datasets
from sklearn.semi_supervised import LabelPropagation, LabelSpreading
###for n_samples in [20, 200, 2000, 20000]:
### X, y = datasets.make_classification(n_samples=n_samples, n_classes=3, n_informative=3)
for (X, y) in [datasets.load_iris(return_X_y=True)]:
for model in [LabelPropagation(max_iter=1000),
#LabelSpreading(alpha=0.01),
#LabelSpreading(alpha=0.1),
#LabelSpreading(alpha=0.3)
@musically-ut
musically-ut / update_server.sh
Created March 16, 2017 23:14
Setting up a new server by copying config files from local computer.
#!/bin/bash
set -e
set -u
set -o pipefail
if [ -z $1 ]
then
echo "Usage: $0 [user@]servername"
exit 1
@musically-ut
musically-ut / poor_man_parallel.sh
Last active April 1, 2019 10:11
Poor man's parallel execution on servers
#!/usr/bin/env bash
set -e
for N in {1..5}
do
for M in {0.1,1,2,5,10};
do
# Replace ./my_prog.py with your program to run it in parallel
./my_prog.py -N $N -M $M > output/stdout_N${N}_M${M}.txt &
@musically-ut
musically-ut / 4 dots puzzle.md
Created September 16, 2016 16:40
4 dots puzzle

4 dots puzzle

Initial position: There are 4 dots arranged as a square on a grid.

Move: The dots can be moved by reflecting them through any other three dots. So to move a point, draw a line segment from that dot to another dot, extend it to twice its length and move the first dot to the place where it terminates.

Question: Is it possible to transform the square into another square of a larger size?


@musically-ut
musically-ut / pre-commit.no-git.sh
Last active August 14, 2016 05:18
Pre-commit hook to avoid committing lines with '#NO-GIT"
#!/bin/sh
PAT='#\s*NO(.)?GIT'
git diff --cached --name-only | \
xargs egrep -i --color --with-filename -n "$PAT" && echo "Found '"$PAT"' in code about to be committed. Rejecting commit." && exit 1
# Exit with error code zero if all went well.
exit 0
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@musically-ut
musically-ut / nngraph_plot_in_itorch.lua
Last active April 5, 2016 11:07
How to show an nnGraph plot in iTorch
require 'graph';
require 'os';
function displayGraph(g, forward)
local imgFile = os.tmpname() .. '.png'
local dag = g.fg
if forward == false then
dag = g.bg
end
par(mfrows=c(clustering$cluster,1))
for(j in 1:max(clustering$cluster))
{
x <- 1:12
d <- d[clustering$cluster == j,]
plot.default(x = NA, xlim = c(1, 12),
ylim = c(min(y), max(y)), xlab = "Time", ylab = "Expression changes",
main = paste("Cluster", j), axes = FALSE)
function (eset, cl, mfrow = c(1, 1), colo, min.mem = 0, time.labels,
new.window = TRUE)
{
clusterindex <- cl[[3]]
memship <- cl[[4]]
memship[memship < min.mem] <- -1
colorindex <- integer(dim(exprs(eset))[[1]])
if (missing(colo)) {
colo <- c("#FF8F00", "#FFA700", "#FFBF00", "#FFD700",
"#FFEF00", "#F7FF00", "#DFFF00", "#C7FF00", "#AFFF00",
@musically-ut
musically-ut / README.md
Last active November 2, 2015 10:50
Scripts to convert sqlite

Scripts to convert datasets from unruly forms to SQLite

The script json2sqlite.py reads files which have one JSON block per new line to be inserted in a database. This has become a rather common dataformat which is easy to incrementally parse. The arguments to the scripts are self explanatory.

Example execution: python json2sqlite.py --gzip aggressive_dedup.json.gz amazon.sqlite reviews

For a more upto date scripts, see: Networks-Leraning/datasets2sqlite.