Skip to content

Instantly share code, notes, and snippets.

Utkarsh Upadhyay musically-ut

Block or report user

Report or block musically-ut

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@musically-ut
musically-ut / bench_semi_supervised_n_iter.py
Last active Jul 7, 2017 — forked from jnothman/bench_semi_supervised_n_iter
Benchmarking `sklearn.semi_supervised` `n_iter_` as a function of model and data characteristics
View bench_semi_supervised_n_iter.py
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 Mar 16, 2017
Setting up a new server by copying config files from local computer.
View update_server.sh
#!/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 Apr 1, 2019
Poor man's parallel execution on servers
View poor_man_parallel.sh
#!/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 &
View 4 dots puzzle.md

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 Aug 14, 2016
Pre-commit hook to avoid committing lines with '#NO-GIT"
View pre-commit.no-git.sh
#!/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
View randomized_methods.ipynb
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 Apr 5, 2016
How to show an nnGraph plot in iTorch
View nngraph_plot_in_itorch.lua
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
View Plotting_clustering_timeseries.R
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)
View Example code.R
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 Nov 2, 2015
Scripts to convert sqlite
View README.md

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.

You can’t perform that action at this time.