내가 광장 오류의 합계 (SSE)을 계산하기 위해 노력하고 반복 가능한되지는 코드계산 SSE지고 오류가 있지만 'numpy.float64'개체가
def SSEadver(tv_train,radio_train,newsppr_train,y_train):
y_train_predct = []
sse_train = 0
y_train_predct_srs = 0
# Calculating the predicted sales values on training data
for i in range(0,len(tv_train)):
y_train_predct.append(2.8769666223179353 + (0.04656457* tv_train.iloc[i])+ (0.17915812*(radio_train.iloc[i])) + (0.00345046*(newsppr_train.iloc[i])))
# ** Here I Convert y_train_predct's type List to Series, but still it is showing type as list**
y_train_predct_srs = pd.Series(y_train_predct)
# *** Due above converting not working here y_train_predct_srs.iloc[j]) is not working***
# Now calculate SSE (sum of Squared Errors)
for j in range (len(y_train)):
sse_train += sum((y_train.iloc[j] - y_train_predct_srs.iloc[j])**2)
return y_train_predct, y_train_predct_srs
sse_train = SSEadver(tv_train,radio_train,newsppr_train, y_train)
아래에 언급 I 동안 내가 오류가 점점 오전이 코드를 실행 :
TypeError Traceback (most recent call last)
<ipython-input-446-576e1af02461> in <module>()
20 return y_train_predct, y_train_predct_srs
21
---> 22 sse_train = SSEadver(tv_train,radio_train,newsppr_train, y_train)
23
<ipython-input-446-576e1af02461> in SSEadver(tv_train, radio_train, newsppr_train, y_train)
14 # Now calculate SSE (sum of Squared Errors)
15 for j in range (len(y_train)):
---> 16 sse_train += sum((y_train.iloc[j] - y_train_predct_srs.iloc[j])**2)
17
18
TypeError: 'numpy.float64' object is not iterable
은 왜 생을 얻고있다 s의 오류? 파이썬 3.X.X가
[ 'numpy.float64'개체는 반복 불가 - 의미 클러스터링] (https://stackoverflow.com/questions/39048355/numpy-float64-object-is-not-iterable-meanshift-clustering) – Sombrero
# y_train_predct 타입을 List to Series로 변환하려고했으나 Pandas Data Series 대신 Tuple로 변환되었습니다. ** y_train_predct_srs = pd.Series (y_train_predct) ** – user3631357
하지만 동일한 코드 행은 개별 셀에서 실행되면 팬더 시리즈로 변환됩니다. 왜 듀얼 동작을합니까? 도와주세요. – user3631357