[Python machine learning] Recommendation of using Spyder for beginners (as of August 2020)

I recently became interested in machine learning and started studying Python. Since machine learning is a prerequisite, the library is complete "[Anadonda](https://ja.wikipedia.org/wiki/Anaconda_(Python%E3%83%87%E3%82%A3%E3%82%B9%E3%" 83% 88% E3% 83% AA% E3% 83% 93% E3% 83% A5% E3% 83% BC% E3% 82% B7% E3% 83% A7% E3% 83% B3)) " I built a learning environment and proceeded with learning, but on the way, "[Spyder](https://ja.wikipedia.org/wiki/Spyder_(%E3%82%BD%E3%83%95) % E3% 83% 88% E3% 82% A6% E3% 82% A7% E3% 82% A2))) ”has been used, and the learning efficiency has improved significantly. So, I will post this article for beginners who are just starting machine learning with Python.

■■ What is Anaconda? ■■

Anaconda is a free open source distribution of Python and R for scientific computing (data science, machine learning applications, large-scale data processing, predictive analysis, etc.) that simplifies package management and deployment. This is what I aimed for. Package versions are managed by the package management system conda. The Anaconda distribution is used by more than 15 million users and includes over 1500 popular data science packages for Windows, Linux and macOS. (Quoted from Wikipedia)

A Python environment with all the libraries required for machine learning is provided, so if you use Python for machine learning, this is a free package that you can choose.

■■ What is Spyder (the leading role in this article) ■■

Spyder (formerly Pydee) is an open source, cross-platform integrated development environment designed for scientific programming in Python. NumPy, SciPy, Matplotlib, IPython, etc. are integrated in Spyder. (Quoted from Wikipedia)

It is an integrated development environment as described. The protagonist of this article. "Spyder" will be installed automatically when you install "Anaconda".

■■ Installation method ■■

The installation procedure for "Anaconda" is described below.

"Anaconda: Install Windows version"

When the installation is completed, "Spyder" is automatically installed in the Windows startup. image.png

When you start "Spyder", the following screen will be displayed. I started it once at the beginning of the installation, but I didn't know how to use it, and I didn't realize how amazing this child was. Since I got stuck on the way and started using "Spyder", my learning efficiency has improved dramatically. image.png

■■ Spyder operation method ■■

① When you start Spyder, the following screen will open. image.png

(2) Describe the syntax on the "temp.py" screen on the left side of the screen. image.png

③ Press the execute button. image.png

④ The result is displayed on the console at the bottom right of the screen. image.png

⑤ Of course, you can easily save the program file. Let's save the program you made. image.png

■■ Good points of Spyder (main subject) ■■

Here is the main issue. I will introduce how "Spyder" is an excellent learning environment.

Easy to enter syntax

Initially, I started learning by starting "Anadonda Powershell Prompt" and inputting a program from the terminal. It was the procedure described in the teaching material, and there was no pain at first. However, when it comes to long syntax such as def statement, Class statement, and for statement, I find it very troublesome to input each one. image.png

However, with "Spyder", it is easy to enter and edit the syntax all at once on the screen. It's easy to change variables and re-execute, so you can change various things and try the movement. It was a great help when I was studying Python. image.png In addition, the functions are color-coded, so it is easy to understand at a glance.

Will tell you if the syntax is wrong

And if I tried to move it and got an error, it took time to investigate. For example, the example below is an error that is output when the ":" after "x> 0" is omitted. Somehow a multi-line message is coming out. It's hard to understand. image.png

However, with "Spyder", if the syntax is incorrect, an "x" will be displayed in the column column to let you know on the spot. If you move the cursor to "x", it will tell you the details of the error. You don't have to worry about trivial syntax mistakes. image.png

Variable explorer can be used

For example, execute the following syntax.

a = 20
b = 30
c = (a+b)/3
d = (a+b)%3
e = "kamera"
f = "taiko"
g = e + f
h = ("neko","inu","saru")
i = [("aka","ao"),("kiiro","siro")]
j = {0 : "test",1 :"tst2",2 : "test3"}


If I wanted to know what was set in a variable and the variable type, I ran the variable name and type commands to check. These tasks can be very time consuming, such as when an error occurs. image.png

However, with "Spyder", "Variable Explorer" is displayed in the upper right corner of the screen. The variables used are displayed there. You can check it without typing a variable type or command, and you can save time and effort. image.png

Debug mode can be used

There is a function called debug mode. image.png This allows the syntax to be processed line by line so you can see how it is processed. Especially when using def, if statement, for statement, etc., it helps to follow the movement visibly. Especially when combined with "Variable Explorer", it becomes clear at a glance when it was rewritten.

For example, try running the following syntax in debug mode.

test = []
for x in [0,1,2]:
    for y in [1,2]:
        if x != y:
            test.append((x, y))

The process is halfway, but it is as follows. On the syntax screen, the line currently being processed is marked with an arrow. The Variable Explorer shows what you are doing at that point. Since you can proceed step by step, you will be able to understand the contents of the process. This makes it easy to understand syntax that you didn't understand what it would be like.

Syntax screen Variable explorer screen
image.png image.png
image.png image.png
image.png image.png
image.png image.png
image.png image.png
image.png image.png
image.png image.png
image.png image.png
image.png image.png

Scripts created in the past can be used immediately

You can easily save the created program as a script. And you can pull it out from the file screen at any time. image.png

■■ Summary ■■

As mentioned above, it has all the features for beginners who want to learn Python. The evaluation may be different when using it in actual work, but it is a very excellent tool for learning. If you are a beginner just starting to learn Python, please take advantage of it.

that's all

Recommended Posts

[Python machine learning] Recommendation of using Spyder for beginners (as of August 2020)
<For beginners> python library <For machine learning>
Learning flow for Python beginners
Checkio's recommendation for learning Python
Memo for building a machine learning environment using Python
A memorandum of method often used in machine learning using scikit-learn (for beginners)
Build an environment for machine learning using Python on MacOSX
Python beginners publish web applications using machine learning [Part 1] Introduction
A beginner's summary of Python machine learning is super concise.
Machine learning summary by Python beginners
Ideone> Python version: 3.5 (as of August 29, 2017)
[Python] Minutes of study meeting for beginners (7/15)
Amplify images for machine learning with python
First Steps for Machine Learning (AI) Beginners
Why Python is chosen for machine learning
[Shakyo] Encounter with Python for machine learning
[Python] Web application design for machine learning
An introduction to Python for machine learning
[Definitive Edition] Building an environment for learning "machine learning" using Python on Windows
[Definitive Edition] Building an environment for learning "machine learning" using Python on Mac
[Python] [Machine learning] Beginners without any knowledge try machine learning for the time being
[Example of Python improvement] What is the recommended learning site for Python beginners?
Python beginners publish web applications using machine learning [Part 2] Introduction to explosive Python !!
Python learning memo for machine learning by Chainer Chapter 13 Basics of neural networks
Python learning memo for machine learning by Chainer until the end of Chapter 2
Recommended study order for machine learning / deep learning beginners
Machine learning of sports-Analysis of J-League as an example-②
Python & Machine Learning Study Memo ⑤: Classification of irises
Upgrade the Azure Machine Learning SDK for Python
Python & Machine Learning Study Memo ②: Introduction of Library
[Python] Collect images with Icrawler for machine learning [1000 images]
Easy understanding of Python for & arrays (for super beginners)
List of links that machine learning beginners are learning
[Python3] Let's analyze data using machine learning! (Regression)
Get a glimpse of machine learning in Python
Try using Jupyter Notebook of Azure Machine Learning
[For beginners] Introduction to vectorization in machine learning
Basic story of inheritance in Python (for beginners)
Causal reasoning using machine learning (organization of causal reasoning methods)
[For beginners of artificial intelligence] Machine learning / Deep Learning Programming Learning path and reference books
Align the number of samples between classes of data for machine learning with Python
Let's analyze Covid-19 (Corona) data using Python [For beginners]
What I learned about AI / machine learning using Python (1)
Image collection Python script for creating datasets for machine learning
Build an interactive environment for machine learning in Python
[Recommended tagging for machine learning # 2] Extension of scraping script
[Recommended tagging for machine learning # 2.5] Modification of scraping script
The first step of machine learning ~ For those who want to implement with python ~
Python learning memo for machine learning by Chainer from Chapter 2
Python learning memo for machine learning by Chainer Chapters 1 and 2
Summary of pre-processing practices for Python beginners (Pandas dataframe)
python textbook for beginners
What I learned about AI / machine learning using Python (3)
Support for Python 2.7 runtime on AWS Lambda (as of 2020.1)
Preparing to start "Python machine learning programming" (for macOS)
[Python] I made a classifier for irises [Machine learning]
Summary of the basic flow of machine learning with Python
[For beginners of deep learning] Implementation of simple binary classification by full coupling using Keras
OpenCV for Python beginners
What I learned about AI / machine learning using Python (2)
Everything for beginners to be able to do machine learning