방금 spark를 사용하기 시작했고 로지스틱 회귀 분석을 실행하려고합니다. 이 오류가 계속 : 나는 21이 기능의스파크 로지스틱 회귀 오류 치수 불일치
Caused by: java.lang.IllegalArgumentException: requirement failed:
Dimensions mismatch when adding new sample. Expecting 21 but got 17.
수입니다,하지만 난 17 여기에 무엇을 의미하는지 모르겠어요. 무엇을해야할지 모르십니까? 내 코드는 여기에 있습니다 :
from pyspark.mllib.regression import LabeledPoint
from numpy import array
def isfloat(string):
try:
float(string)
return True
except ValueError:
return False
def parse_interaction(line):
line_split = line.split(",")
# leave_out = [1,2,3]
clean_line_split = line_split[3:24]
retention = 1.0
if line_split[0] == '0.0':
retention = 0.0
return LabeledPoint(retention, array([map(float,i) for i in clean_line_split if isfloat(i)]))
training_data = raw_data.map(parse_interaction)
from pyspark.mllib.classification import LogisticRegressionWithLBFGS
from time import time
t0 = time()
logit_model = LogisticRegressionWithLBFGS.train(training_data)
tt = time() - t0
print "Classifier trained in {} seconds".format(round(tt,3))
'배열'을 만들 때 값을 필터링하므로 길이가 0에서 예상되는 크기 사이가 될 수 있습니다. 무엇이든지 잘못된 항목을 삭제하는 것이 더 합리적입니다. – zero323