在 Google Colab 中使用特定版本的包

Use specific version of package in Google Colab

我有一些模型序列化为 pickle 的文件,但现在当我尝试反序列化它们时,我得到:

UserWarning: Trying to unpickle estimator LogisticRegression from version 1.0.1 when using version 1.0.2. This might lead to breaking code or invalid results. Use at your own risk. For more info please refer to: https://scikit-learn.org/stable/modules/model_persistence.html#security-maintainability-limitations

如何指定 colab 使用该版本的 pickle

Pickle 是 Python 标准库的一部分,因此您不能在不更改 Python 版本的情况下更改其版本。但是,该警告消息指的是 Scikit-learn 的版本,而不是 pickle。您可以按如下方式安装 Scikit-learn 1.0.1:

!pip install scikit-learn==1.0.1