Ejemplo n.º 1
0
def home():
    if request.method == 'GET':
        return render_template('index.html')
    else:
        hours = request.form['hours']
        message = model.answer(hours)
        return render_template('index.html', message=message)
Ejemplo n.º 2
0
def train_and_test(learning_rate, epoch_cnt, tao, train, test, cls):
  train_features, train_answers = split(train)
  train_answers = answers_for_class(train_answers, cls)
  test_features, test_answers = split(test)
  test_answers = answers_for_class(test_answers, cls)
  feature_cnt = len(train_features[0])
  model = Adagrad(learning_rate=learning_rate, epoch_cnt=epoch_cnt, tao=tao, n=feature_cnt)
  model.train(train_features, train_answers)
  model_answers = answer(model.predict(test_features))
  accuracy = calculate_accuracy(model_answers, test_answers)

  return accuracy
Ejemplo n.º 3
0
def get_prediction(context, query, n_clicks, data):
    if data is None:
        data = {}
        data['clicks'] = 1
        return [''], data

    if n_clicks and data['clicks'] <= n_clicks:
        data['clicks'] = n_clicks + 1
        return [answer(context, query)], data

    else:
        print(data, n_clicks)
        return [''], data