Skip to content

Commit 48d1bec

Browse files
committed
Added seaborn.
1 parent 9ab659a commit 48d1bec

File tree

1 file changed

+27
-21
lines changed

1 file changed

+27
-21
lines changed

main.md

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Some imports.
4545
<pre data-code-language="python"
4646
data-executable="true"
4747
data-type="programlisting">
48-
# That's an impressive list of imports!
48+
# That's an impressive list of imports.
4949
import numpy as np
5050
from numpy import linalg
5151
from numpy.linalg import norm
@@ -63,18 +63,20 @@ from sklearn.manifold.t_sne import (_joint_probabilities,
6363
_kl_divergence)
6464
from sklearn.utils.extmath import _ravel
6565

66-
# matplotlib for graphics
66+
# matplotlib for graphics.
6767
import matplotlib.pyplot as plt
6868
import matplotlib.patheffects as PathEffects
6969
import matplotlib
70+
%matplotlib inline
71+
72+
# We import seaborn for improve aesthetics.
73+
import seaborn as sns
74+
sns.set_style('darkgrid')
75+
sns.set_context("notebook", font_scale=1.5, rc={"lines.linewidth": 2.5})
7076

71-
# We'll generate an animation with matplotlib and moviepy
77+
# We'll generate an animation with matplotlib and moviepy.
7278
from moviepy.video.io.bindings import mplfig_to_npimage
7379
import moviepy.editor as mpy
74-
75-
# Some matplotlib params.
76-
%matplotlib inline
77-
matplotlib.rcParams.update({'font.size': 22})
7880
</pre>
7981

8082
Illustration on digit dataset.
@@ -290,37 +292,41 @@ animation.write_gif("anim2.gif", fps=20)
290292

291293
<img src="anim2.gif" />
292294

293-
<pre data-code-language="python"
294-
data-executable="true"
295-
data-type="programlisting">
296-
def simpleaxis(ax):
297-
ax.spines['top'].set_visible(False)
298-
ax.spines['left'].set_visible(False)
299-
ax.set_yticks([]);
300-
ax.get_xaxis().tick_bottom()
301-
ax.set_xticks([0., .5, 1.]);
302-
</pre>
303-
304295
<pre data-code-language="python"
305296
data-executable="true"
306297
data-type="programlisting">
307298
npoints = 1000
308-
plt.figure(figsize=(14, 3))
299+
plt.figure(figsize=(15, 4))
309300
for i, D in enumerate((2, 5, 10)):
301+
# Normally distributed points.
310302
u = np.random.randn(npoints, D)
303+
# Now on the sphere.
311304
u /= norm(u, axis=1)[:, None]
305+
# Uniform radius.
312306
r = np.random.rand(npoints, 1)
307+
# Uniformly within the ball.
313308
points = u * r**(1./D)
309+
# Plot.
314310
ax = plt.subplot(1, 3, i+1)
315311
ax.set_xlabel('Ball radius')
316312
if i == 0:
317-
ax.set_ylabel('Distance from\norigin')
318-
simpleaxis(ax)
313+
ax.set_ylabel('Distance from origin')
319314
ax.hist(norm(points, axis=1),
320315
bins=np.linspace(0., 1., 50))
321316
ax.set_title('D=%d' % D, loc='left')
322317
</pre>
323318

319+
<pre data-code-language="python"
320+
data-executable="true"
321+
data-type="programlisting">
322+
z = np.linspace(0., 5., 1000)
323+
gauss = np.exp(-z**2)
324+
cauchy = 1/(1+z**2)
325+
plt.plot(z, gauss, label='Gaussian distribution');
326+
plt.plot(z, cauchy, label='Cauchy distribution');
327+
plt.legend();
328+
</pre>
329+
324330
Equations:
325331

326332
<span class="math-tex" data-type="tex">\\(p_{j|i} = \frac{\exp(-\lVert\mathbf{x}_i - \mathbf{x}_j\rVert^2 / 2\sigma_i^2)}{\sum_{k \neq i} \exp(-\lVert\mathbf{x}_i - \mathbf{x}_k\rVert^2 / 2\sigma_i^2)}\\)</span>

0 commit comments

Comments
 (0)