Open guiniao opened 5 years ago
Hi @guiniao, thanks for your comment. I'm going to take a look at this issue and get back to you once I've determined the problem.
@KhaledSharif ,Thank you for your reply. I tried another way.I generate the test.py script from the following code:
from pandas import DataFrame
from sklearn.datasets import load_iris
from sklearn.tree import DecisionTreeClassifier
iris = load_iris()
input_df = DataFrame(data=iris['data'], columns=iris['feature_names'])
clf = DecisionTreeClassifier(max_depth=2)
clf.fit(input_df.values, iris['target'])
from sklearn2docker.constructor import Sklearn2Docker
s2d = Sklearn2Docker(
classifier=clf,
feature_names=iris['feature_names'],
class_names=iris['target_names'].tolist()
)
s2d.save(name="classifier", tag="iris")
I use the ubuntu18.04 installed docker,When test.py is executed, the container has been successfully.When I run the command:docker run -d -p 5000:5000 classifier:iris,I use docker container ls,You see that the container is not started, but when I delete the image, it prompts me that the image is being used by the container. The picture is as follows: Ignore the above question.An error occurrs when I used the following code to predict:
from os import system
system("docker run -d -p 5000:5000 classifier:iris && sleep 5")
from requests import post
from pandas import read_json
request = post("http://localhost:5000/predict_proba/split",
json=input_df.to_json(orient="split"))
result = read_json(request.content.decode(), orient="split")
print(result.head())
Error is as follows:
requests.exceptions.ConnectionError: HTTPConnectionPool(host='localhost', port=5000): Max retries exceeded with url: /predict/split (Caused by NewConnectionError(': Failed to establish a new connection: [Errno 111] Connection refused',))
I need your help, thank you
Hello, do you have any more details? I used Dockerfile and requirements. txt from constructor. py in the sklearn2docker directory. Generate the container using app.py in the sklearn2docker directory. Then, execute the python code at Getting started, but run docker, the container does not start. How do you run the entire project Thank you for your help