This file contains hidden or 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
| node1: | |
| image: hauptmedia/mariadb:10.1 | |
| hostname: node1 | |
| ports: | |
| - 13306:3306 | |
| environment: | |
| - MYSQL_ROOT_PASSWORD=test | |
| - REPLICATION_PASSWORD=test | |
| - MYSQL_DATABASE=maria | |
| - MYSQL_USER=maria |
This file contains hidden or 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 pyspark import SparkContext | |
| import numpy as np | |
| from sklearn import ensemble | |
| def batch(xs): | |
| yield list(xs) | |
| N = 1000 |
This file contains hidden or 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
| %matplotlib inline | |
| import numpy as np | |
| import pandas as pd | |
| from matplotlib import pyplot as plt | |
| plt.style.use("ggplot") | |
| plt.rcParams["font.size"] = 13 | |
| plt.rcParams["figure.figsize"] = 10, 8 |
This file contains hidden or 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.frontier45 | |
| /** | |
| * Created by du on 16/01/29. | |
| */ | |
| fun <T1, T2> T1?.map(f: (T1) -> T2): T2? { | |
| return if (this != null) { | |
| f(this) | |
| } else { |
This file contains hidden or 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
| object RichAny { | |
| class RichAny[T1](o: T1) { | |
| def let[T2](f: (T1) => T2): T2 = { | |
| f(o) | |
| } | |
| } | |
| implicit def richAny[T](o: T): RichAny[T] = new RichAny(o) |
This file contains hidden or 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 absolute_import | |
| import json | |
| from abc import ABCMeta, abstractmethod | |
| from datetime import datetime | |
| from json import JSONEncoder as JSONEncoder | |
| from six import add_metaclass | |
This file contains hidden or 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 time | |
| from collections import UserDict | |
| from threading import Lock, Event, Thread | |
| from functional import seq | |
| # <http://stackoverflow.com/questions/22498038/improve-current-implementation-of-a-setinterval-python/22498708#22498708> | |
| def set_interval(interval, func, *args): | |
| stopped = Event() |
This file contains hidden or 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
| def startJob(args: RunArgs)(implicit sc: SparkContext): Unit = { | |
| val src = sc.textFile(args.fname, minPartitions = args.n_partitions).map(_.split("\t")) | |
| .flatMap { | |
| // input file's format is (user_id, product_name, count) | |
| case Array(u, p, r, t) => Some((u.toInt, p.toInt, r.toDouble)) | |
| case _ => None | |
| }.persist() | |
| // Map to convert user_id or product_name into unique sequencential id | |
| val userid_map = src.map(_._1).distinct().zipWithIndex().collect().toMap |
This file contains hidden or 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 python:3.5-slim | |
| MAINTAINER Shiqiao DU <lucidfrontier.45@gmail.com> | |
| RUN pip install -U pip setuptools wheel && rm -rf /root/.cache | |
| RUN set -ex \ | |
| && buildDeps=' \ | |
| gcc \ | |
| libbz2-dev \ | |
| libc6-dev \ |
This file contains hidden or 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.frontier45.LDABench | |
| import org.apache.spark.mllib.clustering.LDA | |
| import org.apache.spark.mllib.linalg.Vectors | |
| import org.apache.spark.{SparkContext, SparkConf} | |
| import scala.util.Random | |
| /** |