テキストファイルからデータを読み取ってテキストファイルに出力する単純なベイズ分類器を構築しようとしていますが、戻り値が関数の外にあるというエラーがコードに表示されますが、エラーは表示されません
# compute the relative frequencies of the
# 2nd explanatory variable taking on the
# values 'A', 'B' and 'C'
# and return a dictionary with these values
def getCatProbs(self, data):
a_count = 0
b_count = 0
c_count = 0
probs = {}
for row in data:
if row[1] == ">50K":
a_count = a_count + 1
if row[1] == "<=50K":
b_count = b_count + 1
else:
c_count = c_count + 1
probs[">50K"] = float(a_count)/len(data)
probs["<=50K"] = float(b_count)/len(data)
probs['C'] = float(c_count)/len(data)
return probs