Skip to content

Instantly share code, notes, and snippets.

@aficionado
aficionado / metadata.json
Created January 5, 2019 05:12 — forked from jaor/metadata.json
Incremental anomaly detection
{
"name": "Incremental anomalies",
"kind": "script",
"description": "Adds a new dataset to a collection and computes a set of anomalies for the new, extended data",
"source_code": "script.whizzml",
"imports":[
],
"inputs":[
{
"name": "url",
@aficionado
aficionado / gradient-boosting.whizzml
Created May 6, 2016 12:59 — forked from charleslparker/gradient-boosting.whizzml
A vanilla implementation of gradient boosting in WhizzML
;; This is a vanilla implementation of gradient boosting. The main
;; function is at the bottom of the script, where it explains the
;; algorithm in some detail.
;; A constant added to the generated field names to let us know that
;; we generated them
(define boost-id "__bmlboost")
;; The names of the fields contain ground truth - if there are k
;; classes, this is k coluns, one for each class. If the true class
{
"name": "Model or ensemble",
"description": "Select the best option for modeling a source: a model or an ensemble?",
"parameters": [
{
"name": "input-source-id",
"type": "source-id",
"description": "Source for training/test the model and ensemble"
}
],
@aficionado
aficionado / one-click-dataset.json
Created May 6, 2016 12:56 — forked from whizzmler/one-click-dataset.json
One-Click Dataset from a Source
{
"name": "One-Click Dataset",
"description": "Create a new dataset from a source with a click",
"outputs": [
{"name": "dataset-id", "type": "dataset-id", "description": "The new dataset"},
{"name": "rows", "type": "number", "description": "The number of rows of the new dataset"}
],
"parameters": [
{"name": "source-id", "type": "source-id", "default": "", "description": "Source from which to create a new dataset"},
{"name": "source-name", "type": "string", "default": "", "description": "Name for the new dataset"}
from pymongo.son_manipulator import SONManipulator
class KeyTransform(SONManipulator):
"""Transforms keys going to database and restores them coming out.
This allows keys with dots in them to be used (but does break searching on
them unless the find command also uses the transform.
Example & test:
# To allow `.` (dots) in keys
{"fields": [{"optype": "numeric", "name": "pregnancies", "datatype": "int8", "preferred": true, "summary": {"sum_squares": 20063, "missing_count": 0, "sum": 2953, "median": 2.96687, "maximum": 17, "minimum": 0, "standard_deviation": 3.36958, "variance": 11.35406, "counts": [[0, 111], [1, 135], [2, 103], [3, 75], [4, 68], [5, 57], [6, 50], [7, 45], [8, 38], [9, 28], [10, 24], [11, 11], [12, 9], [13, 10], [14, 2], [15, 1], [17, 1]], "population": 768, "mean": 3.84505}, "column_number": 0, "id": "000000", "order": 0}, {"optype": "numeric", "name": "plasma glucose", "datatype": "int16", "preferred": true, "summary": {"sum_squares": 12008759, "splits": [73.40028, 80.70976, 84.56046, 88.29697, 91.0653, 94.02324, 96.37393, 99.15167, 100.81422, 102.99865, 105.47912, 107.37394, 109.45106, 111.68975, 114.22117, 116.8391, 119.5, 122.06267, 124.31608, 126.65592, 129.19127, 132.64738, 136.8101, 140.43237, 144.72673, 148.62092, 155.01649, 161.85305, 168.92, 178.9276, 187.59806], "missing_count": 0, "sum": 92847, "median":

The introduction to Reactive Programming you've been missing

(by @andrestaltz)

So you're curious in learning this new thing called (Functional) Reactive Programming (FRP).

Learning it is hard, even harder by the lack of good material. When I started, I tried looking for tutorials. I found only a handful of practical guides, but they just scratched the surface and never tackled the challenge of building the whole architecture around it. Library documentations often don't help when you're trying to understand some function. I mean, honestly, look at this:

Rx.Observable.prototype.flatMapLatest(selector, [thisArg])

Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.

This variation of a clustered force layout uses an entry transition and careful initialization to minimize distracting jitter as the force simulation converges on a stable layout.

By default, D3’s force layout randomly initializes node positions. You can prevent this by setting each node’s x and y properties before starting the layout. In this example, because custom forces cluster nodes by color, most of the initial jitter is caused by the initial random placement overlapping clusters. We can reduce the jitter by initially placing nodes of the same color near other.

The number of clusters in this example is defined by the variable m; the local variable i is the node’s cluster number. To initialize clusters in a circle of radius 200px around the canvas center, we can define x and y like so:

x: Math.cos(i / m * 2 * Math.PI) * 200 + width / 2 + Math.random(),
y: Math.sin(i / m * 2 * Math.PI) * 200 + height / 2 + Math.r
build
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>BigML Prediction Test</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<script src="http://code.jquery.com/jquery-1.7.1.js" type="text/javascript"></script>