Machine Learning An Algorithmic Perspective
ch2.py
# Code from Chapter 2 of Machine Learning: An Algorithmic Perspective (2nd Edition)
# by Stephen Marsland (http://stephenmonika.net)
# You are free to use, change, or redistribute the code in any way you wish for
# non-commercial purposes, but please maintain the name of the original author.
# This code comes with no warranty of any kind.
# Stephen Marsland, 2008, 2014
# Plots a 1D Gaussian function
from matplotlib import pylab
import pylab as pl
import numpy as np
gaussian = lambda x: 1/(np.sqrt(2*np.pi)*1.5)*np.exp(-(x-0)**2/(2*(1.5**2)))
x = np.arange(-5,5,0.01)
y = gaussian(x)
pl.ion()
pl.plot(x,y,'k',linewidth=3)
pl.xlabel('x')
pl.ylabel('y(x)')
pl.axis([-5,5,0,0.3])
pl.title('Gaussian Function (mean 0, standard deviation 1.5)')
pl.show()
----------------------------------------------------------------------
(base) C:\Users\USERNAME\Desktop>conda activate VIRTUALENV_NAME
(VIRTUALENV_NAME) C:\Users\USERNAME\Desktop>python ch1.py
(VIRTUALENV_NAME) C:\Users\USERNAME\Desktop>python -i ch1.py
- Run cmd
> python -i ch2.py
----------------------------------------------------------------------
댓글
댓글 쓰기