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 encountered an error while using the SUDO code in the tutorial file:
frompyod.models.suodimportSUODfrompyod.models.lofimportLOFfrompyod.models.iforestimportIForestfrompyod.models.copodimportCOPODfrompyod.utils.utilityimportstandardizerfrompyod.utils.dataimportgenerate_datafrompyod.utils.dataimportevaluate_printfrompyod.utils.exampleimportvisualizecontamination=0.1n_train=200n_test=100# Generate sample dataX_train, X_test, y_train, y_test= \
generate_data(n_train=n_train,
n_test=n_test,
n_features=2,
contamination=contamination,
random_state=42)
# train SUODclf_name='SUOD'# initialized a group of outlier detectors for accelerationdetector_list= [LOF(n_neighbors=15), LOF(n_neighbors=20),
LOF(n_neighbors=25), LOF(n_neighbors=35),
COPOD(), IForest(n_estimators=100),
IForest(n_estimators=200)]
# decide the number of parallel process, and the combination methodclf=SUOD(base_estimators=detector_list, n_jobs=2, combination='average',
verbose=False)
# or to use the default detectors# clf = SUOD(n_jobs=2, combination='average',# verbose=False)clf.fit(X_train)
# get the prediction labels and outlier scores of the training datay_train_pred=clf.labels_# binary labels (0: inliers, 1: outliers)y_train_scores=clf.decision_scores_# raw outlier scores# get the prediction on the test datay_test_pred=clf.predict(X_test) # outlier labels (0 or 1)y_test_scores=clf.decision_function(X_test) # outlier scores# evaluate and print the resultsprint("\nOn Training Data:")
evaluate_print(clf_name, y_train, y_train_scores)
print("\nOn Test Data:")
evaluate_print(clf_name, y_test, y_test_scores)
# visualize the resultsvisualize(clf_name, X_train, y_train, X_test, y_test, y_train_pred,
y_test_pred, show_figure=True, save_figure=False)
Detailed error details:
---------------------------------------------------------------------------ValueErrorTraceback (mostrecentcalllast)
CellIn[14], line4441y_train_scores=clf.decision_scores_# raw outlier scores43# get the prediction on the test data--->44y_test_pred=clf.predict(X_test) # outlier labels (0 or 1)45y_test_scores=clf.decision_function(X_test) # outlier scores47# evaluate and print the resultsFile/kaggle/working/pyod/pyod/models/base.py:168, inBaseDetector.predict(self, X, return_confidence)
147"""Predict if a particular sample is an outlier or not. 148 149 Parameters (...) 164 Only if return_confidence is set to True. 165 """167check_is_fitted(self, ['decision_scores_', 'threshold_', 'labels_'])
-->168pred_score=self.decision_function(X)
170ifisinstance(self.contamination, (float, int)):
171prediction= (pred_score>self.threshold_).astype('int').ravel()
File/kaggle/working/pyod/pyod/models/suod.py:260, inSUOD.decision_function(self, X)
257X=check_array(X)
259# initialize the output score-->260predicted_scores=self.model_.decision_function(X)
262# standardize the score and combine263predicted_scores=self.score_scalar_.transform(predicted_scores)
File/opt/conda/lib/python3.10/site-packages/suod/models/base.py:460, inSUOD.decision_function(self, X)
456# decide whether bps is needed457# it is turned off458ifself.bps_flag:
459# load the pre-trained cost predictor to forecast the train cost-->460cost_predictor=joblib.load(self.cost_forecast_loc_pred_)
462time_cost_pred=cost_forecast_meta(cost_predictor, X,
463self.base_estimator_names)
465n_estimators_list, starts, n_jobs=balanced_scheduling(
466time_cost_pred, self.n_estimators, self.n_jobs, self.verbose)
File/opt/conda/lib/python3.10/site-packages/joblib/numpy_pickle.py:658, inload(filename, mmap_mode)
652ifisinstance(fobj, str):
653# if the returned file object is a string, this means we654# try to load a pickle file generated with an version of655# Joblib so we load it with joblib compatibility function.656returnload_compatibility(fobj)
-->658obj=_unpickle(fobj, filename, mmap_mode)
659returnobjFile/opt/conda/lib/python3.10/site-packages/joblib/numpy_pickle.py:577, in_unpickle(fobj, filename, mmap_mode)
575obj=None576try:
-->577obj=unpickler.load()
578ifunpickler.compat_mode:
579warnings.warn("The file '%s' has been generated with a "580"joblib version less than 0.10. "581"Please regenerate this pickle file."582%filename,
583DeprecationWarning, stacklevel=3)
File/opt/conda/lib/python3.10/pickle.py:1213, in_Unpickler.load(self)
1211raiseEOFError1212assertisinstance(key, bytes_types)
->1213dispatch[key[0]](self)
1214except_Stopasstopinst:
1215returnstopinst.valueFile/opt/conda/lib/python3.10/site-packages/joblib/numpy_pickle.py:402, inNumpyUnpickler.load_build(self)
394defload_build(self):
395"""Called to set the state of a newly created object. 396 397 We capture it to replace our place-holder objects, NDArrayWrapper or (...) 400 NDArrayWrapper is used for backward compatibility with joblib <= 0.9. 401 """-->402Unpickler.load_build(self)
404# For backward compatibility, we support NDArrayWrapper objects.405ifisinstance(self.stack[-1], (NDArrayWrapper, NumpyArrayWrapper)):
File/opt/conda/lib/python3.10/pickle.py:1718, in_Unpickler.load_build(self)
1716setstate=getattr(inst, "__setstate__", None)
1717ifsetstateisnotNone:
->1718setstate(state)
1719return1720slotstate=NoneFilesklearn/tree/_tree.pyx:676, insklearn.tree._tree.Tree.__setstate__()
Filesklearn/tree/_tree.pyx:1364, insklearn.tree._tree._check_node_ndarray()
ValueError: nodearrayfromthepicklehasanincompatibledtype:
-expected: [('left_child', '<i8'), ('right_child', '<i8'), ('feature', '<i8'), ('threshold', '<f8'), ('impurity', '<f8'), ('n_node_samples', '<i8'), ('weighted_n_node_samples', '<f8')]
-got : {'names': ['left_child', 'right_child', 'feature', 'threshold', 'impurity', 'n_node_samples', 'weighted_n_node_samples', 'missing_go_to_left'], 'formats': ['<i8', '<i8', '<i8', '<f8', '<f8', '<i8', '<f8', 'u1'], 'offsets': [0, 8, 16, 24, 32, 40, 48, 56], 'itemsize': 64}
scikit_learn version is 1.2.2, joblibversion is 1.2.0
I ran other sample code without any issues, but whenever I use SUOD, I will report the above error
The text was updated successfully, but these errors were encountered:
Hi,
I had the same issue. First with scikit_learn version 1.1.3, then I updated to 1.2.2 (just like you), and finally, I updated to 1.3.0.
Updating to 1.3.0 did the trick for me.
I encountered an error when using SUOD on the Kaggle platform
The process of installing dependent packages is as follows:
I encountered an error while using the SUDO code in the tutorial file:
Detailed error details:
scikit_learn
version is 1.2.2,joblib
version is 1.2.0I ran other sample code without any issues, but whenever I use SUOD, I will report the above error
The text was updated successfully, but these errors were encountered: