This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### 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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np # Generating the data | |
import matplotlib.pyplot as plt # Visualization | |
from sklearn.linear_model import LinearRegression # Linear Regression Implementation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 :)""" |
OlderNewer