Machine Learning: Getting started - QEDK/clarity GitHub Wiki
The ml
directory is intended to be imported as an entire module (hence the __init__.py
). To get started with making predictions, it's simple!
$ git clone [email protected]:QEDK/clarity.git
$ cd clarity/ml
$ pip3 install -r requirements.txt
Now, in your code, you can import the entire module using:
from ml.processtext import ProcessText
nlp = ProcessText() # this will load the Keras model and other functionality
# And then to perform analysis:
result = await nlp.process("Some text you need to analyze!")
# This module uses async so you can enable concurrency in your real-time applications ;)
Importing the module from arbitrary locations
If your ml
folder is located in sibling folders and you are not using Python packages, it is difficult to import
the module for usage. There's a simple solution for that:
import sys
from pathlib import Path
sys.path.append(str(Path(__file__).resolve().parents[<levels between the current file and ml module>].joinpath("ml")))
from processtext import ProcessText # noqa