Adding a new model to the Python Bridge only requiresThe 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
Implementation Class
Code Block |
---|
|
def initialize(self, model_dir, **kwargs): |
Receive the path to the model type and the configuration for the path
Code Block |
---|
|
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
Code Block |
---|
|
def save(self): |
Save the current loaded model
Code Block |
---|
|
def clear(self): |
Remove the current loaded model, and any training data in memory
Code Block |
---|
|
def feed(self, data): |
Receives a list of string tokens tokens to be added to the training data
Code Block |
---|
|
def train(self, **kwargs): |
Trains model with the fed documents, the model can be either kept in memory or saved
Code Block |
---|
|
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.
Code Block |
---|
|
def regress(self, data): |
??
Code Block |
---|
|
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