Beispiel #1
0
def test_nn():
    req_data = request.get_json()
    print("--------- 1.load data ------------")
    dataTest = load_data(
        [
        req_data['x1']
        , req_data['x2']
        , req_data['x3']
        , req_data['x4']
        , req_data['x5']
        , req_data['x6']
        , req_data['x7']
        , req_data['x8']
        , req_data['x9']
        , req_data['x10']
        , req_data['x11']
        , req_data['x12']
        , req_data['x13']
        , req_data['x14']
        , req_data['x15']
        , req_data['x16']
        , req_data['x17']
        , req_data['x18']
        , req_data['x19']
        ]
    )
    print("--------- 2.load model ------------")
    center, delta, w = load_model("messidor_center.txt", "messidor_delta.txt", "messidor_weight.txt")
    print("--------- 3.get prediction ------------")
    result = get_predict(dataTest, center, delta, w)
    print('result', result)
    print("--------- 4.save result ------------")
    res = save_predict(result)
    return jsonify({  "res": res })
Beispiel #2
0
def start_nn():
    print("--------- 1.load data ------------")
    feature, label, n_output = load_data("data.txt")
    print("--------- 2.training ------------")
    center, delta, w = bp_train(feature, label, 20, 5000, 0.008, n_output)
    print("--------- 3.get prediction ------------")
    result = get_predict(feature, center, delta, w)
    # print("result:", (1 - err_rate(label, result)))
    print("--------- 4.save model and result ------------")
    save_model_result(center, delta, w, result)
    return jsonify({"res": "success"})