Skip to content

Instantly share code, notes, and snippets.

View thierrymoudiki's full-sized avatar

Thierry Moudiki thierrymoudiki

View GitHub Profile
@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)
@thierrymoudiki
thierrymoudiki / Ruby with chruby
Created August 22, 2023 01:33 — forked from rubyandcoffee/Ruby with chruby
chruby - Installing and managing Ruby versions
To install chruby and ruby-install:
brew install chruby ruby-install
To install Ruby using ruby-install:
ruby-install ruby 2.7.1
NOTE: You can find latest stable version of Ruby here: https://www.ruby-lang.org/en/downloads/
If you have issues installing Ruby then try the following:
brew install openssl@3
ruby-install 3.2.2 -- --with-openssl-dir=$(brew --prefix openssl@3)
@thierrymoudiki
thierrymoudiki / SmithWilson.R
Last active August 29, 2015 14:21
Annuity value with UFR method
# Wilson function
fonctionsWilson <- function(t,u,alpha,UFR)
{
N <- length(u)
J <- length(t)
u_mat <- matrix(rep.int(u,J), nrow=J, byrow=T)
t_mat <- t(matrix(rep.int(t,N), nrow=N, byrow=T))
min_u <- u_mat*(u_mat<=t_mat) + t_mat*(u_mat>t_mat)
max_u <- u_mat + t_mat - min_u
return(exp(-UFR*(u_mat+t_mat))*(alpha*min_u - 0.5*exp(-alpha*max_u)*(exp(alpha*min_u)-exp(-alpha*min_u))))