2
을 얻고 왜이 NaiveBayes
파이썬 라이브러리 (파이썬 2.7)이 코드는 나에게 ZeroDivisionError
을주고 실행 이유가 궁금파이썬 NaiveBayes : 나는 ZeroDivisionError
을 시도하고있다. 그래서 즉, 내 입력 (에 문제가, 내가 베이지안 분류기에 새로운 오전
Traceback (most recent call last):
File "/tmp/py4127eDT", line 24, in <module>
result = model.predict({'attributes': {'Height': 212, 'Weight': 200}})
File "/usr/local/lib/python2.7/dist-packages/NaiveBayes.py", line 152, in predict
scores[label] /= sumPx
ZeroDivisionError: float division by zero
: 숫자의 분포, 또는 충분한 샘플이없는 여기에
#!/usr/bin/env python
import NaiveBayes
model = NaiveBayes.NaiveBayes()
model.set_real(['Height'])
model.set_real(['Weight'])
model.add_instances({'attributes':
{'Height': 239,
'Weight': 231,
},
'cases': 32,
'label': 'Sex=M'})
model.add_instances({'attributes':
{'Height': 190,
'Weight': 152
},
'cases': 58,
'label': 'Sex=F'
})
model.train()
result = model.predict({'attributes': {'Height': 212, 'Weight': 200}})
print("The result is %s" % (result))
그리고
는 출력 ?)
(어두운로 샷)이 수레로 높이와 무게를 강제하는 경우 문제가 지속됩니다? 예 : '239' 대신'239.' 등? –
나는 이것을 시도했지만 일부 입력에 대해서는 작동하지만 전부는 아닙니다. 나는 이유를 모른다. – dg123