eland.ml.
ImportedMLModel
Transform and serialize a trained 3rd party model into Elasticsearch. This model can then be used for inference in the Elastic Stack.
The unique identifier of the trained inference model in Elasticsearch.
Names of the features (required)
Labels of the classification targets
Weights of the classification targets
Delete and overwrite existing model (if exists)
Examples
>>> from sklearn import datasets >>> from sklearn.tree import DecisionTreeClassifier >>> from eland.ml import ImportedMLModel
>>> # Train model >>> training_data = datasets.make_classification(n_features=5, random_state=0) >>> test_data = [[-50.1, 0.2, 0.3, -0.5, 1.0], [1.6, 2.1, -10, 50, -1.0]] >>> classifier = DecisionTreeClassifier() >>> classifier = classifier.fit(training_data[0], training_data[1])
>>> # Get some test results >>> classifier.predict(test_data) array([0, 1])
>>> # Serialise the model to Elasticsearch >>> feature_names = ["f0", "f1", "f2", "f3", "f4"] >>> model_id = "test_decision_tree_classifier" >>> es_model = ImportedMLModel('localhost', model_id, classifier, feature_names, overwrite=True)
>>> # Get some test results from Elasticsearch model >>> es_model.predict(test_data) array([0, 1])
>>> # Delete model from Elasticsearch >>> es_model.delete_model()