Skip to content

Instantly share code, notes, and snippets.

View glemaitre's full-sized avatar

Guillaume Lemaitre glemaitre

View GitHub Profile
# %%
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
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)
import asyncio
import random
import time
from concurrent.futures import ProcessPoolExecutor
def simulator_submission():
"""Give ``None`` or a submission id."""
return random.choice([random.randint(0, 1000), None])
In [16]: df = pd.DataFrame({'A': [1, 2, 1, 2, 1, 2, 3, 3]})
In [17]: df2 = df[df['A'].isin([1, 2])]
In [18]: df2.loc[df2['A'] == 1, 'A'] = 4
/home/glemaitre/miniconda3/lib/python3.7/site-packages/pandas/core/indexing.py:189: SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame
See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy
self._setitem_with_indexer(indexer, value)
from sklearn.datasets import load_diabetes
from sklearn.compose import TransformedTargetRegressor
from sklearn.model_selection import GridSearchCV
from sklearn.ensemble import RandomForestRegressor
from sklearn.linear_model import LinearRegression
X, y = load_diabetes(return_X_y=True)
ttr = TransformedTargetRegressor()
grid = [{'regressor': [RandomForestRegressor()], 'regressor__n_estimators': [10, 20]},
import os
import pandas as pd
import numpy as np
from sklearn.ensemble import make_stack_layer
from sklearn.preprocessing import FunctionTransformer
from sklearn.experimental import make_column_transformer
from sklearn.pipeline import make_pipeline
from sklearn.preprocessing import StandardScaler
from sklearn.preprocessing import CategoricalEncoder
['/home/glemaitre/Documents/data/cycling/user_3/2015/2015-01-03-10-28-33.fit',
'/home/glemaitre/Documents/data/cycling/user_3/2015/2015-01-09-18-14-34.fit',
'/home/glemaitre/Documents/data/cycling/user_3/2015/2015-01-16-18-20-45.fit',
'/home/glemaitre/Documents/data/cycling/user_3/2015/2015-01-22-17-58-25.fit',
'/home/glemaitre/Documents/data/cycling/user_3/2015/2015-01-23-17-36-40.fit',
'/home/glemaitre/Documents/data/cycling/user_3/2015/2015-01-30-18-03-10.fit',
'/home/glemaitre/Documents/data/cycling/user_3/2015/2015-02-01-17-14-54.fit',
'/home/glemaitre/Documents/data/cycling/user_3/2015/2015-02-06-18-22-13.fit',
'/home/glemaitre/Documents/data/cycling/user_3/2015/2015-02-13-18-21-15.fit',
'/home/glemaitre/Documents/data/cycling/user_3/2015/2015-02-14-09-05-54.fit',
# --- ploting the original angles ---#
fig, xxx = plt.subplots(nrows=3, ncols=2, figsize=(18, 10), sharex=True)
((ax0, ax1), (ax2, ax3), (ax4, ax5)) = xxx
ax0.plot(imu_eG[:, 0], '-', c='k', linewidth=3, label='GT', alpha=0.8)
ax0.plot(pre_angle[:, 0], ':', lw=2,
label=r'No noise$= {:1.3f} \pm {:1.3f}$'.format(0.087, 0.078))
ax0.plot(pre_angle[:, 0] + np.random.random(pre_angle[:, 0].shape) - 0.5, '-.', lw=2,
label=r'Noisy$= {:1.3f} \pm {:1.3f}$'.format(0.087, 0.078))
from abc import ABCMeta, abstractmethod
from random import randint
import six
class BaseChiffrement(six.with_metaclass(ABCMeta)):
@staticmethod
def _check_input(texte, cle):
#cython: cdivision=True
#cython: boundscheck=False
#cython: nonecheck=False
#cython: wraparound=False
from libc.stdlib cimport malloc, free, realloc
import numpy as np
from ..transform import integral_image