Skip to content

Instantly share code, notes, and snippets.

View alcantarar's full-sized avatar
🌮
Twitter: @Ryan_Alcantara_

Ryan Alcantara alcantarar

🌮
Twitter: @Ryan_Alcantara_
View GitHub Profile
@mattjj
mattjj / chunk_data.py
Last active August 24, 2021 15:11
data chunking with overlapping windows! uses stride tricks so no data is copied; it just produces a view!
from __future__ import division
import numpy as np
from numpy.lib.stride_tricks import as_strided as ast
def chunk_data(data,window_size,overlap_size=0,flatten_inside_window=True):
assert data.ndim == 1 or data.ndim == 2
if data.ndim == 1:
data = data.reshape((-1,1))
# get the number of overlapping windows that fit into the data
@weiznich
weiznich / fit2gpx.py
Created January 11, 2015 14:39
Simple script to convert the fit files of a garmin forerunner to gpx files.
#!/usr/bin/env python
from fitparse import FitFile
import srtm
import xml.dom.minidom as minidom
import moment
import sys
import xml.etree.cElementTree as ET
@mrecos
mrecos / stratifiedCV.r
Last active August 14, 2020 17:50
Stratified K-folds Cross-Validation with Caret
require(caret)
#load some data
data(USArrests)
### Prepare Data (postive observations)
# add a column to be the strata. In this case it is states, it can be sites, or other locations
# the original data has 50 rows, so this adds a state label to 10 consecutive observations
USArrests$state <- c(rep(c("PA","MD","DE","NY","NJ"), each = 5))
# this replaces the existing rownames (states) with a simple numerical index