I tried to build an environment for machine learning with Python (Mac OS X)

At the CROSS 2015 python session the other day, I thought that machine learning would be interesting, so I tried to prepare the environment for the time being, so I'm sorry.

The other day's article on CROSS 2015 is here.

: black_square_button: Overview

--Building an environment where machine learning can be done with python ――I haven't done much, so I thought it was necessary to give it to Qiita, but I personally got into various things, so I will give it to you.

: black_square_button: Premise

: black_square_button: Various installations

$ brew update
$ brew upgrade
$ brew install python

For the time being, check the version

$ python -V 
Python 2.7.5

pip

$ pip install --upgrade setuptools
$ pip install --upgrade pip

Set the path in .bash_profile. I forgot. .. If you don't do this, you will get the following error when importing scikit-learn.

ImportError: No module named sklearn

So add the path to .bash_profile.

export PATH=/usr/local/bin:$PATH
export PATH=/usr/local/share/python:$PATH

Update after adding the above to .bash_profile.

source ~/.bash_profile

--Install various math libraries

$ pip install numpy
$ pip install scipy
$ pip install matplotlib
$ pip install scikit-learn
$ pip install pandas
$ pip install pydot
$ pip install rpy2
$ pip install ipython
$ pip install pyzmq
$ pip install tornado
$ pip install jinja2

I ran into the following error when installing rpy2.

$ pip install rpy2
Collecting rpy2
  Using cached rpy2-2.5.5.tar.gz
    Error: Tried to guess R's HOME but no R command in the PATH.
    Complete output from command python setup.py egg_info:
    Error: Tried to guess R's HOME but no R command in the PATH.

    ----------------------------------------
    Command "python setup.py egg_info" failed with error code 1 in /private/var/folders/jl/h7wk98516f1_tj7zg87r08b00000gn/T/pip-build-Cs7fDa/rpy2

You don't have R installed. .. That's right. ..
Refer to the following for how to install R on MacOSX. Thank you. Thank you.
Install R with homebrew on MacOSX I was quite addicted to it. ..

: black_square_button: Miscellaneous feelings

――I feel like I somehow understand why python is attracting attention in machine learning. ――Because there are abundant libraries in mathematics, engineering, and statistics? ――Is there so much Ruby? I can't say anything because I haven't investigated it properly. .. --It's great to be able to call R-related libraries with rpy2 and pandas ――Is it a feature of Python that there are Scipy and scikit-learn? --This completes the environment for boxplots, histograms, regression analysis, cluster analysis, etc. ――By the way, I remembered that I was doing statistical things when I was a student, and I felt a little nostalgic. .. .. ――If you have a good library other than the above, please let me know. ――After all, I think it wasn't enough to give to Qiita. ..

: black_square_button: Reference

-I put ipython in Mavericks -Install R with homebrew on MacOSX

Recommended Posts

I tried to build an environment for machine learning with Python (Mac OS X)
I tried to build a Mac Python development environment with pythonz + direnv
Build an interactive environment for machine learning in Python
Build a machine learning Python environment on Mac OS
Build an environment for machine learning using Python on MacOSX
[Definitive Edition] Building an environment for learning "machine learning" using Python on Mac
I tried to move machine learning (ObjectDetection) with TouchDesigner
Building an environment for "Tello_Video" on Mac OS X
Build a Python development environment on Mac OS X
Build a machine learning application development environment with Python
How to build an environment for using multiple versions of Python on Mac
I tried to build an environment of Ubuntu 20.04 LTS + ROS2 with Raspberry Pi 4
How to Introduce IPython (Python2) to Mac OS X-Preparation for Introduction to Machine Learning Theory-
Rebuilding an environment for machine learning with Miniconda (Windows version)
I tried to build an environment with WSL + Ubuntu + VS Code in a Windows environment
I tried to make a real-time sound source separation mock with Python machine learning
I tried machine learning with liblinear
I tried to create a reinforcement learning environment for Othello with Open AI gym
Mayungo's Python Learning Episode 3: I tried to print numbers with print
Machine learning environment settings based on Python 3 on Mac (coexistence with Python 2)
I learned MNIST with Caffe and tried to draw it (MAC OS X El Capitan)
I created an environment for Masonite, a Python web framework similar to Laravel, with Docker!
Building a Windows 7 environment for getting started with machine learning with Python
[Pandas] I tried to analyze sales data with Python [For beginners]
I tried to display GUI on Mac with X Window System
[Machine learning] I tried to do something like passing an image
I tried to make an image similarity function with Python + OpenCV
[Python] Building an environment with Anaconda [Mac]
Build an environment for Blender built-in Python
Amplify images for machine learning with python
I installed Python 3.5.1 to study machine learning
An introduction to OpenCV for machine learning
I want to build a Python environment
I tried sending an email with python.
[Shakyo] Encounter with Python for machine learning
Build Python environment with Anaconda on Mac
I tried to understand supervised learning of machine learning in an easy-to-understand manner even for server engineers 1
I tried to understand supervised learning of machine learning in an easy-to-understand manner even for server engineers 2
Anyone can understand how to build an initial environment for Python on Mac September 2016 (pyenv + virutalenv)
[Definitive Edition] Building an environment for learning "machine learning" using Python on Windows
I tried to refer to the fun rock-paper-scissors poi for beginners with Python
Build an environment with pyenv, pyenv-virtualenv, jupyter on OS X El Capitan
Mayungo's Python Learning Episode 2: I tried to put out characters with variables
(Machine learning) I tried to understand Bayesian linear regression carefully with implementation.
A beginner of machine learning tried to predict Arima Kinen with python
I tried to visualize the model with the low-code machine learning library "PyCaret"
I started machine learning with Python (I also started posting to Qiita) Data preparation
Introduction to Graph Database Neo4j in Python for Beginners (for Mac OS X)
[Python] Easy introduction to machine learning with python (SVM)
An introduction to machine learning for bot developers
For beginners to build an Anaconda environment. (Memo)
Building an environment for executing Python scripts (for mac)
I tried to get CloudWatch data with Python
I tried to output LLVM IR with Python
[Python] Collect images with Icrawler for machine learning [1000 images]
I tried to detect an object with M2Det!
I tried to automate sushi making with python
I started machine learning with Python Data preprocessing
[Mac] I tried reinforcement learning with OpenAI Baselines
Build an environment to execute C ++ functions from Python with Pybind11 (for Windows & Visual Studio Code people)
I want to create a nice Python development environment for my new Mac