diff --git a/labs/04_machine-learning/04_PCA-analysis_key.ipynb b/labs/04_machine-learning/04_PCA-analysis_key.ipynb index d05919f..4c53975 100644 --- a/labs/04_machine-learning/04_PCA-analysis_key.ipynb +++ b/labs/04_machine-learning/04_PCA-analysis_key.ipynb @@ -28,7 +28,7 @@ "metadata": {}, "source": [ "## Protein structures\n", - "+ Write a function that loads in the `x`, `y`, and `z` coordinates for all `CA` atoms from a pdb file." + "+ Write a function that loads in the `x`, `y`, and `z` coordinates for all `CA` atoms from a pdb file and returns all the coordinates in an numpy array. (Hint: the shape of this array should be (number-of-`CA`-atoms, 3).)" ] }, { @@ -64,9 +64,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": true - }, + "metadata": {}, "outputs": [], "source": [ "hm1 = load_pdb(\"homolog-1.pdb\")\n", @@ -83,9 +81,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "plt.plot(hm1[:,0],hm1[:,1])\n", @@ -120,15 +116,13 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "+ Plot the transformed coordinates on top of one another." + "+ Plot the first 2 transformed coordinates on top of one another." ] }, { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "plt.plot(t_hm1[:,0],t_hm1[:,1])\n", @@ -146,7 +140,6 @@ "cell_type": "code", "execution_count": null, "metadata": { - "collapsed": false, "scrolled": true }, "outputs": [], @@ -166,9 +159,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "import pandas\n", @@ -184,7 +175,7 @@ "pca_fit = pca.fit(X)\n", "Q = pca_fit.transform(X)\n", "\n", - "a = X.shape[0]/num_data_sets\n", + "a = int(X.shape[0]/num_data_sets)\n", "for i in range(X.shape[1]):\n", " plt.plot(X[(i*a):((i+1)*a),3],\n", " X[(i*a):((i+1)*a),4],\"o\")\n", @@ -210,9 +201,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "pca_fit.explained_variance_ratio_" @@ -240,9 +229,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "for i in range(Q.shape[1]):\n", @@ -310,9 +297,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "f = open(\"pca_dataset.csv\")\n", @@ -341,7 +326,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.5.2" + "version": "3.4.3" } }, "nbformat": 4,