2021年3月19日星期五

Trying to calculate de equation for linear regression with numpy.polyfit but getting too many values to unpack (expected 2)

I'm expected to read a column "Horas Estudo" and a number(x) = 5.95 then calculate the y= ax + b.

import pandas as pd  import matplotlib.pyplot as plt  import numpy as np  df = pd.read_csv("https://www.dropbox.com/s/k3owtgaywmjhk66/fake-classrooms-correl03.csv?dl=1")    col = input()  x = round(float(input()),2)    (a,b) = np.polyfit(df[col],df["Nota Final"], deg=2)  print(a,b)    ValueError                                Traceback (most recent call last)    <ipython-input-81-7e077f926863> in <module>()        7 x = round(float(input()),2)        8   ----> 9 (a,b) = np.polyfit(df[col],df["Nota Final"], deg=2)       10 print(a,b)    ValueError: too many values to unpack (expected 2)          
https://stackoverflow.com/questions/66717910/trying-to-calculate-de-equation-for-linear-regression-with-numpy-polyfit-but-get March 20, 2021 at 11:19AM

没有评论:

发表评论