本文整理汇总了Python中neuralnet.NeuralNet.predict_for_threshold方法的典型用法代码示例。如果您正苦于以下问题:Python NeuralNet.predict_for_threshold方法的具体用法?Python NeuralNet.predict_for_threshold怎么用?Python NeuralNet.predict_for_threshold使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类neuralnet.NeuralNet
的用法示例。
在下文中一共展示了NeuralNet.predict_for_threshold方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from neuralnet import NeuralNet [as 别名]
# 或者: from neuralnet.NeuralNet import predict_for_threshold [as 别名]
def main():
args = get_args()
# f1_matrix holds for every training annotator: the list of tuples of
# avg/med f1_row based on avg/med threshold
f1_matrix = []
# holds for every training annotator: the list of tuples of avg/med threshold
t_matrix = []
current_label_list = []
f1_final = [] # holds 4-tuples of avgs over (f1_avg_avg, f1_avg_med, f1_med_avg, f1_med_med) f.e. tr
t_final = [] # holds 4-tuples of (t_avg_avg, t_avg_med, t_med_avg, t_med_med) f.e. tr
#X_tr, _, v = feats_and_classify_py2.collect_features(args.parsed_file)
with open('X_train.pickle', 'rb') as pf:
X_tr = pickle.load(pf)
with open('X_test.pickle', 'rb') as pf:
X_te = pickle.load(pf)
y_tr = feats_and_classify_py2.collect_labels_positive_threshold(args.all_annotations_file, 1)
#X_out, _, _ = feats_and_classify_py2.collect_features(args.predictfile)
# filter for targets
#X_out = [x for x in X_out if not x.label == '?']
conf = NeuralNetConfig(X=X_tr, y=y_tr, layers=args.layers, iterations=args.iterations, verbose=args.verbose)
nn = NN(conf)
nn.train(X_tr, y_tr)
if args.threshold:
preds = nn.predict_for_threshold(X_te, args.threshold)
else:
preds = nn.get_output(X_te)
with open(args.output, 'w') as outfile:
for p in preds:
#print(p)
outfile.write(str(p))
outfile.write('\n')
sys.exit(0)