Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 hidden or 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
# %% | |
# Download the original dataset to be able to easily build an index with the | |
# original datetime. | |
# The dataset is available at: | |
# https://archive.ics.uci.edu/ml/machine-learning-databases/00275/Bike-Sharing-Dataset.zip | |
import pandas as pd | |
df_external = pd.read_csv( | |
"~/Downloads/Bike-Sharing-Dataset/hour.csv", | |
index_col=0, |
This file contains hidden or 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
# %% | |
from sklearn.datasets import fetch_openml | |
usps = fetch_openml(data_id=41082) | |
# %% | |
data = usps.data | |
target = usps.target | |
# %% |
This file contains hidden or 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 | |
import pandas as pd | |
def calcul_chute_tension( | |
Ib=1, S=1.5, Un=400, L=0.1, metal="cuivre", phi=np.arccos(0.85) | |
): | |
Ib = np.asarray(Ib) | |
S = np.asarray(S) |
This file contains hidden or 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 pandas as pd | |
import pytest | |
def func(expected_columns): | |
df = pd.DataFrame({ | |
"A": [1, 2, 3], | |
"B": [1, 2, 3], | |
"C": [1, 2, 3] |
This file contains hidden or 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
@pytest.mark.parametrize("name, Tree", REG_TREES.items()) | |
@pytest.mark.parametrize("criterion", REG_CRITERIONS) | |
def test_diabetes_overfit(name, Tree, criterion): | |
# check consistency of overfitted trees on the diabetes dataset | |
# since the trees will overfit, we expect an MSE of 0 | |
reg = Tree(criterion=criterion, random_state=0) | |
reg.fit(diabetes.data, diabetes.target) | |
score = mean_squared_error(diabetes.target, reg.predict(diabetes.data)) | |
assert score == pytest.approx(0), ( | |
f"Failed with {name}, criterion = {criterion} and score = {score}" |
This file contains hidden or 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
In [1]: import numpy as np | |
In [2]: X = ["One", "string"] | |
In [3]: X | |
Out[3]: ['One', 'string'] | |
In [4]: X[0] | |
Out[4]: 'One' |
This file contains hidden or 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
# %% | |
from sklearn.datasets import make_classification | |
from sklearn.model_selection import StratifiedShuffleSplit | |
from sklearn.preprocessing import StandardScaler | |
from sklearn.linear_model import LogisticRegression | |
from sklearn.pipeline import make_pipeline | |
from sklearn.model_selection import cross_validate | |
RANDOM_SEED = 2 |
This file contains hidden or 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 cv2 | |
import matplotlib.pyplot as plt | |
from matplotlib.animation import FuncAnimation | |
def grab_frame(cap): | |
_, frame = cap.read() | |
return cv2.cvtColor(frame,cv2.COLOR_BGR2RGB) | |
NewerOlder