One of the courses in developer Works, [Create Python apps] with IBM Watson and IBM Bluemix](https://developer.ibm.com/courses/all/create-python-apps-ibm-watson-ibm-bluemix/).
Last time, I worked on episode-2 of the text and added a function to determine the number of languages entered in the app and translate it into English. This time, we will enter episode-3, add a natural language classification function, and improve the accuracy of the answer by going through the training here.
Go to src / episode-3 / django / src / projwatson. Rewrite the various files rewritten in # 1 with a text editor again.
Select Natural Language Classifier from the catalog.
Set the connection destination to the app you want to bind to and click "Create". You will be asked to restage, so it's OK.
You can get the credentials from the connection field of the app, so
Embed it in naturallanguageclassification.py in the watsonutils folder.
The sentences translated in this area of wl.py (original in the case of English) are classified.
This part of naturallanguageclassify.py is where you actually classify
Create a class that will be the basis of the classification. Select "Natural Language Classifier" from the "Connection" field on the application details screen on Bluemix. (Press the white part as much as possible) Click "Access the beta toolkit" (blue-green part) from the "Administration" column to jump to the tool.
Log in using your Bluemix login information.
Click Add training data to add training data. I set English sentences about tourism by referring to here. It is better to have 10 example sentences in each class. I created "Directions", "Meals", "Sightseeing", and "Shopping". Press Create Classifier at the top to finish.
Select the Classifier name and language and confirm.
I'm worried if there is a way to do it, but it seems to be moving.
In the terminal, go to src / episode-3 / django / src / projwatson.
python manage.Output to localhost with py run server.
It went well!
![スクリーンショット 2017-07-16 15.01.04.png](https://qiita-image-store.s3.amazonaws.com/0/141025/076bd573-372f-e191-ecb6-f4e2eb709348.png)
I haven't trained so much, so I haven't done it yet.
![スクリーンショット 2017-07-16 15.02.09.png](https://qiita-image-store.s3.amazonaws.com/0/141025/0e679b8b-541d-d9b0-55d1-bd8a79545263.png)
Up to here for this time!
Thank you for your hard work! !!
Recommended Posts