Slide 13
Slide 13 text
13 © NEC Corporation 2018
### iris.py ###
import pickle
import pandas as pd
def classify_iris(
sepal_length, sepal_width,
petal_length, petal_width, model_file):
# In [1]
with open(model_file, 'rb') as f:
clf = pickle.load(f)
# In [3]
IRIS_NAMES = {
0: 'setosa',
1: 'versicolor',
2: 'virginica'
}
result = clf.predict([
[sepal_length, sepal_width,
petal_length, petal_width]
])
return IRIS_NAMES[result[0]]
Notebookに書いたコードのWeb API化
▌2. Pythonスクリプト作成 - 予測するコードをPythonスクリプト化
Notebookに書いたコードを
また書かなくてはならない