Skip to content

Instantly share code, notes, and snippets.

Avatar

Szilard Pafka szilard

View GitHub Profile
@szilard
szilard / ML_pkgs.R
Last active Oct 1, 2020
ML R packages (my focus: supervised learning) by CRAN downloads
View ML_pkgs.R
##install.packages("cranlogs")
library(data.table)
library(cranlogs)
##caret/models/file
## grep "library =" * | sed 's/.*=//' | sed 's/c(//' | sed 's/),/,/' | grep -v NULL | sed 's/,.*$/,/' | sort | uniq | tr -d '\n'
caret_pkgs <- c("rpart", "C50", "CHAID", "Cubist", "FCNN4R", "HDclassif", "HiDimDA", "KRLS", "LiblineaR",
View rpart_pruning.R
library(data.table)
library(rpart)
d_train <- fread("https://s3.amazonaws.com/benchm-ml--main/train-0.1m.csv")
md <- rpart(ifelse(dep_delayed_15min=="Y",1,0) ~ ., d_train,
control = rpart.control(cp = 0.001))
plotcp(md)
printcp(md)
@szilard
szilard / lightgbm_example.R
Created Aug 27, 2017
Minimal lightgbm example
View lightgbm_example.R
library(data.table)
library(ROCR)
library(lightgbm)
set.seed(123)
d_train <- fread("/var/data/bm-ml/train-0.1m.csv")
d_test <- fread("/var/data/bm-ml/test.csv")
@szilard
szilard / simul_unbal_methods.R
Last active Aug 25, 2017
A little framework for experimenting with the impact of various methods for dealing with unbalanced classes for machine learning
View simul_unbal_methods.R
## partial credit :) to @earino for the idea
library(lightgbm)
library(data.table)
library(ROCR)
d0_train <- fread("/var/data/bm-ml/train-10m.csv")
d0_test <- fread("/var/data/bm-ml/test.csv")
d0 <- rbind(d0_train, d0_test)
@szilard
szilard / dataset_size_openML.R
Created Aug 21, 2017
Dataset sizes in OpenML
View dataset_size_openML.R
# OpenML Benchmarking Suites and the OpenML100
# https://arxiv.org/abs/1708.03731
# https://www.openml.org/s/14/data
library(OpenML)
ids <- getOMLStudy('OpenML100')$data$data.id
dsall <- listOMLDataSets()
sum(dsall$data.id %in% ids) ## 96???
ds <- dsall[dsall$data.id %in% ids,]
@szilard
szilard / dataset_sizes_pmlb.py
Last active Aug 20, 2017
Size distribution of datasets in the Penn Machine Learning Benchmarks
View dataset_sizes_pmlb.py
## https://github.com/EpistasisLab/penn-ml-benchmarks
## pip install pmlb
import numpy as np
from pmlb import fetch_data
from pmlb import dataset_names
x = np.zeros(len(dataset_names))
for i, dn in enumerate(dataset_names):
View game_money_multi.c
#include <stdio.h>
#include <stdlib.h>
#define N 128
#define B0 100
#define R 1000000
#define M 1000
int cmpfunc (const void * a, const void * b)
{
View game_money.c
#include <stdio.h>
#include <stdlib.h>
#define N 100
#define B0 100
#define R 1000000
int main() {
int b[N], rec[N];
for (int i=0; i<N; i++) b[i] = B0;
@szilard
szilard / h2o_scoring.R
Last active Mar 12, 2018
ML Scoring (REST API) - h2o.ai
View h2o_scoring.R
## training a model
library(h2o)
h2o.init(nthreads = -1)
dx_train <- h2o.importFile("https://s3.amazonaws.com/benchm-ml--main/train-0.1m.csv")
md_rf <- h2o.randomForest(x = 1:(ncol(dx_train)-1), y = ncol(dx_train), training_frame = dx_train,
model_id = "h2o_RF",
ntrees = 100, max_depth = 10, nbins = 100)
View caret-slowdown-issue.R
library(caret)
library(readr)
library(ROCR)
set.seed(123)
d <- read_csv("https://raw.githubusercontent.com/szilard/teach-data-science-UCLA-master-appl-stats/master/wk-06-ML/data/airline100K.csv")
You can’t perform that action at this time.