Skip to content

Instantly share code, notes, and snippets.

View achetverikov's full-sized avatar

Andrey Chetverikov achetverikov

View GitHub Profile
@achetverikov
achetverikov / udi_checker.py
Created January 5, 2023 12:50
UDI checker
#!/usr/bin/python
from apscheduler.schedulers.blocking import BlockingScheduler
from datetime import datetime
import json
import pickle
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
@achetverikov
achetverikov / ecvp_21_abstracts.R
Created February 2, 2022 11:43
Topic modeling of ECVP 21 abstracts
library(data.table)
library(xml2)
library(stm)
library(quanteda)
library(gofastr)
library(stopwords)
library(spacyr)
library(quanteda)
library(quanteda.textplots)
library(Hmisc)
@achetverikov
achetverikov / sim_mean_BF.R
Created October 21, 2021 19:44
simulations with BayesFactors
library(BayesFactor)
library(future.apply)
library(future.batchtools)
# for the simulations, I used our cluster that runs PBS Torque
plan(batchtools_torque, resources = list(walltime = '01:00:00', memory = '2Gb')) # specify that the PBS Torque cluster is used and the resources we want
# create conditions combinations
conditions <- expand.grid(d = seq(0, 0.36, 0.04), N = seq(5, 65, 4))
@achetverikov
achetverikov / batchtools.torque.tmpl
Created June 23, 2021 12:57
examples with future and batchtools for PBS Torque
#!/bin/bash
#PBS -N <%= job.name %>
#PBS -o <%= log.file %>
#PBS -l walltime=<%= resources$walltime %>,mem=<%= resources$memory %>M
#PBS -q batch
#PBS -j oe
## setup modules
## create our own temp dir (and clean it up later)
@achetverikov
achetverikov / denoising_the_datasaur
Created April 30, 2021 12:39
DatasauRus as the noisy data
library(datasauRus)
library(data.table)
library(ragg)
library(ggplot2)
dsd <- datasaurus_dozen
setDT(dsd)
dsd <- dsd[dataset%in%c('star','dino','away', 'circle')]
dsd[,z:=rnorm(.N, sd = 0.4)]
dsd[,y_new:=0.2*x+z+y, by = dataset]
@achetverikov
achetverikov / seq_presentation.R
Created October 30, 2019 11:45
a function for sequentially presenting ggplot2 layers
seq_presentation <- function(p, name = 'plot_layers_%i.png', res = 320, width = 6.2, height = 6.2){
n_layers <- length(p$layers)
y_range <- ggplot_build(p)$layout$panel_scales_y[[1]]$range$range
for (i in c(n_layers:0)){
if (!is.null(name))
png(file = sprintf(name , i), res = res, width = width*res, height = height*res)
if (i!=0) {
p_copy <- copy(p)
p_copy$layers[n_layers:i] <- NULL
@achetverikov
achetverikov / moving_dots.R
Last active January 21, 2021 10:49
Moving dots with gganimate
library(ggplot2)
library(gganimate)
library(ggthemes)
library(data.table)
n = 80 # number of dots
max_r = 300 # aperture radius
dt <- data.table(r = max_r*sqrt(runif(n)), theta =2*pi*runif(n), dot_n = 1:n)
@achetverikov
achetverikov / turbo_scale_comparisons.R
Last active August 21, 2019 08:54
Turbo scale from GoogleAI vs Viridis, Inferno, and Jet
# turboscale values are from https://gist.github.com/mikhailov-work/ee72ba4191942acecc03fe6da94fc73f
library(grDevices)
turbo_colormap_data = matrix(c(c(0.18995,0.07176,0.23217),
c(0.19483,0.08339,0.26149),
c(0.19956,0.09498,0.29024),
c(0.20415,0.10652,0.31844),
c(0.20860,0.11802,0.34607),
c(0.21291,0.12947,0.37314),
c(0.21708,0.14087,0.39964),