In [55]:
import numpy
In [56]:
import scipy
In [57]:
import matplotlib
In [58]:
import sklearn
In [59]:
import psutil
In [60]:
import pandas
In [61]:
import IPython.parallel
Finding the location of an installed package and its version:
In [62]:
numpy.__path__
Out[62]:
In [63]:
numpy.__version__
Out[63]:
In [64]:
%run ../fetch_data.py
In [1]:
import os
for fname in os.listdir('../datasets/'):
print(fname)
In [2]:
import numpy as np
In [3]:
a = np.array([1, 2, 3])
In [4]:
a
Out[4]:
In [5]:
b = np.array([[0, 2, 4], [1, 3, 5]])
In [6]:
b
Out[6]:
In [7]:
b.shape
Out[7]:
In [8]:
b.dtype
Out[8]:
In [9]:
a.shape
Out[9]:
In [10]:
a.dtype
Out[10]:
In [11]:
np.zeros(5)
Out[11]:
In [12]:
np.ones(shape=(3, 4), dtype=np.int32)
Out[12]:
In [13]:
c = b * 0.5
In [14]:
c
Out[14]:
In [15]:
c.shape
Out[15]:
In [16]:
c.dtype
Out[16]:
In [17]:
a
Out[17]:
In [18]:
d = a + c
In [19]:
d
Out[19]:
In [20]:
d[0]
Out[20]:
In [21]:
d[0, 0]
Out[21]:
In [22]:
d[:, 0]
Out[22]:
In [23]:
d.sum()
Out[23]:
In [24]:
d.mean()
Out[24]:
In [25]:
d.sum(axis=0)
Out[25]:
In [26]:
d.mean(axis=1)
Out[26]:
In [27]:
e = np.arange(12)
In [28]:
e
Out[28]:
In [29]:
f = e.reshape(3, 4)
In [30]:
f
Out[30]:
In [31]:
e
Out[31]:
In [32]:
e[5:] = 0
In [33]:
e
Out[33]:
In [34]:
f
Out[34]:
In [35]:
a
Out[35]:
In [36]:
b
Out[36]:
In [37]:
d
Out[37]:
In [38]:
np.concatenate([a, a, a])
Out[38]:
In [39]:
np.vstack([a, b, d])
Out[39]:
In [40]:
np.hstack([b, d])
Out[40]:
In [41]:
%matplotlib inline
In [42]:
import matplotlib.pyplot as plt
In [43]:
x = np.linspace(0, 2, 10)
In [44]:
x
Out[44]:
In [45]:
plt.plot(x, 'o-');
In [46]:
plt.plot(x, x, 'o-', label='linear')
plt.plot(x, x ** 2, 'x-', label='quadratic')
plt.legend(loc='best')
plt.title('Linear vs Quadratic progression')
plt.xlabel('Input')
plt.ylabel('Output');
In [47]:
samples = np.random.normal(loc=1.0, scale=0.5, size=1000)
In [48]:
samples.shape
Out[48]:
In [49]:
samples.dtype
Out[49]:
In [50]:
samples[:30]
Out[50]:
In [51]:
plt.hist(samples, bins=50);
In [52]:
samples_1 = np.random.normal(loc=1, scale=.5, size=10000)
samples_2 = np.random.standard_t(df=10, size=10000)
In [53]:
bins = np.linspace(-3, 3, 50)
_ = plt.hist(samples_1, bins=bins, alpha=0.5, label='samples 1')
_ = plt.hist(samples_2, bins=bins, alpha=0.5, label='samples 2')
plt.legend(loc='upper left');
In [54]:
plt.scatter(samples_1, samples_2, alpha=0.1);
In [ ]:
In [ ]:
In [ ]:
In [ ]: