VR Gameplay — Sentiment Analysis: Part 2

Set up Anaconda & Python Workspace

Widnu
4 min readSep 17, 2020

1 Conda (Miniconda)

In this step, we set up Conda environment and Spyder IDE for Machine Learning implementation in Python.

1.1 Installation

1. Download the installer of Miniconda from the following official website.

- https://docs.conda.io/en/latest/miniconda.html

2. Then verify the installation by running the Anaconda Prompt (miniconda3) from the Start menu. The result should be similar to the following screenshot.

1.2 Create Conda Environment (env_nltk)

Open Anaconda Prompt (miniconda3) from the start menu. We will create and activate a working environment named ‘env_nltk’ by executing the following commands. In the end, we will verify the python version which should be 3.7 at the minimum.

conda create -n env_nltkconda activate env_nltkpython –version
Figure 5. The successful result of conda installation.

1.3 Install Spyder IDE

Spyder is a Python IDE, which we need to manually install into conda environment (env_nltk) by executing the following command. Please ensure that we have activate the env_nltk environment already. After the installation, we should be able to run Spyder from the Start menu.

conda activate env_nltkconda install -y -c anaconda spyder
Figure 6. The successful result of Spyder installation.
Figure 7. Verify the Spyder installation.

1.4 Install Python Packages

It is recommended to use ‘conda install’ rather than ‘pip install’ command because Conda can handle library dependencies and manage the packages which may contain software written in any language. The required packages can be installed by the following commands.

conda install -c anaconda numpyconda install -c anaconda nltkconda install -c anaconda flaskconda install -c anaconda scikit-learnpip install pyttsx3
Figure 8. The successful result of NLTK installation.

1.5 Install NLTK data

NLTK comes with many built-in data, which we can choose to download and use it to train the model. To see all data, please visit this link: http://www.nltk.org/nltk_data/. In our development environment, we will download all data by executing following command.

python -m nltk.downloader all
Figure 9. Downloading NLTK data.

1.6 Set Up Python Workspace

1. Open Spyder IDE. Ensure to select the correct Conda environment (env_nltk).

2. In the menu bar, select Project > New Project…

3. Create the new project from an existing directory by choosing the py_sentiment_analysis folder located in {project}/py_sentiment_analysis

Figure 10. New project in Spyder.

4. The project’s folder structure should appear on the left side of Spyder IDE.

Figure 11. Project view in Spyder IDE.

1.7 Test the Workspace

We can verify the workspace setup by executing the following files via Spyder. They should be able to run without any modification.

1.8 Test the APIs on Local Server

1. Open the Anaconda Prompt (miniconda3) from the start menu.

2. Run the following commands

conda activate env_nltkcd {project}/py_sentiment_analysispython sentiment_api.py
Figure 12. Commands to start the server.
Figure 13. The web and APIs are ready to serve at http://localhost:5000

Conclusion

In this story, we set up Anaconda and Spyder for Python development. We can run and save the model. In the end, we start the Flask server in our local machine, which allows us to test the REST APIs.

Next

We will deploy our APIs on Heroku.

--

--