Skip to content

Instantly share code, notes, and snippets.

@elyase
elyase / curvature.py
Last active June 2, 2023 11:35
2D curve curvature
from scipy.interpolate import UnivariateSpline
import numpy as np
def curvature_splines(x, y=None, error=0.1):
"""Calculate the signed curvature of a 2D curve at each point
using interpolating splines.
Parameters
----------
x,y: numpy.array(dtype=float) shape (n_points, )
function (x, y = NULL, xtest = NULL, ytest = NULL, ntree = 500,
mtry = if (!is.null(y) && !is.factor(y)) max(floor(ncol(x)/3),
1) else floor(sqrt(ncol(x))), replace = TRUE, classwt = NULL,
cutoff, strata, sampsize = if (replace) nrow(x) else ceiling(0.632 *
nrow(x)), nodesize = if (!is.null(y) && !is.factor(y)) 5 else 1,
maxnodes = NULL, importance = FALSE, localImp = FALSE, nPerm = 1,
proximity, oob.prox = proximity, norm.votes = TRUE, do.trace = FALSE,
keep.forest = !is.null(y) && is.null(xtest), corr.bias = FALSE,
keep.inbag = FALSE, ...)
{
@elyase
elyase / SparkSQL
Created November 20, 2014 23:50
Data Exploration Using Spark SQL
{
"metadata": {
"name": "",
"signature": "sha256:f04c113accbabf25e09e5680267acfb16af33ae3a79b0992a8aea30875c51b17"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
@elyase
elyase / spark.ipynb
Last active August 29, 2015 14:10
Data Exploration Using Spark
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
[u'0.013*species + 0.005*formation + 0.004*water + 0.004*plant + 0.004*genus + 0.003*white + 0.003*mm + 0.003*brown + 0.002*common + 0.002*sea',
u'0.008*system + 0.006*data + 0.006*game + 0.004*using + 0.004*systems + 0.004*software + 0.003*model + 0.003*technology + 0.003*information + 0.003*available',
u'0.014*league + 0.010*club + 0.010*round + 0.009*cup + 0.007*football + 0.007*championship + 0.006*games + 0.006*player + 0.005*teams + 0.005*match',
u'0.009*party + 0.008*william + 0.008*election + 0.007*london + 0.006*james + 0.006*george + 0.005*thomas + 0.005*elected + 0.005*republican + 0.005*england',
u'0.010*building + 0.008*district + 0.008*river + 0.008*road + 0.008*station + 0.007*village + 0.006*park + 0.006*town + 0.006*railway + 0.006*historic',
u'0.014*air + 0.010*ship + 0.008*racing + 0.007*aircraft + 0.006*force + 0.006*car + 0.005*crew + 0.005*navy + 0.005*class + 0.005*race',
u'0.025*album + 0.019*song + 0.013*band + 0.009*chart + 0.008*songs + 0.008*you + 0.008*track + 0.007*records
{
"metadata": {
"name": "",
"signature": "sha256:b99bf1f68a92860ccebd342a666077e249dfb487cea12a567d68facfaa39ab39"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
@elyase
elyase / yahoo.ipnb
Created October 1, 2014 11:06
download stocks symbols specified in a text file from Yahoo
{
"metadata": {
"name": "",
"signature": "sha256:42134ad8f5b08de55437d93a2e23cb1ca3217608d1d8cc35d7768fe256c96c11"
},
"nbformat": 3,
"nbformat_minor": 0,
"worksheets": [
{
"cells": [
@elyase
elyase / quartz_event_taps
Created September 21, 2014 10:11
QuartztEvent Taps
import Quartz
from AppKit import NSKeyUp, NSSystemDefined, NSEvent
def keyboardTapCallback(proxy, type_, event, refcon):
# Convert the Quartz CGEvent into something more useful
if type_ < 0 or type_ > 0x7fffffff:
print "----- Timed out -----"
print NSEvent.eventWithCGEvent_(event)
return event
keyEvent = NSEvent.eventWithCGEvent_(event)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.