Skip to content

Instantly share code, notes, and snippets.

fabrizioc1

Block or report user

Report or block fabrizioc1

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@fabrizioc1
fabrizioc1 / n_armed_bandit.py
Created Jun 3, 2019
Reinforcement Learning: N-Armed Bandit
View n_armed_bandit.py
from __future__ import division
import random
import numpy as np
import matplotlib
matplotlib.use('TkAgg')
import matplotlib.pyplot as plt
# epsilon values
EPSILON_VALUES = [0.0, 0.01, 0.1]
@fabrizioc1
fabrizioc1 / Stemmer.py
Created Feb 12, 2019
Example of scala Spark transformer with python wrapper
View Stemmer.py
from pyspark import since, keyword_only
from pyspark.ml.param.shared import HasInputCol, HasOutputCol, Param
from pyspark.ml.util import JavaMLReadable, JavaMLWritable
from pyspark.ml.wrapper import JavaTransformer
class Stemmer(JavaTransformer, HasInputCol, HasOutputCol, JavaMLReadable, JavaMLWritable):
@keyword_only
def __init__(self, inputCol=None, outputCol=None):
super(Stemmer, self).__init__()
@fabrizioc1
fabrizioc1 / permutations.scala
Created Jan 4, 2019
Calculate permutations of a sequence
View permutations.scala
// Permutations are using all elements in the sequence
import scala.collection.mutable.ArrayBuffer
// Mutable version
def permutationsM[T](s: Seq[T]): Seq[Seq[T]] = {
if (s.length < 2) {
Seq(s)
}
else if (s.length == 2) {
@fabrizioc1
fabrizioc1 / concurrent.scala
Last active Jan 4, 2019
Comparing different concurrency methods using Scala
View concurrent.scala
import requests._
import org.json4s._
import org.json4s.jackson.{JsonMethods => Json}
import org.json4s.JsonDSL.WithBigDecimal._
import scala.concurrent._
import scala.concurrent.duration._
// import ExecutionContext.Implicits.global
import java.lang.Runtime
@fabrizioc1
fabrizioc1 / emr_exec.py
Created Aug 10, 2018
Execute script in each EMR cluster node
View emr_exec.py
import os
import boto3
import subprocess
import configargparse
SSH_USER = 'hadoop'
SSH_TEMPLATE = 'ssh -o StrictHostKeyChecking=no -i {ssh_key} {ssh_user}@{host} "{cmd}"'
SSH_KEY_PATH = os.path.expanduser('~/.ssh')
def find_ssh_key(emr, config):
View expand_hadoop_path.py
import re
def expand_hadoop_path(path):
brace_patterns = re.findall('{{[^}]+}}', path)
brace_patterns_values = [(brace_pattern, brace_pattern.replace('{{','').replace('}}','').split(',')) for brace_pattern in brace_patterns]
replacements = []
for (brace_pattern, values) in brace_patterns_values:
if replacements:
View generate_lsh_seeds_and_features.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View find_similar_items_using_lsh.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View Learning_LSH.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View Mining_Massive_Datasets.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
You can’t perform that action at this time.