Code Monkey home page Code Monkey logo

Comments (7)

davidkyle avatar davidkyle commented on May 27, 2024

Thanks for reporting this @mundruid.

Elasticsearch 8.11 should work with your model. What version of XGBoost did you create the model with?

from eland.

mundruid avatar mundruid commented on May 27, 2024

I created XGBClassifier with eland 8.11.0 and I can upload to Elastic 8.11.1. I am able to upload the XGBClassifier model.

If I convert the exact same model from XGBClassifier to RandomForestClassifier, I get the bad request error mentioned above.

from eland.

davidkyle avatar davidkyle commented on May 27, 2024

There was as similar error reported in #255 where the model upload failed because it was too big for the HTTP buffer. H/ow big is your model @mundruid?

The resolution was to compress the model definition #255 (comment)

from eland.

mundruid avatar mundruid commented on May 27, 2024

The Random Forest Classifier is 36372 Bytes. I have tried the resolution and I get an error: "Connection #0 to host cas-aggregator.es.us-east-1.aws.elastic-cloud.com left intact
{"error":{"root_cause":[{"type":"x_content_parse_exception","reason":"[1:0] [trained_model_definition] Expected START_OBJECT but was: null"}],"type":"x_content_parse_exception","reason":"[1:0] [trained_model_definition] Expected"

Is anyone else able to upload Random Forest Classifier models with these versions of Eland and Elastic? Is there a min/max size?

from eland.

davidkyle avatar davidkyle commented on May 27, 2024

@mundruid there is actually a test that creates a random RandomForestClassifier model and uploads it Elasticsearch, that test passes when I run it locally with pytest tests/ml/test_ml_model_pytest.py::TestMLModel::test_random_forest_classifier and it passes in CI runs.

https://github.com/elastic/eland/blob/main/tests/ml/test_ml_model_pytest.py#L417

The failure you are seeing may be specific to your model, or due to a certain combinations of dependencies.

What version of sklearn do you have installed?

My eland version is: 8.11.0 and elasticsearch version is 8.11.1 when the above error happens.
The versions of Elastic I was able to upload the RandomForestClassifier is: 7.17.1 and 7.17.5.

Can you upload the model to Elasticsearch 7.17 with Eland 8.11.1?

from eland.

mundruid avatar mundruid commented on May 27, 2024

I only have a 7.17.5 cluster left and I tried Eland 8.11.1 and still getting a bad request error.

The model that cannot be uploaded was uploaded using the following method recommended by Elastic. This may help so I am pasting here what I did:

  1. Transform the model to json:
import json
from eland.ml.transformers import get_model_transformer
# (Same inputs as ImportedMLModel)
transformer = get_model_transformer(
    model,
    feature_names=feature_names,
    classification_labels=classification_labels,
    classification_weights=classification_weights,
)
# Put this into the GitHub issue
print(json.dumps(transformer.transform().to_dict())
  1. Compress:
python print_ml_model.py > upload.json
jq -j '{"trained_model": .}' upload.json | gzip | base64 > compressed_definition.txt
COMPRESSED_DEF=$(cat compressed_definition.txt); FEATURE_NAMES=$(jq '.ensemble.feature_names' upload.json); echo "{\"compressed_definition\": \"$COMPRESSED_DEF\", \"input\": {\"field_names\": $FEATURE_NAMES}, \"inference_config\":{\"classification\":{}}}" > my_model.json
  1. Upload with curl:
curl -v -X PUT -H "Content-Type: application/json" -d @my_model.json <elasticsearch_endpoint>/_ml/trained_models/<your-model-name>

If you would like me to share the model json please let me know. I do not think I can share it on a public forum but I can send you a PM.

from eland.

mundruid avatar mundruid commented on May 27, 2024

This issue can be closed. Based on the workaround above I can upload my model. I still cannot upload it with Eland, however based on discussions with Elastic support, this does not seem to be an issue with Eland but with how my model is saved with scikit.

from eland.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.