Skip to content

Instantly share code, notes, and snippets.

@smartinsightsfromdata
smartinsightsfromdata / dyselect.R
Created October 14, 2015 05:36 — forked from jcheng5/dyselect.R
Interactive date range selection using dygraphs
library(shiny)
library(dygraphs)
# Helper function to present Shiny controls in a dialog-like layout
dialogPage <- function(outputControl) {
bootstrapPage(
tags$style("
html, body { width: 100%; height: 100%; overflow: none; }
#dialogMainOutput { position: absolute; top: 10px; left: 10px; right: 10px; bottom: 40px; }
#dialogControls {
@smartinsightsfromdata
smartinsightsfromdata / debounce.R
Created October 14, 2015 05:35 — forked from jcheng5/debounce.R
reactive debounce for Shiny
# Returns a reactive that debounces the given expression by the given time in
# milliseconds.
#
# This is not a true debounce in that it will not prevent \code{expr} from being
# called many times (in fact it may be called more times than usual), but
# rather, the reactive invalidation signal that is produced by expr is debounced
# instead. This means that this function should be used when \code{expr} is
# cheap but the things it will trigger (outputs and reactives that use
# \code{expr}) are expensive.
debounce <- function(expr, millis, env = parent.frame(), quoted = FALSE,
== Skip Lists in Cypher
:neo4j-version: 2.0.0
:author: Wes Freeman
:twitter: @wefreema
:tags: in-graph index:skiplist:range lookup:timeline
Skip lists are my new favorite probabilistic sorted data structure. O(log N) for most operations (insert/delete/find/range!). If you don't know what they are, for the rest of the explanation I'll assume that you've at least read the http://en.wikipedia.org/wiki/Skip_list[wikipedia page]. You take a random number and calculate the number of levels a particular node should have. In this case, our max level is 3. To calculate the random level, we'll take the \(\large \log _.5 \left( rand() \right) \) which gives us about a 1/2 chance for our node to have just 1 level, and a 1/4 chance for our node to have just 2 levels, and a 1/8 chance for our node to have 3 levels. In a normal skip list, you'd want several more levels, but we'll keep it down to 3 for the purpose of this experiment.
From wikipedia (shows a skip list structure):
@smartinsightsfromdata
smartinsightsfromdata / Offshore Leaks and Azerbaijan.adoc
Created October 5, 2015 09:20 — forked from jvilledieu/Offshore Leaks and Azerbaijan.adoc
How to use Neo4j to analyse the Offshore Leaks : the case of Azerbaijan

How to use Neo4j to analyse the Offshore Leaks : the case of Azerbaijan

This interactive Neo4j graph tutorial shows how to use Neo4j to analyse the Offshore Leaks : the case of Azerbaijan.


Credit Card Fraud Detection

This interactive Neo4j graph tutorial covers a common credit card fraud detection scenario.


Last login: Sat Oct 3 08:12:01 on ttys000
e-mac:~ e$ cd $(brew --repository) && git reset --hard origin/master
HEAD is now at 80170b5 gdal: update 1.11.3 bottle.
e-mac:local e$ brew update
Stashing your changes:
M .editorconfig
M .gitattributes
M .gitignore
M .rspec
M .rubocop.yml
= Car manufacturers 2013
This is a graph of all the major car manufacturers and their earnings in 2013, alongside all of their main suppliers.
It also shows the relationships between the various manufactures: cooperations, jointventuress and stock ownership. and the type of those
relationships.(For example a cooperation can be of the type: research/development)
//hide

Beer & Breweries GraphGist

OpenBeerDB.com has a list of 1400+ breweries and 5900+ beers. Here’s a graph of the first 50 breweries from that list. The graph makes beer recommendations based on beer style, beer category, location, and alcohol content.

Schema

beer brewery2

(Beer)

Movie Recommendations with k-Nearest Neighbors and Cosine Similarity


Introduction

The k-nearest neighbors (k-NN) algorithm is among the simplest algorithms in the data mining field. Distances / similarities are calculated between each element in the data set using some distance / similarity metric ^[1]^ that the researcher chooses (there are many distance / similarity metrics), where the distance / similarity between any two elements is calculated based on the two elements' attributes. A data element’s k-NN are the k closest data elements according to this distance / similarity.


1. A distance metric measures distance; the higher the distance the further apart the neighbors. A similarity metric measures similarity; the higher the similarity the closer the neighbors.

Phone store

Model

Phone store

The domain model is fairly simple and straight forward. Each :Phone node is connected to at least one :Manufacturer, :Type, :OS and :Category node. Different 'weight' were given to different type of relation between these nodes. These 'weight' are the factors that will affect the ranking of the recommendation. It rates what people are more concerned with when considering for a new phone.