[Let's build a neural network with PYTHON without using a library](http://blog.moji.ai/2015/12/ Neural net without using a library with python /) in your own environment The first day I tried it.
I read up to the neural network area with [PRML](https://www.amazon.co.jp/Pattern recognition and machine learning-above-CM-Bishop / dp / 4621061224? Ie = UTF8 & redirect = true & tag = prog4ml-22) So I will try it as a practice.
I wrote that I do not use the library, but it seems that I need a python library, so I will prepare it. Some things you don't need this time, but after this series [Python Machine Learning Programming](https://www.amazon.co.jp/Python Machine Learning Programming-Theory and Practice by Expert Data Scientists-impress-top- gear / dp / 4844380605) I think I'll do it, so I put it in.
pip install --upgrade pip
pip install NumPy
pip install SciPy
pip install scikit-learn
pip install pandas
pip install matplotlib
pip install ipython
I succeeded in installing matplotlib
, but when I tried to use it, I got an error (interactively).
The symptom was the same as here RuntimeError when trying to use matplitlib and pylab in Python 3.3, so create the configuration file matplotlibrc
and change the backend settings. did.
It looks like this in my environment
python --version
Python 3.5.0
pip list
appnope (0.1.0)
cycler (0.10.0)
decorator (4.0.10)
gnureadline (6.3.3)
ipython (4.2.1)
ipython-genutils (0.1.0)
matplotlib (1.5.1)
networkx (1.11)
numpy (1.11.1)
pandas (0.18.1)
pexpect (4.1.0)
pickleshare (0.7.2)
pip (8.1.2)
ptyprocess (0.5.1)
pyparsing (2.1.5)
python-dateutil (2.5.3)
pytz (2016.4)
scikit-learn (0.17.1)
scipy (0.17.1)
setuptools (24.0.2)
simplegeneric (0.8.1)
six (1.10.0)
traitlets (4.2.2)
I used Scikit-learn as it is written in the data generation.
The data generated by make_moon
is 200 data points,
X
y
(0 or 1) for each variable X
Have the information of. It is two semicircular two-dimensional data, and is sample data with linear identification added.
ipython --pylab
Python 3.5.0 (default, Oct 17 2015, 16:12:04)
Type "copyright", "credits" or "license" for more information.
IPython 4.2.1 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
Using matplotlib backend: TkAgg
In [1]: import numpy as np
In [2]: import matplotlib.pyplot as plt
In [3]: from sklearn.datasets import make_moons
In [4]: np.random.seed(0)
In [5]: X, y = make_moons(200, noise=0.20)
In [6]: plt.scatter(X[:,0], X[:,1], s=40, c=y, cmap=plt.cm.Spectral)
Out[6]: <matplotlib.collections.PathCollection at 0x119813ef0>
The data points output for the implementation are as follows.
That's all for today.
Recommended Posts