Skip to content

Commit

Permalink
Update clustering.md
Browse files Browse the repository at this point in the history
  • Loading branch information
lawrennd authored Nov 6, 2023
1 parent 69e5519 commit 1e4f15f
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions _ml/includes/clustering.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,9 @@ for i in range(6):
centres[j, :] = np.mean(Y[ind==j, :], 0)
c[0].set_data(centres[:, 0], centres[:, 1])
counter+=1
mlai.write_figure(f"kmeans_clustering_{counter:0>3}.svg", directory="ml")
mlai.write_figure(f"kmeans_clustering_{counter:0>3}.svg", directory="\writeDiagramsDir/ml")
write_plot(counter, 'Allocate each data point to the nearest cluster centre.')}

\setupdisplaycode{import notutils as nu}
\setupdisplaycode{import notutils as nu}
\displaycode{nu.display_plots('kmeans_clustering_{counter:0>3}.svg', directory='\writeDiagramsDir/ml',
text_top='kmeans_clustering_{counter:0>3}.tex', counter=(0, 13))}
Expand All @@ -127,17 +126,16 @@ ax.plot(Y[:, 0], Y[:, 1], 'rx')
ax.set_xlabel('$y_1$', fontsize=20)
ax.set_ylabel('$y_2$', fontsize=20)

mlai.write_figure(\writeDiagramsDir/ml/cluster_data00.svg')
mlai.write_figure("cluster_data00.svg', directory="\writeDiagramsDir/ml/")
pi_vals = np.linspace(-np.pi, np.pi, 200)[:, None]
for i in range(num_centres):
ax.plot(centres[i, 0], centres[i, 1], 'o', markersize=5, color=[0, 0, 0], linewidth=2)
x = np.hstack([np.sin(pi_vals), np.cos(pi_vals)])
L = np.linalg.cholesky(np.outer(w[i, :],w[i, :]) + sigma[i]**2*np.eye(2))
el = np.dot(x, L.T)
ax.plot(centres[i, 0] + el[:, 0], centres[i, 1] + el[:, 1], linewidth=2, color=[0,0,0])
mlai.write_figure(\writeDiagramsDir/ml/cluster_data01.svg')}
mlai.write_figure("cluster_data01.svg", directory="\writeDiagramsDir/ml/")}

\setupdisplaycode{import notutils as nu}
\setupdisplaycode{import notutils as nu}
\displaycode{nu.display_plots('cluster_data{counter:0>2}.svg', directory='\writeDiagramsDir/ml', counter=(0, 1))}

Expand Down

0 comments on commit 1e4f15f

Please sign in to comment.