-
Notifications
You must be signed in to change notification settings - Fork 11.6k
Closed
Description
Legacy print statements are syntax errors in Python 3 but print() function works as expected in both Python 2 and Python 3. Flake8 finds 52 instances of >> is invalid with print function.
flake8 testing of https://github.com/apachecn/AiLearning on Python 3.7.1
$ flake8 . --count --select=E9,F63,F72,F82 --show-source --statistics
./src/py3.x/ml/7.AdaBoost/roc_test.py:9:30: F821 undefined name 'load_data_set'
data_mat, class_labels = load_data_set('../../../input/7.AdaBoost/horseColicTraining2.txt')
^
./src/py3.x/ml/7.AdaBoost/roc_test.py:11:37: F821 undefined name 'ada_boost_train_ds'
weak_class_arr, agg_class_est = ada_boost_train_ds(data_mat, class_labels, 40)
^
./src/py3.x/ml/7.AdaBoost/roc_test.py:16:5: F821 undefined name 'plot_roc'
plot_roc(agg_class_est.T, class_labels)
^
./src/py3.x/ml/7.AdaBoost/roc_test.py:17:37: F821 undefined name 'load_data_set'
data_arr_test, label_arr_test = load_data_set("../../../input/7.AdaBoost/horseColicTest2.txt")
^
./src/py3.x/ml/7.AdaBoost/roc_test.py:18:9: F821 undefined name 'np'
m = np.shape(data_arr_test)[0]
^
./src/py3.x/ml/7.AdaBoost/roc_test.py:19:20: F821 undefined name 'ada_classify'
predicting10 = ada_classify(data_arr_test, weak_class_arr)
^
./src/py3.x/ml/7.AdaBoost/roc_test.py:20:15: F821 undefined name 'np'
err_arr = np.mat(np.ones((m, 1)))
^
./src/py3.x/ml/7.AdaBoost/roc_test.py:20:22: F821 undefined name 'np'
err_arr = np.mat(np.ones((m, 1)))
^
./src/py3.x/ml/7.AdaBoost/roc_test.py:23:35: F821 undefined name 'np'
err_arr[predicting10 != np.mat(label_arr_test).T].sum(),
^
./src/py3.x/ml/7.AdaBoost/roc_test.py:24:35: F821 undefined name 'np'
err_arr[predicting10 != np.mat(label_arr_test).T].sum() / m
^
./src/py3.x/16.RecommenderSystems/test_基于用户.py:74:28: F821 undefined name 'u'
for v, wuv in sorted(W[u].items, key=itemgetter(1), reverse=True)[0:K]:
^
./src/py3.x/16.RecommenderSystems/test_基于用户.py:74:73: F821 undefined name 'K'
for v, wuv in sorted(W[u].items, key=itemgetter(1), reverse=True)[0:K]:
^
./src/py3.x/16.RecommenderSystems/RS-sklearn-rating.py:47:5: F633 use of >> is invalid with print function
print >> sys.stderr, '开始统计流行item的数量...'
^
./src/py3.x/16.RecommenderSystems/RS-sklearn-rating.py:57:5: F633 use of >> is invalid with print function
print >> sys.stderr, '总共流行item数量 = %d' % item_count
^
./src/py3.x/16.RecommenderSystems/RS-sklearn-rating.py:125:5: F633 use of >> is invalid with print function
print >> sys.stderr, '%s: precision=%.4f \t recall=%.4f \t coverage=%.4f \t popularity=%.4f' % (
^
./src/py3.x/16.RecommenderSystems/RS-itemcf.py:36:9: F633 use of >> is invalid with print function
print >> sys.stderr, 'Similar movie number = %d' % self.n_sim_movie
^
./src/py3.x/16.RecommenderSystems/RS-itemcf.py:37:9: F633 use of >> is invalid with print function
print >> sys.stderr, 'Recommended movie number = %d' % self.n_rec_movie
^
./src/py3.x/16.RecommenderSystems/RS-itemcf.py:52:17: F633 use of >> is invalid with print function
print >> sys.stderr, 'loading %s(%s)' % (filename, i)
^
./src/py3.x/16.RecommenderSystems/RS-itemcf.py:54:9: F633 use of >> is invalid with print function
print >> sys.stderr, 'load %s success' % filename
^
./src/py3.x/16.RecommenderSystems/RS-itemcf.py:84:9: F633 use of >> is invalid with print function
print >> sys.stderr, '分离训练集和测试集成功'
^
./src/py3.x/16.RecommenderSystems/RS-itemcf.py:85:9: F633 use of >> is invalid with print function
print >> sys.stderr, 'train set = %s' % trainset_len
^
./src/py3.x/16.RecommenderSystems/RS-itemcf.py:86:9: F633 use of >> is invalid with print function
print >> sys.stderr, 'test set = %s' % testset_len
^
./src/py3.x/16.RecommenderSystems/RS-itemcf.py:91:9: F633 use of >> is invalid with print function
print >> sys.stderr, 'counting movies number and popularity...'
^
./src/py3.x/16.RecommenderSystems/RS-itemcf.py:101:9: F633 use of >> is invalid with print function
print >> sys.stderr, 'count movies number and popularity success'
^
./src/py3.x/16.RecommenderSystems/RS-itemcf.py:105:9: F633 use of >> is invalid with print function
print >> sys.stderr, 'total movie number = %d' % self.movie_count
^
./src/py3.x/16.RecommenderSystems/RS-itemcf.py:109:9: F633 use of >> is invalid with print function
print >> sys.stderr, 'building co-rated users matrix...'
^
./src/py3.x/16.RecommenderSystems/RS-itemcf.py:119:9: F633 use of >> is invalid with print function
print >> sys.stderr, 'build co-rated users matrix success'
^
./src/py3.x/16.RecommenderSystems/RS-itemcf.py:122:9: F633 use of >> is invalid with print function
print >> sys.stderr, 'calculating movie similarity matrix...'
^
./src/py3.x/16.RecommenderSystems/RS-itemcf.py:133:21: F633 use of >> is invalid with print function
print >> sys.stderr, 'calculating movie similarity factor(%d)' % simfactor_count
^
./src/py3.x/16.RecommenderSystems/RS-itemcf.py:135:9: F633 use of >> is invalid with print function
print >> sys.stderr, 'calculate movie similarity matrix(similarity factor) success'
^
./src/py3.x/16.RecommenderSystems/RS-itemcf.py:136:9: F633 use of >> is invalid with print function
print >> sys.stderr, 'Total similarity factor number = %d' % simfactor_count
^
./src/py3.x/16.RecommenderSystems/RS-itemcf.py:170:9: F633 use of >> is invalid with print function
print >> sys.stderr, 'Evaluation start...'
^
./src/py3.x/16.RecommenderSystems/RS-itemcf.py:188:17: F633 use of >> is invalid with print function
print >> sys.stderr, 'recommended for %d users' % i
^
./src/py3.x/16.RecommenderSystems/RS-itemcf.py:207:9: F633 use of >> is invalid with print function
print >> sys.stderr, 'precision=%.4f \t recall=%.4f \t coverage=%.4f \t popularity=%.4f' % (
^
./src/py3.x/16.RecommenderSystems/RS-usercf.py:36:9: F633 use of >> is invalid with print function
print >> sys.stderr, 'similar user number = %d' % self.n_sim_user
^
./src/py3.x/16.RecommenderSystems/RS-usercf.py:37:9: F633 use of >> is invalid with print function
print >> sys.stderr, 'recommended movie number = %d' % self.n_rec_movie
^
./src/py3.x/16.RecommenderSystems/RS-usercf.py:52:17: F633 use of >> is invalid with print function
print >> sys.stderr, 'loading %s(%s)' % (filename, i)
^
./src/py3.x/16.RecommenderSystems/RS-usercf.py:54:9: F633 use of >> is invalid with print function
print >> sys.stderr, 'load %s success' % filename
^
./src/py3.x/16.RecommenderSystems/RS-usercf.py:84:9: F633 use of >> is invalid with print function
print >> sys.stderr, '分离训练集和测试集成功'
^
./src/py3.x/16.RecommenderSystems/RS-usercf.py:85:9: F633 use of >> is invalid with print function
print >> sys.stderr, 'train set = %s' % trainset_len
^
./src/py3.x/16.RecommenderSystems/RS-usercf.py:86:9: F633 use of >> is invalid with print function
print >> sys.stderr, 'test set = %s' % testset_len
^
./src/py3.x/16.RecommenderSystems/RS-usercf.py:93:9: F633 use of >> is invalid with print function
print >> sys.stderr, 'building movie-users inverse table...'
^
./src/py3.x/16.RecommenderSystems/RS-usercf.py:109:9: F633 use of >> is invalid with print function
print >> sys.stderr, 'build movie-users inverse table success'
^
./src/py3.x/16.RecommenderSystems/RS-usercf.py:113:9: F633 use of >> is invalid with print function
print >> sys.stderr, 'total movie number = %d' % self.movie_count
^
./src/py3.x/16.RecommenderSystems/RS-usercf.py:117:9: F633 use of >> is invalid with print function
print >> sys.stderr, 'building user co-rated movies matrix...'
^
./src/py3.x/16.RecommenderSystems/RS-usercf.py:127:9: F633 use of >> is invalid with print function
print >> sys.stderr, 'build user co-rated movies matrix success'
^
./src/py3.x/16.RecommenderSystems/RS-usercf.py:130:9: F633 use of >> is invalid with print function
print >> sys.stderr, 'calculating user similarity matrix...'
^
./src/py3.x/16.RecommenderSystems/RS-usercf.py:141:21: F633 use of >> is invalid with print function
print >> sys.stderr, 'calculating user similarity factor(%d)' % simfactor_count
^
./src/py3.x/16.RecommenderSystems/RS-usercf.py:143:9: F633 use of >> is invalid with print function
print >> sys.stderr, 'calculate user similarity matrix(similarity factor) success'
^
./src/py3.x/16.RecommenderSystems/RS-usercf.py:144:9: F633 use of >> is invalid with print function
print >> sys.stderr, 'Total similarity factor number = %d' % simfactor_count
^
./src/py3.x/16.RecommenderSystems/RS-usercf.py:185:9: F633 use of >> is invalid with print function
print >> sys.stderr, 'Evaluation start...'
^
./src/py3.x/16.RecommenderSystems/RS-usercf.py:203:17: F633 use of >> is invalid with print function
print >> sys.stderr, 'recommended for %d users' % i
^
./src/py3.x/16.RecommenderSystems/RS-usercf.py:222:9: F633 use of >> is invalid with print function
print >> sys.stderr, 'precision=%.4f \t recall=%.4f \t coverage=%.4f \t popularity=%.4f' % (
^
./src/py3.x/16.RecommenderSystems/test_evaluation_model.py:22:16: F821 undefined name 'GetRecommendation'
rank = GetRecommendation(user, N)
^
./src/py3.x/16.RecommenderSystems/test_evaluation_model.py:36:16: F821 undefined name 'GetRecommendation'
rank = GetRecommendation(user, N)
^
./src/py3.x/16.RecommenderSystems/test_evaluation_model.py:51:16: F821 undefined name 'GetRecommendation'
rank = GetRecommendation(user, N)
^
./src/py3.x/16.RecommenderSystems/test_evaluation_model.py:68:16: F821 undefined name 'GetRecommendation'
rank = GetRecommendation(user, N)
^
./src/py3.x/16.RecommenderSystems/sklearn-RS-demo-cf-item-test.py:46:9: F633 use of >> is invalid with print function
print >> sys.stderr, 'Similar item number = %d' % self.n_sim_item
^
./src/py3.x/16.RecommenderSystems/sklearn-RS-demo-cf-item-test.py:47:9: F633 use of >> is invalid with print function
print >> sys.stderr, 'Recommended item number = %d' % self.n_rec_item
^
./src/py3.x/16.RecommenderSystems/sklearn-RS-demo-cf-item-test.py:63:9: F633 use of >> is invalid with print function
print >> sys.stderr, '分离训练集和测试集成功'
^
./src/py3.x/16.RecommenderSystems/sklearn-RS-demo-cf-item-test.py:64:9: F633 use of >> is invalid with print function
print >> sys.stderr, 'len(train) = %s' % np.shape(self.train_data)[0]
^
./src/py3.x/16.RecommenderSystems/sklearn-RS-demo-cf-item-test.py:65:9: F633 use of >> is invalid with print function
print >> sys.stderr, 'len(test) = %s' % np.shape(self.test_data)[0]
^
./src/py3.x/16.RecommenderSystems/sklearn-RS-demo-cf-item-test.py:84:9: F633 use of >> is invalid with print function
print >> sys.stderr, 'item_mat_similarity=', np.shape(
^
./src/py3.x/16.RecommenderSystems/sklearn-RS-demo-cf-item-test.py:87:9: F633 use of >> is invalid with print function
print >> sys.stderr, '开始统计流行item的数量...'
^
./src/py3.x/16.RecommenderSystems/sklearn-RS-demo-cf-item-test.py:98:9: F633 use of >> is invalid with print function
print >> sys.stderr, '总共流行item数量 = %d' % self.item_count
^
./src/py3.x/16.RecommenderSystems/sklearn-RS-demo-cf-item-test.py:139:9: F633 use of >> is invalid with print function
print >> sys.stderr, 'Evaluation start...'
^
./src/py3.x/16.RecommenderSystems/sklearn-RS-demo-cf-item-test.py:155:17: F633 use of >> is invalid with print function
print >> sys.stderr, 'recommended for %d users' % u_index
^
./src/py3.x/16.RecommenderSystems/sklearn-RS-demo-cf-item-test.py:183:9: F633 use of >> is invalid with print function
print >> sys.stderr, 'precision=%.4f \t recall=%.4f \t coverage=%.4f \t popularity=%.4f' % (
^
./src/py3.x/16.RecommenderSystems/test_lfm.py:12:16: F821 undefined name 'items_pool'
item = items_pool[random.randint(0, len(items_pool) - 1)]
^
./src/py3.x/16.RecommenderSystems/test_lfm.py:12:49: F821 undefined name 'items_pool'
item = items_pool[random.randint(0, len(items_pool) - 1)]
^
./src/py3.x/16.RecommenderSystems/test_lfm.py:23:14: F821 undefined name 'InitModel'
[P, Q] = InitModel(user_items, F)
^
./src/py3.x/16.RecommenderSystems/test_lfm.py:26:23: F821 undefined name 'RandSelectNegativeSamples'
samples = RandSelectNegativeSamples(items)
^
./src/py3.x/16.RecommenderSystems/test_lfm.py:28:29: F821 undefined name 'Predict'
eui = rui - Predict(user, item)
^
./src/py3.x/16.RecommenderSystems/test_基于物品.py:10:18: F821 undefined name 'users'
for i in users:
^
./src/py3.x/16.RecommenderSystems/test_基于物品.py:12:22: F821 undefined name 'users'
for j in users:
^
./src/py3.x/16.RecommenderSystems/test_基于物品.py:21:18: F821 undefined name 'v'
W[u][v] = cij / math.sqrt(N[i] * N[j])
^
./src/py3.x/16.RecommenderSystems/test_基于物品.py:30:18: F821 undefined name 'users'
for i in users:
^
./src/py3.x/16.RecommenderSystems/test_基于物品.py:32:22: F821 undefined name 'users'
for j in users:
^
./src/py3.x/16.RecommenderSystems/test_基于物品.py:41:18: F821 undefined name 'v'
W[u][v] = cij / math.sqrt(N[i] * N[j])
^
./src/py3.x/dl/perceptron.py:192:22: F821 undefined name 'train_and_perceptron'
and_perceptron = train_and_perceptron()
^
52 F633 use of >> is invalid with print function
28 F821 undefined name 'GetRecommendation'
80
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels