小编sof*_*x55的帖子

UsageError: Line magic function `%tensorflow_version` not found

I've got TensorFlow installed on my machine however I'm keep getting the error: UsageError: Line magic function `%tensorflow_version` not found.

Any ideas as to why this is? The code I ran is below (Jupyter Notebook)

%tensorflow_version 1.x
import tensorflow as tf
print(tf.__version__)
Run Code Online (Sandbox Code Playgroud)

python tensorflow jupyter-notebook

16
推荐指数
2
解决办法
1万
查看次数

YellowBrick 导入错误:无法从“sklearn.utils”导入名称“safe_indexing”

我正在尝试为我运行的 K-Means 模型绘制轮廓图,但是,我收到错误:ImportError: cannot import name 'safe_indexing' from 'sklearn.utils.

我最初遇到了这篇文章中描述的 NotFoundError 问题,但是一旦我修复了它,我就遇到了这个问题。我的代码如下:

from yellowbrick.cluster import SilhouetteVisualizer

fig, ax = plt.subplots(2, 2, figsize=(15,8))
for i in range(1,6):
    
    kmeans = KMeans(n_clusters=i, init='k-means++', n_init=10, max_iter=100, random_state=0)
    q, mod = divmod(i, 2)
  
    visualizer = SilhouetteVisualizer(km, colors='yellowbrick', ax=ax[q-1][mod])
    visualizer.fit(ct1)
Run Code Online (Sandbox Code Playgroud)

python scikit-learn yellowbrick

5
推荐指数
1
解决办法
3336
查看次数