Tento kód byl funkční a byl vrácen do státu, kde bylo fungování, ale je nyní unfunctionial. Může mi někdo pomoci vyřešit chybu
import pandas as pd
import seaborn as sns
import numpy as np
import matplotlib.pyplot as plt
sns.set_theme(style="whitegrid")
iris = sns.load_dataset("iris")
dataset1 = iris
from scipy.stats import linregress
x = np.linspace(0,7,8)
y = a*x + b
plt.plot(x, y, 'r', label='Y = aX + b')
x = dataset1['petal_length'].to_numpy(dtype = float)
y = dataset1['sepal_length'].to_numpy(dtype = float)
a, b, r ,p, stderr = linregress(x,y)
print("\na: {:.4f}".format(a))
print("\nb: {:.4f}".format(b))
print("\nR Sqaured: {:.4f}".format(r**2))
sns.scatterplot(data=dataset1, x = 'petal_length', y = 'sepal_length')
plt.show()
chyba přijatá
ValueError Traceback (most recent call last)
<ipython-input-185-aa2ea9694f18> in <module>
2
3 x = np.linspace(0,7,8)
----> 4 y = a*x + b
5 plt.plot(x, y, 'r', label='Y = aX + b')
6
ValueError: operands could not be broadcast together with shapes (3,4) (8,)
nová chyba jednoho seaborn byla odinstalována a znovu
NameError Traceback (most recent call last)
<ipython-input-27-0c657297db5a> in <module>
2
3 x = np.linspace(8,7,8)
----> 4 y = a*x + b (1)
5 plt.plot(x, y, 'r', label='Y = aX + b')
6
NameError: name 'a' is not defined