You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I tried to use the Autoencoder model from Pyod for outlier detection, it is a great function for supporting a deep learning model without constructing the neural network on our own.
One issue I found is that it does not provide an option for adjusting batch size in model prediction part. Adjusting batch size is important when the data size varies a lot. It can dramatically affect the time cost dramatically.
Here is the code I am referring to:
def decision_function(self, X):
"""Predict raw anomaly score of X using the fitted detector.
The anomaly score of an input sample is computed based on different
detector algorithms. For consistency, outliers are assigned with
larger anomaly scores.
Parameters
----------
X : numpy array of shape (n_samples, n_features)
The training input samples. Sparse matrices are accepted only
if they are supported by the base estimator.
Returns
-------
anomaly_scores : numpy array of shape (n_samples,)
The anomaly score of the input samples.
"""
check_is_fitted(self, ['model_', 'history_'])
X = check_array(X)
if self.preprocessing:
X_norm = self.scaler_.transform(X)
else:
X_norm = np.copy(X)
# Predict on X and return the reconstruction errors
**pred_scores = self.model_.predict(X_norm)**
return pairwise_distances_no_broadcast(X_norm, pred_scores)
So keras model prediction supports batch size as a parameter. If we could simple adjust the code from pred_scores = self.model_.predict(X_norm) to pred_scores = self.model_.predict(X_norm, batch_size=32) and modify other parts accordingly, it would solve this problem.
Thanks for all your great work.
The text was updated successfully, but these errors were encountered:
Hi,
I tried to use the Autoencoder model from Pyod for outlier detection, it is a great function for supporting a deep learning model without constructing the neural network on our own.
One issue I found is that it does not provide an option for adjusting batch size in model prediction part. Adjusting batch size is important when the data size varies a lot. It can dramatically affect the time cost dramatically.
Here is the code I am referring to:
def decision_function(self, X):
"""Predict raw anomaly score of X using the fitted detector.
So keras model prediction supports batch size as a parameter. If we could simple adjust the code from pred_scores = self.model_.predict(X_norm) to pred_scores = self.model_.predict(X_norm, batch_size=32) and modify other parts accordingly, it would solve this problem.
Thanks for all your great work.
The text was updated successfully, but these errors were encountered: