python - 如何在 Google Colab 中更新 scikit-learn?

标签 python scikit-learn jupyter-notebook google-colaboratory

我想在 Google Colab 中使用 sklearn.metrics plot_confusion_matrix。它带有 sklearn 0.22 的最新稳定更新。

https://scikit-learn.org/stable/auto_examples/model_selection/plot_confusion_matrix.html#sphx-glr-auto-examples-model-selection-plot-confusion-matrix-py

我试过这个 Make colab use the latest installation of a library

但最后它显示sklearn的版本仍然是0.21。

谢谢

enter image description here

最佳答案

我像您在图像开始时所做的那样从 colab 卸载了 sklearn,然后重新安装了它,并按照 sklearn 文档中提到的那样更新它。我使用的代码如下:

!pip uninstall scikit-learn -y

!pip install -U scikit-learn
在我检查我的版本是否更新后:
import sklearn

sklearn.__version__


'0.24.1'

我希望能帮到你!

关于python - 如何在 Google Colab 中更新 scikit-learn?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59339251/

相关文章:

pandas - 如何将 FastAPI 中的 Pydantic 模型转换为 Pandas DataFrame?

python - 为什么优化模型精度会由于没有预测样本而引发错误 : Precision is ill-defined and being set to 0. 0?

python - 在不平衡样本场景中为每个类提取相同数量的样本

python - 如何防止被零除或替换 Theano 中的无限值?

python - 使用 pyinstaller 创建 Python 可执行文件时未导入的库

python - 朱皮特 : Line magic function not found

python - 如何以编程方式在 Jupyter Notebook 中创建多个新单元格

python - 在 Google DFS 文件夹中运行 jupyter 笔记本时出现 "Save and Checkpoint"错误

python - 以毫秒为单位将 python 日期时间转换为时间戳

python - Win32com python : impossible to access a chart on excel