This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import print_function | |
import sys | |
from math import sqrt | |
import argparse | |
from collections import defaultdict | |
from random import randint | |
from pyspark import SparkContext |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import time | |
import boto3 | |
def lambda_handler(event, context): | |
conn = boto3.client("emr") | |
# chooses the first cluster which is Running or Waiting | |
# possibly can also choose by name or already have the cluster id | |
clusters = conn.list_clusters() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# impor spark, set spark context | |
from pyspark import SparkContext, SparkConf | |
from pyspark.sql.context import SQLContext | |
import sys | |
import os | |
if len(sys.argv) == 1: | |
sys.stderr.write("Must enter input file to convert") | |
sys.exit() | |
input_file = sys.argv[1] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.tomron; | |
import org.apache.spark.sql.Row; | |
import org.apache.spark.sql.expressions.MutableAggregationBuffer; | |
import org.apache.spark.sql.expressions.UserDefinedAggregateFunction; | |
import org.apache.spark.sql.types.DataType; | |
import org.apache.spark.sql.types.DataTypes; | |
import org.apache.spark.sql.types.StructField; | |
import org.apache.spark.sql.types.StructType; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.tomron; | |
import org.apache.spark.sql.Row; | |
import org.apache.spark.sql.expressions.MutableAggregationBuffer; | |
import org.apache.spark.sql.expressions.UserDefinedAggregateFunction; | |
import org.apache.spark.sql.types.DataType; | |
import org.apache.spark.sql.types.DataTypes; | |
import org.apache.spark.sql.types.StructField; | |
import org.apache.spark.sql.types.StructType; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import numpy as np | |
from scipy import stats | |
input_file='advertisement_clicks.csv' | |
df = pd.read_csv(input_file) | |
a = df[df['advertisement_id']== 'A']['action'].tolist() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import numpy as np | |
from scipy import stats | |
input_file='advertisement_clicks.csv' | |
df = pd.read_csv(input_file) | |
a = df[df['advertisement_id']== 'A']['action'].tolist() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
""" | |
Implements Sequential probability ratio test | |
https://en.wikipedia.org/wiki/Sequential_probability_ratio_test | |
""" | |
class SPRT: | |
def __init__(self, alpha, beta, mu0, mu1): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
""" | |
Implements Sequential probability ratio test | |
https://en.wikipedia.org/wiki/Sequential_probability_ratio_test | |
""" | |
class SPRT: | |
def __init__(self, alpha, beta, mu0, mu1): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import networkx as nx | |
import pandas as pd | |
import numpy as np | |
import matplotlib.pyplot as plt | |
# Multigraph example | |
G = nx.MultiGraph() | |
G.add_nodes_from([1, 2, 3]) |
OlderNewer