Я пытаюсь запустить этот ноутбук . На Azure работает нормально. Однако, когда я пытаюсь запустить его в Visual Studio Code, все ячейки работают нормально, кроме последней:
levels = {0:'setosa', 1:'versicolor', 2:'virginica'}
iris_test['Species'] = [levels[x] for x in iris_test['predicted']]
markers = {1:'^', 0:'o'}
colors = {'setosa':'blue', 'versicolor':'green', 'virginica':'red'}
def plot_shapes(df, col1,col2, markers, colors):
import matplotlib.pyplot as plt
import seaborn as sns
ax = plt.figure(figsize=(6, 6)).gca() # define plot axis
for m in markers: # iterate over marker dictioary keys
for c in colors: # iterate over color dictionary keys
df_temp = df[(df['correct'] == m) & (df['Species'] == c)]
sns.regplot(x = col1, y = col2,
data = df_temp,
fit_reg = False,
scatter_kws={'color': colors[c]},
marker = markers[m],
ax = ax)
plt.xlabel(col1)
plt.ylabel(col2)
plt.title('Iris species by color')
return 'Done'
plot_shapes(iris_test, 'Petal_Width', 'Sepal_Length', markers, colors)
plot_shapes(iris_test, 'Sepal_Width', 'Sepal_Length', markers, colors)
При выполнении вышеуказанного блока кода я получаю следующую ошибку:
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
in
31 plt.title('Iris species by color')
32 return 'Done'
---> 33 plot_shapes(iris_test, 'Petal_Width', 'Sepal_Length', markers, colors)
34 #plot_shapes(iris_test, 'Sepal_Width', 'Sepal_Length', markers, colors)
35 #iris_test.head()
in plot_shapes(df, col1, col2, markers, colors)
16 scatter_kws={'color': colors[c]},
17 marker = markers[m],
---> 18 ax = ax)
19
20 for m in markers: # iterate over marker dictioary keys
C:\ProgramData\anaconda3\lib\site-packages\seaborn\regression.py in regplot(x, y, data, x_estimator, x_bins, x_ci, scatter, fit_reg, ci, n_boot, units, seed, order, logistic, lowess, robust, logx, x_partial, y_partial, truncate, dropna, x_jitter, y_jitter, label, color, marker, scatter_kws, line_kws, ax)
808 order, logistic, lowess, robust, logx,
809 x_partial, y_partial, truncate, dropna,
--> 810 x_jitter, y_jitter, color, label)
811
812 if ax is None:
C:\ProgramData\anaconda3\lib\site-packages\seaborn\regression.py in __init__(self, x, y, data, x_estimator, x_bins, x_ci, scatter, fit_reg, ci, n_boot, units, seed, order, logistic, lowess, robust, logx, x_partial, y_partial, truncate, dropna, x_jitter, y_jitter, color, label)
112 # Drop null observations
113 if dropna:
--> 114 self.dropna("x", "y", "units", "x_partial", "y_partial")
115
116 # Regress nuisance variables out of the data
C:\ProgramData\anaconda3\lib\site-packages\seaborn\regression.py in dropna(self, *vars)
64 val = getattr(self, var)
65 if val is not None:
---> 66 setattr(self, var, val[not_na])
67
68 def plot(self, ax):
IndexError: invalid index to scalar variable.
Моя Python Версия: 3.7.6 64-разрядная ('base': conda) и версия VSCode: 1.46.1
Я уже видел другие связанные вопросы, но все еще не могу решить проблему .
Помогите, пожалуйста, как мне избавиться от этой ошибки.