Skip to content

Instantly share code, notes, and snippets.

View coppeliaMLA's full-sized avatar

coppelia machine learning and analytics coppeliaMLA

View GitHub Profile
<head>
<script src="http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/4.2.1/d3.min.js"></script>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.css"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.16/d3.min.js"></script>
<style> #mapid {
height: 800px;
} </style>
</head>
<body>
@coppeliaMLA
coppeliaMLA / arm.ino
Created July 13, 2016 15:56
Contro MeArm
#include <Servo.h>
Servo middle, left, right, claw ; // creates 4 "servo objects"
//positions 30, 45, 60, 75, 90, 105, 120, 135, 150
void setup()
{
middle.attach(8);
left.attach(10);
<head>
<script src="http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.js"></script>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.16/d3.min.js"></script>
<style> #mapid {
height: 800px;
} </style>
</head>
<body>
<head>
<script src="http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.js"></script>
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.css"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.16/d3.min.js"></script>
<style> #mapid {
height: 800px;
} </style>
</head>
<body>
@coppeliaMLA
coppeliaMLA / tree.json
Last active August 29, 2015 14:17
Example json for tree visualisations
{
"name": "root",
"visits": "202K",
"children": [
{
"name": "purpledog.com",
"visits": "50K"
},
{
"name": "squishedfish.co.uk",
@coppeliaMLA
coppeliaMLA / Readme.md
Last active October 5, 2017 17:22
ROI Fan

Return on investment is often measured as revenue divided by costs, sometimes expressed as a percentage. For example if a marketing campaign cost £10K but brought in £20K of additional revenue then the ROI is 200%. Now if you are just given the ROI you'll find you are missing any of idea of scale. The same ROI could be achieved with a revenue of £200 and with one of £200 million. So it would be nice to see cost, revenue and ROI visualised all in one go. There are a few ways to do this but after playing around I came up with the following representation which personally I like the best. It's a simple scatterplot of cost against revenue but since all points on straight lines radiating from the origin have the same ROI it's easy to overlay that information. If r is the ROI the the angle of the corresponding spoke is arctan(r).

Note you can drag about the labels. That's my preferred solution for messy scatterplot labelling.

@coppeliaMLA
coppeliaMLA / index.html
Created October 26, 2014 09:40
ROI Fan
<!DOCTYPE html>
<meta charset="utf-8">
<style>
body {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
width: 960px;
height: 500px;
position: relative;
}
@coppeliaMLA
coppeliaMLA / CreateData.R
Last active August 29, 2015 14:05
PMMLExample
exp1<-rnorm(100000)
exp2<-rnorm(100000)
exp3<-rnorm(100000)
noise<-rnorm(100000)
lin.pred<-5*exp1+2*exp2+6*exp3+noise
response.prob<-1/(1+exp(-lin.pred))
response<-as.numeric(response.prob>0.5)
toy.data<-data.frame(response, exp1, exp2, exp3)
write.csv(toy.data, 'ToyData.csv', row.names = FALSE)
@coppeliaMLA
coppeliaMLA / busterExample2.R
Created July 8, 2014 16:07
Buster Example 2
#Another simple test
x.1<-rnorm(50, 10, 3)
y.1<-rnorm(50, 10, 3)
x.2<-rnorm(50, 20, 3)
y.2<-rnorm(50, 10, 3)
x.3<-rnorm(50, 13, 3)
y.3<-rnorm(50, 20, 3)
test.data<-data.frame(group=rep(1:3, each=50), x=c(x.1, x.2, x.3), y=c(y.1, y.2, y.3))
@coppeliaMLA
coppeliaMLA / busterExample1.R
Created July 8, 2014 16:02
Buster Example 1
#Testing on the iris data set
iris.dist<-dist(iris[,1:4])
bhc<-buster(iris.dist, n=250, k=3, size=0.66, method='ward', pct.exc=0.1)
plot(bhc)
#We see the unstable observations in pink.
cluster<-bhc$obs.eval$cluster[order(bhc$obs.eval$obs.ind)]
plot(iris[,1:4], col=6-cluster, pch = rep(15:17, each=50))