Skip to content

Instantly share code, notes, and snippets.

View rinze's full-sized avatar

José María Mateos rinze

View GitHub Profile
@rinze
rinze / ImagePlusHyp.java
Created July 13, 2012 10:39
ImagePlusHyp class extending ImageJ's ImagePlus.
package jclustering;
import ij.ImagePlus;
/**
* This class extends {@link ImagePlus} in order to add a handy {@link #getTac}
* method that allows to easily grab time-activity curves.
*
* @author <a href="mailto:jmmateos@mce.hggm.es">José María Mateos</a>.
*
@rinze
rinze / ruido_madrid.csv
Created November 13, 2012 10:09
CSV con valores de ruido de Madrid (09-1998 - 10-2012)
station Leq L1 L10 L50 L90 L99 date
14 GLORIETA FDEZ. LADREDA 67.3 75.3 69.8 64.3 56.7 50 1998-09-30
16 ARTURO SORIA 59.5 67.8 61.6 56 45.3 39.1 1998-09-30
19 ALTO DE EXTREMADURA 63 72.4 66.3 59.3 51.4 47 1998-09-30
27 GLORIETA CARLOS V 74.3 84.4 79.5 67.8 62 55.5 1998-10-31
29 PLAZA DE ESPAÑA 66.3 74 68.8 64.5 59.6 54.8 1998-10-31
31 PLAZA DOCTOR MARAÑÓN 72.5 80.2 75.6 70.2 63.1 55.2 1998-10-31
32 PLAZA M. DE SALAMANCA 73.1 88.4 69.9 63.6 51.8 42.1 1998-10-31
36 RAMÓN Y CAJAL 70.3 77.2 72.9 68.8 56.8 46.3 1998-10-31
39 GLORIETA FDEZ. LADREDA 68 75.8 70.2 64.6 56.8 49.8 1998-10-31
@rinze
rinze / ingresos.R
Last active December 14, 2015 18:19
El script que he usado para las gráficas https://twitter.com/Rinze/status/310774361588133888 y https://twitter.com/Rinze/status/310774425563836417. El segundo fichero saca https://twitter.com/Rinze/status/310779666774515714 El siguiente enlace permite acceder a los mismos datos que he usado yo (tiene información de más países, yo me he quedado c…
# Eustat data analysis
library(ggplot2)
eustat <- read.csv(file = "/tmp/ilc_di01_1_Data.csv", na.string = ":")
eustat$Value <- gsub(" ", "", eustat$Value)
eustat$Value <- as.numeric(eustat$Value)
spain <- eustat[eustat$GEO == "Spain" &
eustat$CURRENCY == "Purchasing Power Standard" &
eustat$INDIC_IL == "Top cut-off point",
@rinze
rinze / mariano.ijm
Last active December 20, 2015 18:08
ImageJ macro for generating de Mariano Rajoy hybrid image at http://www.flickr.com/photos/rinzewind/9458528864/.
open("C:\\temp\\barcenas.tif");
run("32-bit");
run("Mean...", "radius=30");
open("C:\\temp\\mariano.tif");
run("32-bit");
run("Duplicate...", "title=mariano-1.tif");
run("Mean...", "radius=20");
imageCalculator("Subtract create 32-bit", "mariano.tif","mariano-1.tif");
imageCalculator("Add create 32-bit", "Result of mariano.tif","barcenas.tif");
selectWindow("barcenas.tif");
@rinze
rinze / dataframe_matrix_timing.R
Last active December 21, 2015 15:58
Difference in timing for vectorized simple operations between an R matrix and a data.frame.
# Timing measurement in R. Vectorized operation on matrix / data.frame
# Author: José María Mateos - jmmateos@ieee.org
#
# For certain vectorized operations, it makes sense to convert your data.frame
# into a matrix. Even if you are using apply, the data frame iteration can be
# real slow.
#
# In this example, I will compute the Euclidean distance for a random vector
# and a random matrix / data.frame of thousands of elements. Operations will be
# done in two different ways: using the apply function over the columns and
localpath <- "/home/chema/tmp/kaggle/digits/"
if (Sys.info()["sysname"] == "Windows")
localpath <- "C:/temp/kaggle/digits"
testFile <- file.path(localpath, "test.Rda")
trainFile <- file.path(localpath, "train.Rda")
if(!file.exists(testFile) && !file.exists(trainFile)) {
testCSV <- file.path(localpath, "test.csv")
trainCSV <- file.path(localpath, "train.csv")

Keybase proof

I hereby claim:

  • I am rinze on github.
  • I am rinzewind (https://keybase.io/rinzewind) on keybase.
  • I have a public key whose fingerprint is C7F0 E413 1FFF 47C6 A2A7 F76B F4FE 866D 2948 FA19

To claim this, I am signing this object:

### Keybase proof
I hereby claim:
* I am rinze on github.
* I am rinzewind (https://keybase.io/rinzewind) on keybase.
* I have a public key whose fingerprint is 67AF C4B2 E15C 4F4C 67BD 5F58 5ADF 9021 2630 80EC
To claim this, I am signing this object:
@rinze
rinze / build_dataset.py
Last active January 15, 2019 10:51
Parser para los archivos .DAT del Ministerio del Interior y el archivo de códigos de municipios del INE y código en R para gráficas simples.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import csv
import codecs
import cStringIO
import os
from collections import namedtuple
def getParties(parties_file):
@rinze
rinze / loo_cv_comparison.R
Last active August 29, 2015 14:25
Just a little reminder: be careful not to use leave-one-out with a perfectly balanced problem
library(C50)
# Test data
group <- c(rep('groupA', 10), rep('groupB', 10))
data <- data.frame(group = group, var = c(rep(0, 10), rep(0, 10)))
# Leave-one-out
probs <- lapply(1:nrow(data), function(i) {
train <- data[-i, ]
test <- data[i, ]