File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 747747 " for i in range(len(eigen_vals))]\n",
748748 "\n",
749749 "# Sort the (eigenvalue, eigenvector) tuples from high to low\n",
750- "eigen_pairs.sort(reverse=True)"
750+ "eigen_pairs.sort(key=lambda k: k[0], reverse=True)\n",
751+ "\n",
752+ "# Note: I added the `key=lambda k: k[0]` in the sort call above\n",
753+ "# just like I used it further below in the LDA section.\n",
754+ "# This is to avoid problems if there are ties in the eigenvalue\n",
755+ "# arrays (i.e., the sorting algorithm will only regard the\n",
756+ "# first element of the tuples, now)."
751757 ]
752758 },
753759 {
23182324 ],
23192325 "metadata": {
23202326 "kernelspec": {
2321- "display_name": "Python 2 ",
2327+ "display_name": "Python 3 ",
23222328 "language": "python",
2323- "name": "python2 "
2329+ "name": "python3 "
23242330 },
23252331 "language_info": {
23262332 "codemirror_mode": {
23272333 "name": "ipython",
2328- "version": 2
2334+ "version": 3
23292335 },
23302336 "file_extension": ".py",
23312337 "mimetype": "text/x-python",
23322338 "name": "python",
23332339 "nbconvert_exporter": "python",
2334- "pygments_lexer": "ipython2 ",
2335- "version": "2.7.11 "
2340+ "pygments_lexer": "ipython3 ",
2341+ "version": "3.5.1 "
23362342 }
23372343 },
23382344 "nbformat": 4,
You can’t perform that action at this time.
0 commit comments