def __init__(self):
     """Initial variable and module"""
     config_setting = ConfigSetting()
     self.log = config_setting.set_logger(
         "[Confusion_matrix_calculation_app]")
     self.config = config_setting.yaml_parser()
     self.confusion_matrix_calculation_service = ConfusionMatrixCalculationService()
 def __init__(self):
     """Initial variable and module"""
     config_setting = ConfigSetting()
     self.log = config_setting.set_logger(
         "[Confusion_matrix_calculation_service]")
     self.config = config_setting.yaml_parser()
     self.confusion_matrix_record_dao = ConfusionMatrixRecordDao()
     self.confusion_matrix_record_dao.setting_confusion_matrix_database()
コード例 #3
0
 def __init__(self):
     config_setting = ConfigSetting()
     self.config = config_setting.yaml_parser()
     self.log = config_setting.set_logger(["training_service"])
     self.df = {}
     self.label = []
     self.data = {}
     self.model = None
コード例 #4
0
 def __init__(self):
     config_setting = ConfigSetting()
     self.config = config_setting.yaml_parser()
     self.log = config_setting.set_logger(["data_etl_service"])
     self.df = {}
     self.train_label = []
     self.one_hot_encoder = None
     self.label_encoder = LabelEncoder()
コード例 #5
0
def create_confusion_matrix_router():
    """The function to creates the fastapi api router service."""5
    config_setting = ConfigSetting()
    log = config_setting.set_logger("[create_confusion_matrix_router]")
    config = config_setting.yaml_parser()

    user_router = APIRouter()
    confusion_matrix_calculation_app = ConfusionMatrixCalculationApp()

    @user_router.post("/json/confusion_matrix")
    def calculate_confusion_matrix(y_true: list, y_pred: list):
        if len(y_true) > 0 and len(y_pred) > 0 and len(y_true) == len(y_pred):
            payload = confusion_matrix_calculation_app.get_confusion_matrix(y_true, y_pred)
        else:
            payload = {"message": "Length error."}
        return payload
    
    @user_router.post("/html/confusion_matrix", response_class=HTMLResponse)
    def calculate_confusion_matrix_html(y_true: list, y_pred: list):
        if len(y_true) > 0 and len(y_pred) > 0 and len(y_true) == len(y_pred):
            confusion_matrix_calculation_app.get_confusion_matrix(y_true, y_pred)
            html = confusion_matrix_calculation_app.get_confusion_matrix_html(y_true, y_pred)
        else:
            html = {"message": "Length error."}
        return html

    @user_router.post("/json/accuracy_score")
    def calculate_accuracy_score(confusion_matrix: ConfusionMatrixBaseModel):
        payload = confusion_matrix_calculation_app.confusion_matrix_to_accuracy_value(confusion_matrix.dict())
        return payload
    
    @user_router.post("/json/prediction_accuracy")
    def calculate_prediction_accuracy(y_true: list, y_pred: list):
        if len(y_true) > 0 and len(y_pred) > 0 and len(y_true) == len(y_pred):
            payload = confusion_matrix_calculation_app.prediction_to_accuracy_value(y_true, y_pred)
        else:
            payload = {"message": "Length error."}
        return payload
    
    @user_router.post("/json/precision_recall_score")
    def calculate_precision_recall_value(confusion_matrix: ConfusionMatrixBaseModel):
        payload = confusion_matrix_calculation_app.confusion_matrix_to_precision_recall_value(confusion_matrix.dict())
        return payload
    
    @user_router.post("/json/prediction_precision_recall")
    def calculate_prediction_precision_recall(y_true: list, y_pred: list):
        if len(y_true) > 0 and len(y_pred) > 0 and len(y_true) == len(y_pred):
            payload = confusion_matrix_calculation_app.prediction_to_precision_recall_value(y_true, y_pred)
        else:
            payload = {"message": "Length error."}
        return payload

    log.info("Successfully setting the api router.")
    return user_router
コード例 #6
0
def create_app(unittest=False):
    """The function to creates the fastapi service."""
    # Initial config and log
    config_setting = ConfigSetting()
    log = config_setting.set_logger("[create_app]")
    config = config_setting.yaml_parser()
    
    app = FastAPI()

    api_router = create_api_router()
    app.include_router(api_router, prefix="/api", tags=["api"])

    confusion_matrix_router = create_confusion_matrix_router()
    app.include_router(confusion_matrix_router, prefix="/confusion_matrix", tags=["confusion_matrix"])

    log.info("Start the fastapi service.")
    return app
コード例 #7
0
def create_api_router():
    """The function to creates the fastapi api router service."""
    config_setting = ConfigSetting()
    log = config_setting.set_logger("[create_api_router]")
    config = config_setting.yaml_parser()

    user_router = APIRouter()
    health_check_information = HealthCheckInformation()

    @user_router.get("/health_check", response_model=HealthCheckBaseModel)
    def health_check():
        """health_check: Check the service is working.
        Returns:
            json format: the health check content.
        """
        return health_check_information.get_health_check_content()
    
    log.info("Successfully setting the api router.")
    return user_router
コード例 #8
0
def create_app():
    """Create flask app service."""
    config_setting = ConfigSetting()
    log = config_setting.set_logger("[flask_app]")
    config = config_setting.yaml_parser()
    fast_api_app = FastApiApp()
    app = FastAPI()

    @app.get("/health_check")
    def health_check():
        with open('setup.py', 'r') as f:
            setup_str = f.read()
        # Get version string
        version_str = _pos_string(setup_str, 'project_version=')
        # Get project string
        project_str = _pos_string(setup_str, 'project_name=')
        return {
            'service': project_str,
            'status': '200',
            'version': version_str
        }

    @app.post("/prediction", response_model=Result)
    def prediction(prediction: Prediction):
        data = prediction.dict()
        for index, value in zip(data.keys(), data.values()):
            data[index] = [value]
        result = fast_api_app.prediction(data)
        return {"class_num": result[0]}

    def _pos_string(setup_str, pos_string):
        start_project_pos = setup_str.find(pos_string) + len(pos_string)
        end_project_pos = setup_str.find(',', start_project_pos)
        return setup_str[start_project_pos:end_project_pos].replace("'", '')

    return app
コード例 #9
0
 def __init__(self):
     config_setting = ConfigSetting()
     self.config = config_setting.yaml_parser()
     self.log = config_setting.set_logger(["data_etl_app"])
     self.train_eval_service = TrainEvalService()
コード例 #10
0
 def __init__(self):
     config_setting = ConfigSetting()
     self.config = config_setting.yaml_parser()
     self.log = config_setting.set_logger(["data_etl_app"])
     self.data_etl_service = DataEtlService()
コード例 #11
0
 def __init__(self, req):
     config_setting = ConfigSetting()
     self.log = config_setting.set_logger("[ azure_function ]",
                                          os.path.join("tmp/", "logs"))
     self.config = config_setting.yaml_parser()
     self.req = req
コード例 #12
0
 def __init__(self):
     config_setting = ConfigSetting()
     self.log = config_setting.set_logger("[ azure_function ]", os.path.join("tmp/", "logs"))
     self.config = config_setting.yaml_parser()
     self.blob_service_client = None
     self.file_name = None
コード例 #13
0
 def __init__(self):
     config_setting = ConfigSetting()
     self.config = config_setting.yaml_parser()
     self.log = config_setting.set_logger(["data_etl_app"])
     self.fast_api_service = FastApiService()
コード例 #14
0
 def __init__(self):
     """Initial variable and module"""
     config_setting = ConfigSetting()
     self.log = config_setting.set_logger("[Confusion_matrix_record_dao]")
     self.config = config_setting.yaml_parser()
     self.sqlite_engine = None