[Practice] Make a Watson app with Python! # 3 [Natural language classification]

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.

Bind the natural language classifier to your app

Select Natural Language Classifier from the catalog. スクリーンショット 2017-07-16 12.51.10.png

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. スクリーンショット 2017-07-16 12.52.32.png

Enter credentials

You can get the credentials from the connection field of the app, so スクリーンショット 2017-07-16 12.58.44.png

Embed it in naturallanguageclassification.py in the watsonutils folder. スクリーンショット 2017-07-16 13.32.07.png

The sentences translated in this area of wl.py (original in the case of English) are classified. スクリーンショット 2017-07-16 13.37.07.png

This part of naturallanguageclassify.py is where you actually classify スクリーンショット 2017-07-16 13.39.04.png

Classifier training

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. スクリーンショット 2017-07-16 13.53.10.png

Log in using your Bluemix login information. スクリーンショット 2017-07-16 13.54.53.png

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. スクリーンショット 2017-07-16 13.56.40.png

Select the Classifier name and language and confirm. スクリーンショット 2017-07-16 14.55.19.png

I'm worried if there is a way to do it, but it seems to be moving. スクリーンショット 2017-07-16 14.57.30.png

Output to localhost

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

[Practice] Make a Watson app with Python! # 3 [Natural language classification]
[Practice] Make a Watson app with Python! # 1 [Language discrimination]
[Practice] Make a Watson app with Python! # 2 [Translation function]
Make a desktop app with Python with Electron
Make a fortune with Python
Let's make a GUI with python.
Make a recommender system with python
Let's make a graph with python! !!
Make a scraping app with Python + Django + AWS and change jobs
Let's make a shiritori game with Python
Daemonize a Python web app with Supervisor
Let's make a voice slowly with Python
3. Natural language processing with Python 2-1. Co-occurrence network
3. Natural language processing with Python 1-1. Word N-gram
Let's make a simple language with PLY 1
Make Qt for Python app a desktop app
I tried a functional language with Python
Let's make a web framework with Python! (1)
Let's make a Twitter Bot with Python!
Let's make a web framework with Python! (2)
3. Natural language processing with Python 1-2. How to create a corpus: Aozora Bunko
3. Natural language processing with Python 2-2. Co-occurrence network [mecab-ipadic-NEologd]
Make a Twitter trend bot with heroku + Python
[Python] Make a game with Pyxel-Use an editor-
I want to make a game with Python
[Python] I played with natural language processing ~ transformers ~
Try to make a "cryptanalysis" cipher with Python
[Python] Make a simple maze game with Pyxel
Let's replace UWSC with Python (5) Let's make a Robot
Try to make a dihedral group with Python
3. Natural language processing with Python 3-3. A year of corona looking back at TF-IDF
Python: Natural language processing
Try to make a Python module in C language
Try to make a command standby tool with python
Make a simple Slackbot with interactive button in python
[Let's play with Python] Make a household account book
I made a net news notification app with Python
Let's make a simple game with Python 3 and iPhone
Make a breakpoint on the c layer with python
3. Natural language processing with Python 4-1. Analysis for words with KWIC
Building an environment for natural language processing with Python
Make a CSV formatting tool with Python Pandas PyInstaller
Let's make a Mac app with Tkinter and py2app
What is God? Make a simple chatbot with python
[Super easy] Let's make a LINE BOT with Python.
Let's make a websocket client with Python. (Access token authentication)
100 Language Processing with Python Knock 2015
3. Natural language processing with Python 5-1. Concept of sentiment analysis [AFINN-111]
Embed a Python interpreter into a C ++ app with pybind11 + cmake
Associate Python Enum with a function and make it Callable
Experiment to make a self-catering PDF for Kindle with Python
Predictive Statistics (Practice Classification) Python
Make Puyo Puyo AI with Python
Make a Mac menu bar resident weather app with rumps!
Make a bookmarklet in Python
[Python] Make a simple maze game with Pyxel-Make enemies appear-
Python: Natural language vector representation
3. Natural language processing with Python 3-4. A year of corona looking back on TF-IDF [Data creation]
Create a directory with python
Make a fire with kdeplot
3. Natural language processing with Python 5-2. Emotion intensity analysis tool VADER