Skip to content

Commit

Permalink
Numerous ex8 fixes
Browse files Browse the repository at this point in the history
- Formatting
- More consistent display of plots
  • Loading branch information
jtlowery committed May 8, 2017
1 parent 1e17b41 commit ad61e9c
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
1 change: 0 additions & 1 deletion ex8/estimateGaussian.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ def estimateGaussian(X):
# In particular, mu(i) should contain the mean of
# the data for the i-th feature and sigma2(i)
# should contain variance of the i-th feature.
#
# =============================================================

return mu, sigma2
Expand Down
6 changes: 5 additions & 1 deletion ex8/ex8.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
show()
input('Program paused. Press Enter to continue...')


# ================== Part 2: Estimate the dataset statistics ===================
# For this exercise, we assume a Gaussian distribution for the dataset.
#
Expand All @@ -71,6 +70,7 @@
p = multivariateGaussian(X, mu, sigma2)

# Visualize the fit
plt.figure()
visualizeFit(X, mu, sigma2)
plt.xlabel('Latency (ms)')
plt.ylabel('Throughput (mb/s)')
Expand All @@ -93,6 +93,10 @@
outliers = np.where(p < epsilon, True, False)

# Draw a red circle around those outliers
plt.figure()
visualizeFit(X, mu, sigma2)
plt.xlabel('Latency (ms)')
plt.ylabel('Throughput (mb/s)')
plt.plot(X[outliers, 0], X[outliers, 1], 'ro', lw=2,
markersize=10, fillstyle='none', markeredgewidth=1)
show()
Expand Down
3 changes: 2 additions & 1 deletion ex8/ex8_cofi.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
# We can "visualize" the ratings matrix by plotting it with imagesc

plt.figure()
plt.imshow(Y, aspect='equal', origin='upper', extent=(0, Y.shape[1], 0, Y.shape[0]/2.0))
plt.imshow(Y, aspect='equal', origin='upper',
extent=(0, Y.shape[1], 0, Y.shape[0]/2.0))
plt.ylabel('Movies')
plt.xlabel('Users')
show()
Expand Down
1 change: 0 additions & 1 deletion ex8/visualizeFit.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,3 @@ def visualizeFit(X, mu, sigma2):
# Do not plot if there are infinities
if not isinf(np.sum(Z)):
plt.contour(X1[0], X1[1], Z, 10.0 ** np.arange(-20, 0, 3).T)
show()

0 comments on commit ad61e9c

Please sign in to comment.