我不断收到错误消息:未为以下内容定义 logm。关于为什么这不起作用的任何想法?我是否导入了不正确的模块?
import re
import pandas as pd
beer = pd.read_csv('http://www-958.ibm.com/software/analytics/manyeyes/datasets/af-er-beer-dataset/versions/1.txt', delimiter="\t")
beer = beer.dropna()
def good(x):
if x > 4.3:
return 1
else:
return 0
beer['Good'] = beer['WR'].apply(good)
以上效果很好。如果我尝试运行以下命令,我会发现错误:
input = beer[ ['Reviews', 'ABV'] ].values
good = beer['Good'].values
logm.fit(input, good)
logm.predict(input)
logm.score(input, good)
input = beer[ ['Ale', 'Stout', 'IPA', 'Lager'] ].values
y = beer['Good'].values
logm.fit(input, y)