You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »

The implementation between each model can be entire different, we are not going to go into details about each particular model, each model implementation in Python Bridge is a set of expected functions focus in functionality

Model Class Creation

Every model class must be under the package models, inside the Python Bridge folder, and must extended from the class ModelWrapper. An example of a model class with the bare minimum, can be found below

from models.model_wrapper import ModelWrapper


class Test(ModelWrapper):
    
    def __init__(self):
        super().__init__()

    def initialize(self, model_dir, **kwargs):
        pass

    def load(self, model_dir, name, version):
        pass

    def save(self):
        pass

    def clear(self):
        pass

    def feed(self, data):
        pass

    def train(self, **kwargs):
        pass

    def predict(self, data: list):
        pass

    def regress(self, data):
        pass

    def classify(self, data) -> (str, float):
        pass

    


Implementation Class

def initialize(self, model_dir, **kwargs):

Receive the path to the model type and the configuration for the path


def load(self, model_dir, name, version):

Receive the path to the model type, the name of the model and the version of it, in this section the loading of the model is expected


def save(self):

Save the current loaded model


def clear(self):

Remove the current loaded model, and any training data in memory


def feed(self, data):

Receives a list of string tokens tokens to be added to the training data


def train(self, **kwargs):

Trains model with the fed documents, the model can be either kept in memory or saved


def predict(self, data: list):

Retrieves a vector or an array of vectors, from processing the data with the loaded mode, which is return inside a JSON { 'vector': [ ] }, the value of the vector key must be always be an array.


def regress(self, data):

?? 


def classify(self, data) -> (str, float):

Retrieves a label or multiple labels, using the loaded model, from the data. We recommend returning the label along with its confidence.

Models Location

  • No labels