Skip to content

Instantly share code, notes, and snippets.

View clementpoiret's full-sized avatar
💭
I may be slow to respond.

Clément POIRET clementpoiret

💭
I may be slow to respond.
View GitHub Profile
@clementpoiret
clementpoiret / volume.py
Created February 15, 2024 07:35
Compute the volume of an MRI segmentation
import ants
import click
import numpy as np
from rich.console import Console
from rich.table import Table
CLASS_LABELS = ["Dentate Gyrus", "CA1", "CA2", "CA3", "Subiculum"]
@click.command()
@clementpoiret
clementpoiret / PKGBUILD
Last active April 23, 2024 09:50
hyprland-displaylink-git
# Maintainer: Clément POIRET <poiret dot clement at outlook dot fr>
_pkgname="hyprland"
pkgname="${_pkgname}-displaylink-git"
pkgver="0.38.1"
pkgrel=1
pkgdesc="A dynamic tiling Wayland compositor based on wlroots that doesn't sacrifice on its looks. (DisplayLink patch)"
arch=(any)
url="https://github.com/hyprwm/Hyprland"
license=('BSD')
@clementpoiret
clementpoiret / compare.py
Last active January 20, 2023 13:35
Comparing OpenAI's Codex & ChatGPT, to GitHub's Copilot
import time
import pandas as pd
import numpy as np
import pingouin as pg
from scipy.stats import pearsonr
def mse(y, y_hat):
"""Let's define a dummy error term :)"""
@clementpoiret
clementpoiret / metrics.py
Created August 26, 2021 12:20
Individual Metrics
import torch
import pymia.evaluation.evaluator as eval_
import pymia.evaluation.metric as metric
y = torch.randint(0, 4, (1, 16, 16, 16))
y_hat = y * .8 - 1
metrics = [
metric.DiceCoefficient(),
metric.VolumeSimilarity(),
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
# Prediction
observation = np.array(1).reshape(-1,1)
y_pred = model.predict(observation)
y_truth = gradient * observation + w0
print("Prediction : {}\nTruth : {}".format(y_pred, y_truth))
# Showing data, alongside prediction
x = np.linspace(0, 2, 10).reshape(-1, 1)
y_truth = gradient * x + w0
y_estimated = model.coef_ * x + model.intercept_
plt.scatter(X_train, y_train, label="Data")
plt.plot(x, y_truth, label="Truth")
plt.plot(x, y_estimated, label="Model")
plt.legend();
# Model's Definition and Training
model = LinearRegression(fit_intercept = True)
model.fit(X_train, y_train)
# Creating test sets
X_test = 2 * np.random.random_sample((10, 1))
y_test = gradient * X_test + w0 + 0.1 * np.random.random_sample((10, 1))
# Score
r2 = model.score(X_test, y_test)
# Model's Definition and Training
model = LinearRegression(fit_intercept = True)
model.fit(X_train, y_train)
# Creating test sets
X_test = 2 * np.random.random_sample((10, 1))
y_test = gradient * X_test + w0 + 0.1 * np.random.random_sample((10, 1))
# Score
r2 = model.score(X_test, y_test)
# Real Parameters
gradient = 0.5
w0 = 1
# Data synthesis
X_train = 2 * np.random.random_sample((20, 1))
y_train = gradient * X_train + w0 + 0.1 * np.random.random_sample((20, 1))
# Plot
plt.scatter(X_train, y_train);