import io, os, sys from .base import BaseClassifier from api.errors import RaiseError from api import log from collections import OrderedDict """get the logger""" log = log.get_logger() class FidBobClassifier(BaseClassifier): """name of the classifier""" name = "fid_intent_classifier" def __init__(self, t_vector=None, lr_model=None, ncf=None): """constructor to init the fid classifier""" self.ncf = ncf def predict(self, expression=None): """expression for which we run the model against to derive the intent""" confidence_score = 0 intent = None #intent, confidence_score = self.ncf(expression) intent, confidence_score = "Test", 100 l_msg = "model found : {} and score is {}".format( intent, confidence_score) log.debug(l_msg) return intent, confidence_score
"""Resources for API""" from pathlib import Path from api import (routes, log) from api.config import MACHINE_LEARNING_OPTION as model_config _logger = log.get_logger() # Constants SCHEMA_PATH = Path(model_config('schemas_path')) SCHEMA_IN = SCHEMA_PATH / model_config('schema_in') SCHEMA_OUT = SCHEMA_PATH / model_config('schema_out') class Resource: """ Resource that actually creates handler functions and add all routes to the API. """ def __init__(self, add_route_fun, executor): _logger.debug(f'Initializing Resource object {self}') self.add_route_fun = add_route_fun # Intanciate Handler Object for Machine Learning self.machine_learning_object = routes.MachineLearning( schema_in=SCHEMA_IN, schema_out=SCHEMA_OUT, executor=executor, ) self.healthcheck_object = routes.HealthCheck() # Register Routes