Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _get_kernel(self, X, Y=None):
return cdist_gak(X, Y, sigma=self.sigma, n_jobs=self.n_jobs)
X = to_time_series_dataset(X)
if fit_time:
self._X_fit = X
self.gamma_ = gamma_soft_dtw(X)
self.classes_ = numpy.unique(y)
if self.kernel in VARIABLE_LENGTH_METRICS:
assert self.kernel == "gak"
self.estimator_kernel_ = "precomputed"
if fit_time:
sklearn_X = cdist_gak(X,
sigma=numpy.sqrt(self.gamma_ / 2.),
n_jobs=self.n_jobs)
else:
sklearn_X = cdist_gak(X,
self._X_fit,
sigma=numpy.sqrt(self.gamma_ / 2.),
n_jobs=self.n_jobs)
else:
self.estimator_kernel_ = self.kernel
sklearn_X = _prepare_ts_datasets_sklearn(X)
if y is None:
return sklearn_X
else:
return sklearn_X, y
else:
X, y = check_X_y(X, y, allow_nd=True,
force_all_finite=force_all_finite)
X = check_dims(X, X_fit=None)
X = to_time_series_dataset(X)
if fit_time:
self._X_fit = X
self.gamma_ = gamma_soft_dtw(X)
self.classes_ = numpy.unique(y)
if self.kernel in VARIABLE_LENGTH_METRICS:
assert self.kernel == "gak"
self.estimator_kernel_ = "precomputed"
if fit_time:
sklearn_X = cdist_gak(X,
sigma=numpy.sqrt(self.gamma_ / 2.),
n_jobs=self.n_jobs)
else:
sklearn_X = cdist_gak(X,
self._X_fit,
sigma=numpy.sqrt(self.gamma_ / 2.),
n_jobs=self.n_jobs)
else:
self.estimator_kernel_ = self.kernel
sklearn_X = _prepare_ts_datasets_sklearn(X)
if y is None:
return sklearn_X
else:
return sklearn_X, y