Commit e242f16d authored by Antoine Guillaume's avatar Antoine Guillaume

Pushing last server version

parent 1cf8d981
...@@ -588,7 +588,7 @@ for i_r, dic_func in enumerate([get_R1_dict]): ...@@ -588,7 +588,7 @@ for i_r, dic_func in enumerate([get_R1_dict]):
X = np.array([apply_code_dict(x[0], code_dict).resample(resample_freq, on='date').mean().reindex(pd.date_range(start = x[2][0], end = x[2][1], freq=resample_freq)).fillna(fill_value).values for x in life_cycles if x is not None],dtype='float') X = np.array([apply_code_dict(x[0], code_dict).resample(resample_freq, on='date').mean().reindex(pd.date_range(start = x[2][0], end = x[2][1], freq=resample_freq)).fillna(fill_value).values for x in life_cycles if x is not None], dtype='float')
y = np.asarray([x[1] for x in life_cycles if x is not None]).astype(int) y = np.asarray([x[1] for x in life_cycles if x is not None]).astype(int)
print(X.shape) print(X.shape)
......
...@@ -170,15 +170,20 @@ class MatrixProfile_transform(): ...@@ -170,15 +170,20 @@ class MatrixProfile_transform():
return self return self
class ROCKET_transform(BaseEstimator, TransformerMixin): class ROCKET_transform(BaseEstimator, TransformerMixin):
def __init__(self, n_kernels=20000, kernel_sizes=(5,7,9,11), flatten=False, random_state=None): def __init__(self, n_kernels=20000, kernel_sizes=(5,7,9,11), normalise=True, flatten=False, random_state=None):
self.flatten = flatten self.flatten = flatten
self.n_kernels = n_kernels self.n_kernels = n_kernels
self.kernel_sizes = kernel_sizes self.kernel_sizes = kernel_sizes
self.random_state = random_state self.random_state = random_state
self.normalise = normalise
self.transformer = None self.transformer = None
def transform(self, X, y=None): def transform(self, X, y=None):
X = X.reshape(X.shape[0],X.shape[1]) X = X.reshape(X.shape[0],X.shape[1])
if self.normalise:
X = (X - X.mean(axis=-1, keepdims=True)) / (
X.std(axis=-1, keepdims=True) + 1e-8
)
X = self.transformer.transform(X) X = self.transformer.transform(X)
if self.flatten: if self.flatten:
X = X.reshape(X.shape[0], X.shape[1]) X = X.reshape(X.shape[0], X.shape[1])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment