Google Cloud ML-engine scikit-learn prediction probability 'predict_proba()'

前端 未结 1 1476
无人及你
无人及你 2021-02-05 22:27

Google Cloud ML-engine supports the ability to deploy scikit-learn Pipeline objects. For example a text classification Pipeline could look like the following,

相关标签:
1条回答
  • 2021-02-05 22:59

    The ML Engine API you are using, only has the predict method, as you can see in the documentation, so it will only do the prediction (unless you force it to do something else with the hack you mentioned).

    If you want to do something else with your trained model, you’ll have to load it and use it normally. If you want to use the model stored in Cloud Storage you can do something like:

    from google.cloud import storage
    from sklearn.externals import joblib
    
    bucket_name = "<BUCKET_NAME>"
    gs_model = "path/to/model.joblib"  # path in your Cloud Storage bucket
    local_model = "/path/to/model.joblib"  # path in your local machine
    
    client = storage.Client()
    bucket = client.get_bucket(bucket_name)
    blob = bucket.blob(gs_model)
    blob.download_to_filename(local_model)
    
    model = joblib.load(local_model)
    model.predict_proba(test_data)
    
    0 讨论(0)
提交回复
热议问题