Skip to content

Instantly share code, notes, and snippets.

@mwacc
mwacc / sampler.R
Created November 2, 2013 19:09
sampler for data population
set.seed(100)
N <- 10000000
USER_NUM <- 25000
MOVIE_NUM <- 10000
dayOfWeek = rnorm(N, 6, 2)
partOfDay = c(1,2,3,3,4,4,4)
isRainOrSnow = c(0,0,0,1)
isRainOfSnowBefore = c(0,0,0,1)
temperature = c(0,1,2,3,4)
cameFrom = c(0,1,2,3,4,5,6,7)
@mwacc
mwacc / RandomForest
Created January 12, 2014 15:23
sample of using random forest to predict future :)
# read dataset from local file
data <- read.csv("/Users/kostya/Downloads/abalone.data.csv", header=F)
# set names for dataframe columns
colnames(data) <- c('Sex', 'Length', 'Diameter', 'Height', 'WholeWeight', 'ShuckedWeight',
'VisceraWeight', 'ShellWeight', 'Rings')
# split dataset into train and test seta
train.size <- floor(0.9 * nrow(data))
@mwacc
mwacc / abalone.r
Created January 14, 2014 15:40
linear regression and automatic formula building and best result pick up
library(ggplot2)
# read dataset from local file
abalone <- read.csv("/Users/kostya/Downloads/abalone.data.csv", header=F)
# set names for dataframe columns
colnames(abalone) <- c('Sex', 'Length', 'Diameter', 'Height', 'WholeWeight', 'ShuckedWeight',
'VisceraWeight', 'ShellWeight', 'Rings')
# plot histogram
@mwacc
mwacc / car-analysis.groovy
Created June 13, 2014 17:46
example of groovy script + selenium webdriver (maven artefact is loaded by anotation)
@Grab(group="org.seleniumhq.selenium", module="selenium-java", version="2.42.2")
import org.openqa.selenium.*;
import org.openqa.selenium.chrome.*;
System.setProperty("webdriver.chrome.driver", "/Users/kostya/Downloads/chromedriver");
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addArguments("--verbose", "--ignore-certificate-errors");
WebDriver driver = new ChromeDriver();
@mwacc
mwacc / hug_rhadoop.R
Created June 18, 2014 11:16
rhadoop demo for Lviv HUG
library(rmr2)
rmr.options(backend = "local")
#hdfs.init()
lm.map =
function(., line) {
keyval( line[[1]], paste(line[[2]], line[[3]], sep="|"))
}
@mwacc
mwacc / gist:c04636a1b25409db9257
Created October 7, 2015 16:16
create maven project
# Spark scala project
mvn archetype:generate -B -DarchetypeGroupId=net.alchim31.maven -DarchetypeArtifactId=scala-archetype-simple -DarchetypeVersion=1.5 -DgroupId=org.apache.spark -DartifactId=<Project name> -Dversion=0.1-SNAPSHOT -Dpackage=org.apache.spark
# flink project
mvn archetype:generate \
-DarchetypeGroupId=org.apache.flink \
-DarchetypeArtifactId=flink-quickstart-scala \
-DarchetypeVersion=0.9.1 \
-DgroupId=org.apache.flink.quickstart \
-DartifactId=flink-scala-project \
import sys
import random
import datetime
TNX_NUM = int(sys.argv[1])
ACCOUNT_NUM = int(sys.argv[2])
RATES_NUM = int(sys.argv[3])
PAR_ID = int(sys.argv[4])
def get_random(top_limit):
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mwacc
mwacc / MyFirstTF.py
Last active March 27, 2019 22:02
fourth-degree polynomial using Halley's Method.
import tensorflow as tf
import numpy as np
print(tf.__version__)
def calc_fx1(fx, x):
return tf.gradients(fx, x)[0]
def calc_fx2(fx, x):
return tf.gradients(tf.gradients(fx, x)[0], x)[0]
from aws_xray_sdk.core import xray_recorder
@xray_recorder.capture("get_balance")
def get_balance(user_acc_id):
""" ... """
...