Machine learning python preparation
February 12, 2018
Almost everyone has heard of artificial intelligence. When it comes to artificial intelligence, it must be said that Python, why artificial intelligence and Python have a close relationship? The main reason lies in two aspects. 1 is that Python's language is relatively simple, writing code is easy to understand, and so many algorithms of machine learning and deep learning in artificial intelligence have already caused people a headache. Using Python language can make people pay more attention. It's on the algorithm, not the big mountain that is the most difficult language to cross C++. 2 is the framework of machine learning and deep learning are Python language interfaces, such as the famous machine learning scikit-learn package and Google's deep learning tensorflow. So learning python plus various packages is necessary. This article describes how to install the scikit-learn package in python. Because there are a lot of things to install, many people can't touch the mind, I wrote a tutorial on the installation process. I personally use the habit of pycharm.
1. Install pycharm, this is the python IDE. Download the official website and find the registration code.
2. Install Anaconda2, which is divided into python2 and python3 versions, as well as 32-bit and 64-bit versions. You should see it when you choose to download. The person just getting started will ask why this is installed. Because this software integrates most of the packages needed for machine learning, numpy, matplotlib, pandas, sci-kit learn are integrated inside, and the installation is once and for all. Here is a note to see if you want to install python2.7 or python3.6, which is almost the same, Python2.7 does not support Chinese, and some syntax is a little different from Python3.6, but it does not have much impact. But many online machine learning videos are based on Python 2.7, so you can choose your personal preferences.
Baidu search on the official website to download it. Download the direct installation.
3. Add Anaconda2 to the python interpreter in pycharm.
Import numpy after installation
Import sklearn can check if the package is added successfully
You can see that there is no red line after the guide package, indicating that the addition is successful.
4. Download and install graphviz, because there is an algorithm in machine learning that is a decision tree. This software is used to print the decision tree, and finally can output the pdf decision tree file.
5. Install graphviz, configure the environment variables as shown below after installation. This is mainly to use graphviz on the command line.
After the installation of dot -version to check whether the installation is successful, the following shows that the installation is successful.
6. The decision tree file generated by python is .dot and looks very "friendly".
The following is the decision tree generated by sci-kit learn, does it seem "disgusting". That will use graphviz
7. You must go to your decision tree folder path on the command line and use the following command to convert the above decision tree file into a friendly decision tree file.
Dot -Tpdf xxx.dot -o xxx.pdf
Where xxx is the file name
The decision tree file myDT I generated is placed under F:\ML\DTree, so I want to advance to this folder. Use the conversion command again.
8. The printed decision tree looks like this. This is the converted file of the decision tree in step 6, is not friendly.
Ok, here, basically the configuration of playing machine learning in Python is over. Hope it helps you. After reading it, please!