Quickstart: Tabular Classification with the Python API
Quickstart: Tabular Classification with the Python API#
This tutorial uses Gene expression cancer RNA sequence provided with NeurEco installation.
To work with the Tabular NeurEco models in Python, import NeurEcoTabular library:
from NeurEco import NeurEcoTabular as Tabular
Import numpy to handle the data sets:
import numpy as np
Load the data sets (see Data preparation for NeurEco Classification with python API and Gene expression cancer RNA sequence):
x_train = []
y_train = []
for i in range(2):
x_name = "x_train_" + str(i) + "_.csv"
y_name = "y_train_" + str(i) + "_.csv"
x_part = np.genfromtxt(x_name, delimiter=";", skip_header=True)
x_train.append(x_part)
y_part = np.genfromtxt(y_name, delimiter=";", skip_header=True)
y_train.append(y_part)
x_train = np.vstack(tuple(x_train))
y_train = np.vstack(tuple(y_train))
x_test = np.genfromtxt("x_test.csv", delimiter=";", skip_header=True)
y_test = np.genfromtxt("y_test.csv", delimiter=";", skip_header=True)
To initialize a NeurEco object to handle the Classification problem:
classification_model = Tabular.Classifier()
To build the model, call method build with the parameters set for the problem under consideration (see Build NeurEco Classification model with the Python API).
classification_model.build(input_data=x_train, output_data=y_train,
# the rest of these parameters are optional
write_model_to="./GeneExpressionCancerRnaSeqModel/GeneExpressionCancerRnaSeq.ednn",
checkpoint_address="./GeneExpressionCancerRnaSeqModel/GeneExpressionCancerRnaSeq.checkpoint",
valid_percentage=33.33)
Note
For detailed documentation on build, see Build NeurEco Classification model with the Python API
To evaluate the NeurEco Model on the testing data, call evaluate method:
neureco_test_outputs = classification_model.evaluate(x_test)
Note
For detailed documentation on evaluate, see Evaluate NeurEco Classification model with the Python API
To export the model to the chosen format, run one of the following commands:
classification_model.export_c("./GeneExpressionCancerRnaSeqModel/GeneExpressionCancerRnaSeq.h", precision="double")
classification_model.export_onnx("./GeneExpressionCancerRnaSeqModel/GeneExpressionCancerRnaSeq.onnx", precision="float16")
classification_model.export_fmu("./GeneExpressionCancerRnaSeqModel/GeneExpressionCancerRnaSeq.fmu")
classification_model.export_vba("./GeneExpressionCancerRnaSeqModel/GeneExpressionCancerRnaSeq.bas", precision="float")
Export to these formats requires embed license.
Note
For detailed documentation on export, see Export NeurEco Classification model with the Python API
When the model is not needed any more, delete it from the memory:
classification_model.delete()
Note
For detailed documentation on Tabular Classification with the python API, see Tabular Classification with the Python API.