python - 使用 joblib 腌制文件时出现 TypeError
问题描述
我正在开发用于异常检测的扩展隔离林。alogirthm 的 Gihub 链接在此处。训练后我无法腌制模型。我该如何解决这个错误。
iso_forest_model = iso.iForest(X , ntrees=100, sample_size=256, ExtensionLevel=1)
import joblib
joblib.dump(iso_forest_model, os.path.join(models_path,'extended_isolation_forest.pkl'), compress=9)
错误
--------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-36-6b85f8a16cb7> in <module>()
6
7 import joblib
----> 8 joblib.dump(iso_forest_model, os.path.join(models_path,'extended_isolation_forest.pkl'), compress=9)
4 frames
/usr/local/lib/python3.7/dist-packages/joblib/numpy_pickle.py in dump(value, filename, compress, protocol, cache_size)
475 with _write_fileobject(filename, compress=(compress_method,
476 compress_level)) as f:
--> 477 NumpyPickler(f, protocol=protocol).dump(value)
478 elif is_filename:
479 with open(filename, 'wb') as f:
/usr/lib/python3.7/pickle.py in dump(self, obj)
435 if self.proto >= 4:
436 self.framer.start_framing()
--> 437 self.save(obj)
438 self.write(STOP)
439 self.framer.end_framing()
/usr/local/lib/python3.7/dist-packages/joblib/numpy_pickle.py in save(self, obj)
280 return
281
--> 282 return Pickler.save(self, obj)
283
284
/usr/lib/python3.7/pickle.py in save(self, obj, save_persistent_id)
522 reduce = getattr(obj, "__reduce_ex__", None)
523 if reduce is not None:
--> 524 rv = reduce(self.proto)
525 else:
526 reduce = getattr(obj, "__reduce__", None)
/usr/local/lib/python3.7/dist-packages/eif.cpython-37m-x86_64-linux-gnu.so in eif.iForest.__reduce_cython__()
TypeError: no default __reduce__ due to non-trivial __cinit__
解决方案
推荐阅读
- c++ - 在同一个互斥锁上的锁定和解锁顺序是否一致?
- c - 在 Mac/Windows 上编译 C 代码以在 Linux 上运行
- react-native - React Native 中的重新渲染问题
- vue.js - 渲染错误:“错误:在条件渲染中找不到模块'./432.jpg'”
- amazon-web-services - Delphi 10.4 Amazon aws S3 连接错误
- swift - iOS - Xcode 控制台中的约束警告
- javascript - 使用画布绘制未获得预期的画布输出
- xero-api - 如何将 Xero api 调用次数减少到每天 5000 次以下限制?
- java - 更改对象存在的arraylist字段的值
- javascript - 如何在字符串数组中分隔字符串