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
### Keybase proof
I hereby claim:
* I am clementpoiret on github.
* I am poiretclement (https://keybase.io/poiretclement) on keybase.
* I have a public key ASBOUBaTcj1-ZzN4X3P1HJ3zh7VZ1hVrQu3HOHJPobWiOgo
To claim this, I am signing this object:
import numpy as np # Generating the data
import matplotlib.pyplot as plt # Visualization
from sklearn.linear_model import LinearRegression # Linear Regression Implementation
# 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);
# 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)
# 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();
# 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))
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@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(),
@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 :)"""