Skip to content

Instantly share code, notes, and snippets.

View osipov's full-sized avatar

Carl Osipov osipov

View GitHub Profile
WITH Customers AS (
(SELECT 1 AS Customer, 1 AS Tea, 1 AS Scones) UNION ALL
(SELECT 2 AS Customer, 0 AS Tea, 1 AS Scones) UNION ALL
(SELECT 3 AS Customer, 0 AS Tea, 0 AS Scones) UNION ALL
(SELECT 4 AS Customer, 0 AS Tea, 0 AS Scones) UNION ALL
(SELECT 5 AS Customer, 1 AS Tea, 1 AS Scones) UNION ALL
(SELECT 6 AS Customer, 1 AS Tea, 0 AS Scones) UNION ALL
(SELECT 7 AS Customer, 1 AS Tea, 0 AS Scones) UNION ALL
(SELECT 8 AS Customer, 1 AS Tea, 1 AS Scones) UNION ALL
(SELECT 9 AS Customer, 1 AS Tea, 0 AS Scones) UNION ALL
@osipov
osipov / tensorflow.md
Last active April 24, 2019 01:10
TensorFlow w/R

Using TensorFlow in R

Chapter 1 - Your first "Hello World" neural network with TensorFlow in R

  • Lesson 1.1 - Getting started with TensorFlow

    • A learning objective: Create tensors in R and use the building blocks of TensorFlow APIs
  • Lesson 1.2 - Implementing graphs and loops in TensorFlow

    • A learning objective: Implement a multilayer neural network and evaluate it for predictions against a sample dataset
  • Lesson 1.3 - Training a neural network with gradient descent

# Setup the model
x <- tf$placeholder(tf$float32, shape(NULL, 1024L))
W <- tf$Variable(tf$zeros(shape(1024L, 10L)))
b <- tf$Variable(tf$zeros(shape(10L)))
t <- tf$nn$softmax(tf$matmul(x, W) + b)
# Specify the loss and optimizer
t_ <- tf$placeholder(tf$float32, shape(NULL, 10L))
xent <- tf$reduce_mean(-tf$reduce_sum(t_ * log(t), reduction_indices=1L))
batch_step <- tf$train$GradientDescentOptimizer(0.5)$minimize(xent)
titanic_train_ds <- csv_record_spec("titanic.train.csv")
@osipov
osipov / parks.ipynb
Created April 22, 2019 21:55
parks.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
package org.deeplearning4j.examples.feedforward.xor;
import org.deeplearning4j.eval.Evaluation;
import org.deeplearning4j.nn.api.OptimizationAlgorithm;
import org.deeplearning4j.nn.conf.MultiLayerConfiguration;
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
import org.deeplearning4j.nn.conf.Updater;
import org.deeplearning4j.nn.conf.layers.DenseLayer;
import org.deeplearning4j.nn.conf.layers.OutputLayer;
import org.deeplearning4j.nn.multilayer.MultiLayerNetwork;
package org.deeplearning4j.examples.feedforward.xor;
import org.deeplearning4j.eval.Evaluation;
import org.deeplearning4j.nn.api.Model;
import org.deeplearning4j.nn.api.OptimizationAlgorithm;
import org.deeplearning4j.nn.conf.MultiLayerConfiguration;
import org.deeplearning4j.nn.conf.NeuralNetConfiguration;
import org.deeplearning4j.nn.conf.Updater;
import org.deeplearning4j.nn.conf.distribution.NormalDistribution;
import org.deeplearning4j.nn.conf.distribution.UniformDistribution;
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.deeplearning4j</groupId>
<artifactId>dl4j-spark-cdh5-examples</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>dl4j-spark-cdh5-examples</name>
@osipov
osipov / SQL
Created June 3, 2016 16:18
create sample address table
CREATE TABLE "address" ("address" "text", "city" "text", "state" "text", "postalCode" "text", "country" "text", "lat" "float", "lon" "float");
@osipov
osipov / gender_equality.r
Created August 28, 2015 13:26
Gender Equality
If you select people totally at random (no discrimination!) from the population of people with >130 IQ to work at Facebook and the sd for men in the general population is 11 IQ points instead of 10 for women, you'll wind up with a 70% male workforce at Facebook.
Similarly if men had a mean IQ of 101 instead of 99 for women, Facebook would have a 66% male workforce.
From R:
women <- pnorm(130, mean = 100, sd = 10, lower.tail = FALSE)
men <- pnorm(130, mean = 100, sd = 11, lower.tail = FALSE)
scaling <- 100/(women+men)
men * scaling
[1] 70.28561
women * scaling
[1] 29.71439
@osipov
osipov / Makefile
Last active August 29, 2015 14:04
Makefile to download and build Spark 1.0.1 against Hadoop 2.4.0 on Ubuntu 14.04
all: prereq build
prereq:
apt-get -y install git
apt-get -y install curl
apt-get -y install openjdk-7-jdk
apt-get -y install maven
git clone https://github.com/apache/spark.git
cd spark; git checkout tags/v1.0.1
build:
export SPARK_HADOOP_VERSION=2.4.0