openscoring / openscoring-python

Python client library for the Openscoring REST web service

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to evaluate model with many records at once?

Tenceto opened this issue · comments

The example provided uses just one record:

arguments = {
	"Sepal_Length" : 5.1,
	"Sepal_Width" : 3.5,
	"Petal_Length" : 1.4,
	"Petal_Width" : 0.2
}

result = os.evaluate("Iris", arguments)
print(result)

I was wondering if there was a way to do this but with many records, and to call the Openscorer just once. For example, if I have something like:

arguments = [
{
	"Sepal_Length" : 5.1,
	"Sepal_Width" : 3.5,
	"Petal_Length" : 1.4,
	"Petal_Width" : 0.2
},
{
	"Sepal_Length" : 5.0,
	"Sepal_Width" : 3.7,
	"Petal_Length" : 1.2,
	"Petal_Width" : 0.4
}
]

Is there a way to evaluate the model with both records at once?

Is there a way to evaluate the model with both records at once?

Yes there is - it's called "batch prediction":
https://github.com/openscoring/openscoring#post-modelidbatch

The request and response objects are BatchEvaluationRequest and BatchEvaluationResponse, respectively.

Now, the problem is that the Openscoring-Python client library doesn't provide a method for interacting with this endpoint. The following PR might help, though: #6

Thanks for your quick response!

The last link you wrote seems to be the solution. Do you know how can I make it overwrite the current package installation? I've never used GitHub before, sorry if this is too basic.

Do you know how can I make it overwrite the current package installation?

A complete re-install would be the safest option:

pip uninstall openscoring
pip install git+https://github.com/openscoring/openscoring-python.git

I think that's what I used to install the original version of the package. Shouldn't I do something different if I want the Openscoring object to have the evaluateBatch() method that has been added in the PR?

Shouldn't I do something different if I want the Openscoring object to have the evaluateBatch() method that has been added in the PR?

  1. Clone Openscoring-Python to local computer.
  2. Apply this PR.
  3. Install Openscoring-Python from local computer using pip install .

Thanks!