Let's do machine learning using Python! (`Д´) Elder !! So, it's my first time to touch Python, so it's a memo.
If you have any mistakes, please point them out. Mm
Reference book used this time
-Python Machine Learning Programming Expert Data Scientist Theory and Practice
Our environment
If you are using a Mac, it seems that the 2nd system is included. (The version recommended in the reference book is 3.4.3 or later)
//Check the version in the terminal
$ python --version
Python 2.7.10
It seems that if you include ANACONDA, it will prepare the necessary packages to some extent. Personal images are like XAMPP, MAMP if you compare it with php. Impression.
If you do not have basic knowledge about ANACONDA, please refer to the following. -Building a python environment for those who aim to become data scientists 2016
Introduction example | Install Python environment with Anaconda |
Download destination | https://www.continuum.io/downloads |
//Version confirmation
$ python --version
//* Location of the command body
$ which python3
/usr/local/bin/python3
//* Digression.bash_The path has been added to the profile
$ cat ~/.bash_profile
It seems that the path of the package that is included in the Mac by default is replaced with the one added by ANACONDA.
If you are interested, please check it by doing `which``` or
`ls -al```.
Description | command |
---|---|
Execution command | $ python |
Package management tool(Upward compatible with pip?) | $ conda |
Package management tool | $ pip |
Convert Python2 code to Python3 | $ 2to3 |
Introduction example | Python3 installation |
Download destination | https://www.python.org/downloads/ |
//Version confirmation
$ python3 --version
//* Location of the command body
$ which python3
/usr/local/bin/python3
$ ls -al /usr/local/bin/python3
/Library/Frameworks/Python.framework/Versions/3.5/lib/
//* Digression.bash_The path has been added to the profile
$ cat ~/.bash_profile
It seems that the package will be included with a different name from the package that is included in the Mac by default.
If you are interested, please check it by doing `which``` or
`ls -al```.
originally or add |
Description | command |
---|---|---|
originally | Execution command | $ python |
originally | Package management tool | $ pip |
add to | Execution command | $ python3 |
add to | Package management tool | $ pip3 |
add to | Convert Python2 code to Python3 | $ 2to3 |
//Check the package
$ pip list
This time, check if the following packages are included, and if not, try to install them.
Distribution | Version |
---|---|
NumPy | 1.9.1 |
SciPy | 0.14.0 |
scikit-learn | 0.15.2 |
matplotlib | 1.40.0 |
pandas | 0.15.2 |
If the above is not included, introduce below
■ When entering with ANACONDA When ANACONDA was installed, a package management tool called `` `conda``` was added, so If you can use it, you should use it to add packages.
//Package introduction
$ conda install <package name>
//Package update
$ conda update <package name>
■ If you have not entered in ANACONDA
//Package introduction
$ pip install <package name>
//Package update
$ pip install <package name> -upgrade
By the way, in my environment, the above package was a little old, so I updated it below.
■ Survey
//With ANACONDA
$ conda list | grep -e numpy -e scipy -e scikit-learn -e matplotlib -e pandas
//No ANACONDA
$ pip list | grep -e numpy -e scipy -e scikit-learn -e matplotlib -e pandas
■ Update
//With ANACONDA
$ conda update matplotlib
$ conda update numpy
$ conda update pandas
$ conda update scikit-learn
$ conda update scipy
//No ANACONDA
$ pip install matplotlib --upgrade
$ pip install numpy --upgrade
$ pip install pandas --upgrade
$ pip install scikit-learn --upgrade
$ pip install scipy --upgrade
That's it.
As I wrote at the beginning, if there are any mistakes, It would be helpful if you could point it out mm
Recommended Posts