本文整理汇总了Python中Model.Model.predict方法的典型用法代码示例。如果您正苦于以下问题:Python Model.predict方法的具体用法?Python Model.predict怎么用?Python Model.predict使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Model.Model
的用法示例。
在下文中一共展示了Model.predict方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test
# 需要导入模块: from Model import Model [as 别名]
# 或者: from Model.Model import predict [as 别名]
def test(X_train_files, y_train_files, X_test_files, y_test_files, train_out_file, test_out_file,
train_bad_out_file=None, test_bad_out_file=None,
model=None, C_set=None, gamma_set=None, epsilon_set=None, k=None):
X_train = []
y_train = []
X_test = []
y_test = []
for file in X_train_files:
X_train.extend(load_data_X(file))
for file in y_train_files:
y_train.extend(load_data_y(file))
for file in X_test_files:
X_test.extend(load_data_X(file))
for file in y_test_files:
y_test.extend(load_data_y(file))
if model is None:
if C_set is None:
C_set = [2 ** x for x in range(-5, 15 + 1)]
if gamma_set is None:
gamma_set = [2 ** x for x in range(-15, 3 + 1)]
if epsilon_set is None:
epsilon_set = [0.0001, 0.0005, 0.001, 0.005, 0.01, 0.02, 0.05, 0.1, 0.15, 0.2, 0.25, 0.3, 0.4, 0.5, 0.6,
0.7, 0.8, 0.9, 1, 2]
if k is None:
k = 10
model = Model()
model.train_k_fold(X_train, y_train, C_set, gamma_set, epsilon_set, k)
print 'C:', model.get_param_C()
print 'epsilon:', model.get_param_epsilon()
print 'gamma:', model.get_param_gamma()
if train_out_file != '':
# print "Tocni (train): ", y_train
predicted_train = model.predict(X_train)
# print "Dobiveni (train): ", predicted_train
write_output(train_out_file, predicted_train)
if (train_bad_out_file is not None):
write_low_scored(train_bad_out_file, X_train, y_train, predicted_train, 50)
if test_out_file != '':
# print "Tocni (test): ", y_test
predicted_test = model.predict(X_test)
# print "Dobiveni (test): ", predicted_test
write_output(test_out_file, predicted_test)
if (test_bad_out_file is not None):
write_low_scored(test_bad_out_file, X_test, y_test, predicted_test, 50)
return model
示例2: interactive_demo
# 需要导入模块: from Model import Model [as 别名]
# 或者: from Model.Model import predict [as 别名]
def interactive_demo(X_train_files, y_train_files, C, gamma, epsilon):
print 'Zapocinje ucenje modela'
X_train = []
y_train = []
for file in X_train_files:
X_train.extend(load_data_X(file))
for file in y_train_files:
y_train.extend(load_data_y(file))
model = Model()
model.train(X_train, y_train, True, C, gamma, epsilon)
print 'Ucenje modela je zavrseno'
while True:
print 'Unesite 1. recenicu:'
x1 = raw_input().decode(sys.stdin.encoding or locale.getpreferredencoding(True))
print 'Unesite 2. recenicu:'
x2 = raw_input().decode(sys.stdin.encoding or locale.getpreferredencoding(True))
x = [x1, x2]
y = model.predict(x)[0]
print clamp(y, 0, 5)