Skip to content

Instantly share code, notes, and snippets.

View thierrymoudiki's full-sized avatar

Thierry Moudiki thierrymoudiki

View GitHub Profile
@thierrymoudiki
thierrymoudiki / bayesopt.R
Created December 14, 2025 12:18
Bayesian optimization using bayesianrvfl::bayes_opt
# Run Bayesian optimization minimizing rmse
res_rmse <- bayesianrvfl::bayes_opt(
objective_function_rmse,
lower = c(3L, 1L, -4, -4, 5, 0),
upper = c(40L, 100L, 5, 5, 200, 5L),
init_points = 10,
n_iter = 50
)
@thierrymoudiki
thierrymoudiki / loop_sklearn_models.py
Last active December 13, 2025 18:27
Loop on all sklearn models
from sklearn.utils import all_estimators
from tqdm import tqdm
# Get all scikit-learn regressors
estimators = all_estimators(type_filter='regressor')
for name, RegressorClass in tqdm(estimators):
if name in ['MultiOutputRegressor', 'MultiOutputClassifier', 'StackingRegressor', 'StackingClassifier',
@thierrymoudiki
thierrymoudiki / doSNOW.R
Created October 3, 2025 07:31 — forked from andrie/doSNOW.R
Progress bars with foreach and doSNOW
library(doSNOW)
library(tcltk)
cl <- makeSOCKcluster(2)
registerDoSNOW(cl)
pb <- txtProgressBar(max=100, style=3)
progress <- function(n) setTxtProgressBar(pb, n)
opts <- list(progress=progress)
r <- foreach(i=1:100, .options.snow=opts) %dopar% {
#!/bin/bash
# first, install jq: on macOS, brew install jq
wget https://raw.githubusercontent.com/Techtonique/datasets/refs/heads/main/tabular/survival/gbsg2_2.csv
# === CONFIG ===
JSON_FILE="survival_curves.json"
CSV_FILE="survival_curves.csv"
PLOT_FILE="survival_plot.png"
#!/bin/bash
# === CONFIG ===
OUTPUT_JSON="sims.json"
OUTPUT_CSV="sims.csv"
OUTPUT_IMAGE="plot.png"
# === 1. Prompt for Bearer token ===
read -p "Enter your Bearer token: " AUTH_TOKEN
@thierrymoudiki
thierrymoudiki / Makefile
Last active October 27, 2024 07:09
Makefile for working with Rmd and Rnw scripts
.PHONY: clean getwd initialize help render-rnw render-rmd setwd
.DEFAULT_GOAL := help
define BROWSER_PYSCRIPT
import os, webbrowser, sys
from urllib.request import pathname2url
# The input is expected to be the full HTML filename
filename = sys.argv[1]
filepath = os.path.abspath(os.path.join(filename))
import numpy as np
from typing import Any, Callable, Iterable
from math import factorial
from itertools import chain, combinations
class ShapFromScratchExplainer():
def __init__(self,
model: Callable[[np.ndarray], float],
background_dataset: np.ndarray,
max_samples: int = None):
@thierrymoudiki
thierrymoudiki / gist:16b91f6c61232d8b9592f0212d8d68c2
Last active November 1, 2024 09:27
`curl` examples for Techtonique API
@thierrymoudiki
thierrymoudiki / Makefile
Last active January 14, 2025 08:33
R package workflow (assuming you're on macOS or Linux). You can chain commands `make check&&make install`. See also https://thierrymoudiki.github.io/blog/2024/08/30/r/makefile-r-pkg2.
.PHONY: build buildsite check clean cleanvars coverage docs getwd initialize install installcranpkg installgithubpkg installedpkgs load removepkg render setwd start test usegit
.DEFAULT_GOAL := help
# The directory where R files are stored
R_DIR = ./R
define BROWSER_PYSCRIPT
import os, webbrowser, sys
from urllib.request import pathname2url
@thierrymoudiki
thierrymoudiki / techtonique_learningmachine_conformal_KRR.R
Last active October 26, 2023 16:18
Conformal Kernel Ridge Regression on small data
# rm(list=ls())
install.packages('learningmachine',
repos = c('https://techtonique.r-universe.dev',
'https://cloud.r-project.org'))
# or
# install.packages("remotes", repos = c(CRAN="https://cloud.r-project.org"))
#remotes::install_github("Techtonique/learningmachine")
library(learningmachine)