コード例 #1
0
    def test_01_train_log(self):
        """
        test the train log functionality
        """

        ## train the model
        model_train(DATA_PATH,'unittest',False,'germany')
        self.assertTrue(path.exists(path.join(LOG_PATH,'example-predict-2020-3.log')))
コード例 #2
0
    def test_01_train(self):
        """
        test the train functionality
        """

        ## train the model
        model_train(DATA_PATH, 'unittest', False, 'germany')
        trained_model = path.join(MODEL_PATH, 'unittest-germany-0_1.joblib')
        self.assertTrue(os.path.exists(trained_model))
コード例 #3
0
def main():

    ## train the model
    model_train(test=False)

    ## load the model
    model = model_load()

    print("model training complete.")
コード例 #4
0
def train():
    """
    basic predict function for the API

    the 'mode' flag provides the ability to toggle between a test version and a 
    production verion of training
    """

    ## check for request data
    if not request.json:
        print("ERROR: API (train): did not receive request data")
        return jsonify(False)

    ## set the test flag
    test = False
    if 'mode' in request.json and request.json['mode'] == 'test':
        test = True

    print("... training model")
    train_data_path = os.path.join(DATA_DIR, 'cs-train')
    model_train(train_data_path, test=test)
    print("... training complete")

    return (jsonify(True))