Exemple #1
0
def test_decision_tree():
    runner = Runner(
        'model/experiment/output/decision_tree_basic_full',
        load_sample_data_frame(),
        'arrest',
        decision_tree_basic,
        hyper_parameters=hyper_parameters
    )
    runner.run_classification_search_experiment(
        'roc_auc',
        sample=sample,
        n_iter=iterations,
        record_predict_proba=True
    )

    runner = Runner(
        'model/experiment/output/decision_tree_under_sampled_full',
        load_sample_data_frame(),
        'arrest',
        decision_tree_basic,
        hyper_parameters=hyper_parameters
    )
    runner.run_classification_search_experiment(
        'roc_auc',
        sample=sample,
        n_iter=iterations,
        record_predict_proba=True,
        sampling=RandomUnderSampler()
    )

    runner = Runner(
        'model/experiment/output/decision_tree_over_sampled_full',
        load_sample_data_frame(),
        'arrest',
        decision_tree_basic,
        hyper_parameters=hyper_parameters
    )
    runner.run_classification_search_experiment(
        'roc_auc',
        sample=sample,
        n_iter=iterations,
        record_predict_proba=True,
        sampling=SMOTE()
    )

    runner = Runner(
        'model/experiment/output/decision_tree_combine_sampled_full',
        load_sample_data_frame(),
        'arrest',
        decision_tree_basic,
        hyper_parameters=hyper_parameters
    )
    runner.run_classification_search_experiment(
        'roc_auc',
        sample=sample,
        n_iter=iterations,
        record_predict_proba=True,
        sampling=SMOTEENN()
    )
def test_neural_network_basic():
    runner = Runner('model/experiment/output/neural_network_basic',
                    load_sample_data_frame(), 'violation',
                    neural_network_basic, None)
    runner.run_classification_experiment(sample=sample,
                                         multiclass=True,
                                         record_predict_proba=True)
Exemple #3
0
def test_gaussian_naive_bayes_basic():
    runner = Runner('model/experiment/output/complement_naive_bayes_basic',
                    load_sample_data_frame(), 'violation',
                    gaussian_naive_bayes_basic, None)
    runner.run_classification_experiment(sample=sample,
                                         multiclass=True,
                                         record_predict_proba=True)
def test_lightgbm_basic():
    runner = Runner('model/experiment/output/lightgbm_basic',
                    load_sample_data_frame(), 'violation', lightgbm_basic,
                    hyper_parameters)
    runner.run_classification_search_experiment('neg_log_loss',
                                                sample=sample,
                                                n_iter=iterations,
                                                multiclass=True,
                                                record_predict_proba=True)
# -*- coding: utf-8 -*-
"""
    Test the ticket model being serviced on localhost:8080
"""

__author__ = "John Hoff"
__email__ = "*****@*****.**"
__copyright__ = "Copyright 2019, John Hoff"
__license__ = "Creative Commons Attribution-ShareAlike 4.0 International License"
__version__ = "1.0.0"

import json
import requests

from utility import use_project_path
from model import load_sample_data_frame

if __name__ == '__main__':
    use_project_path()

    for index, row in load_sample_data_frame().iterrows():
        print(row.to_json())
        headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
        response = requests.post('http://127.0.0.1:8080/ticketPrediction',
                                 data=row.to_json(),
                                 headers=headers)
        print(json.loads(response.text))

        if index > 100:
            break