{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "---\n",
    "\n",
    "_You are currently looking at **version 1.0** of this notebook. To download notebooks and datafiles, as well as get help on Jupyter notebooks in the Coursera platform, visit the [Jupyter Notebook FAQ](https://www.coursera.org/learn/python-machine-learning/resources/bANLa) course resource._\n",
    "\n",
    "---"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {
    "collapsed": true
   },
   "source": [
    "# Applied Machine Learning: Module 4 (Supervised Learning, Part II)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Preamble and Datasets"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false,
    "scrolled": false
   },
   "outputs": [],
   "source": [
    "%matplotlib notebook\n",
    "import numpy as np\n",
    "import pandas as pd\n",
    "import seaborn as sn\n",
    "import matplotlib.pyplot as plt\n",
    "\n",
    "from sklearn.model_selection import train_test_split\n",
    "from sklearn.datasets import make_classification, make_blobs\n",
    "from matplotlib.colors import ListedColormap\n",
    "from sklearn.datasets import load_breast_cancer\n",
    "from adspy_shared_utilities import load_crime_dataset\n",
    "\n",
    "\n",
    "cmap_bold = ListedColormap(['#FFFF00', '#00FF00', '#0000FF','#000000'])\n",
    "\n",
    "# fruits dataset\n",
    "fruits = pd.read_table('fruit_data_with_colors.txt')\n",
    "\n",
    "feature_names_fruits = ['height', 'width', 'mass', 'color_score']\n",
    "X_fruits = fruits[feature_names_fruits]\n",
    "y_fruits = fruits['fruit_label']\n",
    "target_names_fruits = ['apple', 'mandarin', 'orange', 'lemon']\n",
    "\n",
    "X_fruits_2d = fruits[['height', 'width']]\n",
    "y_fruits_2d = fruits['fruit_label']\n",
    "\n",
    "# synthetic dataset for simple regression\n",
    "from sklearn.datasets import make_regression\n",
    "plt.figure()\n",
    "plt.title('Sample regression problem with one input variable')\n",
    "X_R1, y_R1 = make_regression(n_samples = 100, n_features=1,\n",
    "                            n_informative=1, bias = 150.0,\n",
    "                            noise = 30, random_state=0)\n",
    "plt.scatter(X_R1, y_R1, marker= 'o', s=50)\n",
    "plt.show()\n",
    "\n",
    "# synthetic dataset for more complex regression\n",
    "from sklearn.datasets import make_friedman1\n",
    "plt.figure()\n",
    "plt.title('Complex regression problem with one input variable')\n",
    "X_F1, y_F1 = make_friedman1(n_samples = 100, n_features = 7,\n",
    "                           random_state=0)\n",
    "\n",
    "plt.scatter(X_F1[:, 2], y_F1, marker= 'o', s=50)\n",
    "plt.show()\n",
    "\n",
    "# synthetic dataset for classification (binary)\n",
    "plt.figure()\n",
    "plt.title('Sample binary classification problem with two informative features')\n",
    "X_C2, y_C2 = make_classification(n_samples = 100, n_features=2,\n",
    "                                n_redundant=0, n_informative=2,\n",
    "                                n_clusters_per_class=1, flip_y = 0.1,\n",
    "                                class_sep = 0.5, random_state=0)\n",
    "plt.scatter(X_C2[:, 0], X_C2[:, 1], marker= 'o',\n",
    "           c=y_C2, s=50, cmap=cmap_bold)\n",
    "plt.show()\n",
    "\n",
    "# more difficult synthetic dataset for classification (binary)\n",
    "# with classes that are not linearly separable\n",
    "X_D2, y_D2 = make_blobs(n_samples = 100, n_features = 2,\n",
    "                       centers = 8, cluster_std = 1.3,\n",
    "                       random_state = 4)\n",
    "y_D2 = y_D2 % 2\n",
    "plt.figure()\n",
    "plt.title('Sample binary classification problem with non-linearly separable classes')\n",
    "plt.scatter(X_D2[:,0], X_D2[:,1], c=y_D2,\n",
    "           marker= 'o', s=50, cmap=cmap_bold)\n",
    "plt.show()\n",
    "\n",
    "# Breast cancer dataset for classification\n",
    "cancer = load_breast_cancer()\n",
    "(X_cancer, y_cancer) = load_breast_cancer(return_X_y = True)\n",
    "\n",
    "# Communities and Crime dataset\n",
    "(X_crime, y_crime) = load_crime_dataset()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Naive Bayes classifiers"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "from sklearn.naive_bayes import GaussianNB\n",
    "from adspy_shared_utilities import plot_class_regions_for_classifier\n",
    "\n",
    "X_train, X_test, y_train, y_test = train_test_split(X_C2, y_C2, random_state=0)\n",
    "\n",
    "nbclf = GaussianNB().fit(X_train, y_train)\n",
    "plot_class_regions_for_classifier(nbclf, X_train, y_train, X_test, y_test,\n",
    "                                 'Gaussian Naive Bayes classifier: Dataset 1')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "X_train, X_test, y_train, y_test = train_test_split(X_D2, y_D2,\n",
    "                                                   random_state=0)\n",
    "\n",
    "nbclf = GaussianNB().fit(X_train, y_train)\n",
    "plot_class_regions_for_classifier(nbclf, X_train, y_train, X_test, y_test,\n",
    "                                 'Gaussian Naive Bayes classifier: Dataset 2')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Application to a real-world dataset"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "X_train, X_test, y_train, y_test = train_test_split(X_cancer, y_cancer, random_state = 0)\n",
    "\n",
    "nbclf = GaussianNB().fit(X_train, y_train)\n",
    "print('Breast cancer dataset')\n",
    "print('Accuracy of GaussianNB classifier on training set: {:.2f}'\n",
    "     .format(nbclf.score(X_train, y_train)))\n",
    "print('Accuracy of GaussianNB classifier on test set: {:.2f}'\n",
    "     .format(nbclf.score(X_test, y_test)))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Ensembles of Decision Trees"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Random forests"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false,
    "scrolled": false
   },
   "outputs": [],
   "source": [
    "from sklearn.ensemble import RandomForestClassifier\n",
    "from sklearn.model_selection import train_test_split\n",
    "from adspy_shared_utilities import plot_class_regions_for_classifier_subplot\n",
    "\n",
    "X_train, X_test, y_train, y_test = train_test_split(X_D2, y_D2,\n",
    "                                                   random_state = 0)\n",
    "fig, subaxes = plt.subplots(1, 1, figsize=(6, 6))\n",
    "\n",
    "clf = RandomForestClassifier().fit(X_train, y_train)\n",
    "title = 'Random Forest Classifier, complex binary dataset, default settings'\n",
    "plot_class_regions_for_classifier_subplot(clf, X_train, y_train, X_test,\n",
    "                                         y_test, title, subaxes)\n",
    "\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Random forest: Fruit dataset"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false,
    "scrolled": false
   },
   "outputs": [],
   "source": [
    "from sklearn.ensemble import RandomForestClassifier\n",
    "from sklearn.model_selection import train_test_split\n",
    "from adspy_shared_utilities import plot_class_regions_for_classifier_subplot\n",
    "\n",
    "X_train, X_test, y_train, y_test = train_test_split(X_fruits.as_matrix(),\n",
    "                                                   y_fruits.as_matrix(),\n",
    "                                                   random_state = 0)\n",
    "fig, subaxes = plt.subplots(6, 1, figsize=(6, 32))\n",
    "\n",
    "title = 'Random Forest, fruits dataset, default settings'\n",
    "pair_list = [[0,1], [0,2], [0,3], [1,2], [1,3], [2,3]]\n",
    "\n",
    "for pair, axis in zip(pair_list, subaxes):\n",
    "    X = X_train[:, pair]\n",
    "    y = y_train\n",
    "    \n",
    "    clf = RandomForestClassifier().fit(X, y)\n",
    "    plot_class_regions_for_classifier_subplot(clf, X, y, None,\n",
    "                                             None, title, axis,\n",
    "                                             target_names_fruits)\n",
    "    \n",
    "    axis.set_xlabel(feature_names_fruits[pair[0]])\n",
    "    axis.set_ylabel(feature_names_fruits[pair[1]])\n",
    "    \n",
    "plt.tight_layout()\n",
    "plt.show()\n",
    "\n",
    "clf = RandomForestClassifier(n_estimators = 10,\n",
    "                            random_state=0).fit(X_train, y_train)\n",
    "\n",
    "print('Random Forest, Fruit dataset, default settings')\n",
    "print('Accuracy of RF classifier on training set: {:.2f}'\n",
    "     .format(clf.score(X_train, y_train)))\n",
    "print('Accuracy of RF classifier on test set: {:.2f}'\n",
    "     .format(clf.score(X_test, y_test)))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Random Forests on a real-world dataset"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "from sklearn.ensemble import RandomForestClassifier\n",
    "\n",
    "X_train, X_test, y_train, y_test = train_test_split(X_cancer, y_cancer, random_state = 0)\n",
    "\n",
    "clf = RandomForestClassifier(max_features = 8, random_state = 0)\n",
    "clf.fit(X_train, y_train)\n",
    "\n",
    "print('Breast cancer dataset')\n",
    "print('Accuracy of RF classifier on training set: {:.2f}'\n",
    "     .format(clf.score(X_train, y_train)))\n",
    "print('Accuracy of RF classifier on test set: {:.2f}'\n",
    "     .format(clf.score(X_test, y_test)))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Gradient-boosted decision trees"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "from sklearn.ensemble import GradientBoostingClassifier\n",
    "from sklearn.model_selection import train_test_split\n",
    "from adspy_shared_utilities import plot_class_regions_for_classifier_subplot\n",
    "\n",
    "X_train, X_test, y_train, y_test = train_test_split(X_D2, y_D2, random_state = 0)\n",
    "fig, subaxes = plt.subplots(1, 1, figsize=(6, 6))\n",
    "\n",
    "clf = GradientBoostingClassifier().fit(X_train, y_train)\n",
    "title = 'GBDT, complex binary dataset, default settings'\n",
    "plot_class_regions_for_classifier_subplot(clf, X_train, y_train, X_test,\n",
    "                                         y_test, title, subaxes)\n",
    "\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Gradient boosted decision trees on the fruit dataset"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false,
    "scrolled": false
   },
   "outputs": [],
   "source": [
    "X_train, X_test, y_train, y_test = train_test_split(X_fruits.as_matrix(),\n",
    "                                                   y_fruits.as_matrix(),\n",
    "                                                   random_state = 0)\n",
    "fig, subaxes = plt.subplots(6, 1, figsize=(6, 32))\n",
    "\n",
    "pair_list = [[0,1], [0,2], [0,3], [1,2], [1,3], [2,3]]\n",
    "\n",
    "for pair, axis in zip(pair_list, subaxes):\n",
    "    X = X_train[:, pair]\n",
    "    y = y_train\n",
    "    \n",
    "    clf = GradientBoostingClassifier().fit(X, y)\n",
    "    plot_class_regions_for_classifier_subplot(clf, X, y, None,\n",
    "                                             None, title, axis,\n",
    "                                             target_names_fruits)\n",
    "    \n",
    "    axis.set_xlabel(feature_names_fruits[pair[0]])\n",
    "    axis.set_ylabel(feature_names_fruits[pair[1]])\n",
    "    \n",
    "plt.tight_layout()\n",
    "plt.show()\n",
    "clf = GradientBoostingClassifier().fit(X_train, y_train)\n",
    "\n",
    "print('GBDT, Fruit dataset, default settings')\n",
    "print('Accuracy of GBDT classifier on training set: {:.2f}'\n",
    "     .format(clf.score(X_train, y_train)))\n",
    "print('Accuracy of GBDT classifier on test set: {:.2f}'\n",
    "     .format(clf.score(X_test, y_test)))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Gradient-boosted decision trees on a real-world dataset"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "from sklearn.ensemble import GradientBoostingClassifier\n",
    "\n",
    "X_train, X_test, y_train, y_test = train_test_split(X_cancer, y_cancer, random_state = 0)\n",
    "\n",
    "clf = GradientBoostingClassifier(random_state = 0)\n",
    "clf.fit(X_train, y_train)\n",
    "\n",
    "print('Breast cancer dataset (learning_rate=0.1, max_depth=3)')\n",
    "print('Accuracy of GBDT classifier on training set: {:.2f}'\n",
    "     .format(clf.score(X_train, y_train)))\n",
    "print('Accuracy of GBDT classifier on test set: {:.2f}\\n'\n",
    "     .format(clf.score(X_test, y_test)))\n",
    "\n",
    "clf = GradientBoostingClassifier(learning_rate = 0.01, max_depth = 2, random_state = 0)\n",
    "clf.fit(X_train, y_train)\n",
    "\n",
    "print('Breast cancer dataset (learning_rate=0.01, max_depth=2)')\n",
    "print('Accuracy of GBDT classifier on training set: {:.2f}'\n",
    "     .format(clf.score(X_train, y_train)))\n",
    "print('Accuracy of GBDT classifier on test set: {:.2f}'\n",
    "     .format(clf.score(X_test, y_test)))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Neural networks"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Activation functions"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "xrange = np.linspace(-2, 2, 200)\n",
    "\n",
    "plt.figure(figsize=(7,6))\n",
    "\n",
    "plt.plot(xrange, np.maximum(xrange, 0), label = 'relu')\n",
    "plt.plot(xrange, np.tanh(xrange), label = 'tanh')\n",
    "plt.plot(xrange, 1 / (1 + np.exp(-xrange)), label = 'logistic')\n",
    "plt.legend()\n",
    "plt.title('Neural network activation functions')\n",
    "plt.xlabel('Input value (x)')\n",
    "plt.ylabel('Activation function output')\n",
    "\n",
    "plt.show()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Neural networks: Classification"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Synthetic dataset 1: single hidden layer"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false,
    "scrolled": false
   },
   "outputs": [],
   "source": [
    "from sklearn.neural_network import MLPClassifier\n",
    "from adspy_shared_utilities import plot_class_regions_for_classifier_subplot\n",
    "\n",
    "X_train, X_test, y_train, y_test = train_test_split(X_D2, y_D2, random_state=0)\n",
    "\n",
    "fig, subaxes = plt.subplots(3, 1, figsize=(6,18))\n",
    "\n",
    "for units, axis in zip([1, 10, 100], subaxes):\n",
    "    nnclf = MLPClassifier(hidden_layer_sizes = [units], solver='lbfgs',\n",
    "                         random_state = 0).fit(X_train, y_train)\n",
    "    \n",
    "    title = 'Dataset 1: Neural net classifier, 1 layer, {} units'.format(units)\n",
    "    \n",
    "    plot_class_regions_for_classifier_subplot(nnclf, X_train, y_train,\n",
    "                                             X_test, y_test, title, axis)\n",
    "    plt.tight_layout()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Synthetic dataset 1: two hidden layers"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "from adspy_shared_utilities import plot_class_regions_for_classifier\n",
    "\n",
    "X_train, X_test, y_train, y_test = train_test_split(X_D2, y_D2, random_state=0)\n",
    "\n",
    "nnclf = MLPClassifier(hidden_layer_sizes = [10, 10], solver='lbfgs',\n",
    "                     random_state = 0).fit(X_train, y_train)\n",
    "\n",
    "plot_class_regions_for_classifier(nnclf, X_train, y_train, X_test, y_test,\n",
    "                                 'Dataset 1: Neural net classifier, 2 layers, 10/10 units')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Regularization parameter: alpha"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false,
    "scrolled": false
   },
   "outputs": [],
   "source": [
    "X_train, X_test, y_train, y_test = train_test_split(X_D2, y_D2, random_state=0)\n",
    "\n",
    "fig, subaxes = plt.subplots(4, 1, figsize=(6, 23))\n",
    "\n",
    "for this_alpha, axis in zip([0.01, 0.1, 1.0, 5.0], subaxes):\n",
    "    nnclf = MLPClassifier(solver='lbfgs', activation = 'tanh',\n",
    "                         alpha = this_alpha,\n",
    "                         hidden_layer_sizes = [100, 100],\n",
    "                         random_state = 0).fit(X_train, y_train)\n",
    "    \n",
    "    title = 'Dataset 2: NN classifier, alpha = {:.3f} '.format(this_alpha)\n",
    "    \n",
    "    plot_class_regions_for_classifier_subplot(nnclf, X_train, y_train,\n",
    "                                             X_test, y_test, title, axis)\n",
    "    plt.tight_layout()\n",
    "    "
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### The effect of different choices of activation function"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false,
    "scrolled": false
   },
   "outputs": [],
   "source": [
    "X_train, X_test, y_train, y_test = train_test_split(X_D2, y_D2, random_state=0)\n",
    "\n",
    "fig, subaxes = plt.subplots(3, 1, figsize=(6,18))\n",
    "\n",
    "for this_activation, axis in zip(['logistic', 'tanh', 'relu'], subaxes):\n",
    "    nnclf = MLPClassifier(solver='lbfgs', activation = this_activation,\n",
    "                         alpha = 0.1, hidden_layer_sizes = [10, 10],\n",
    "                         random_state = 0).fit(X_train, y_train)\n",
    "    \n",
    "    title = 'Dataset 2: NN classifier, 2 layers 10/10, {} \\\n",
    "activation function'.format(this_activation)\n",
    "    \n",
    "    plot_class_regions_for_classifier_subplot(nnclf, X_train, y_train,\n",
    "                                             X_test, y_test, title, axis)\n",
    "    plt.tight_layout()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Neural networks: Regression"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "from sklearn.neural_network import MLPRegressor\n",
    "\n",
    "fig, subaxes = plt.subplots(2, 3, figsize=(11,8), dpi=70)\n",
    "\n",
    "X_predict_input = np.linspace(-3, 3, 50).reshape(-1,1)\n",
    "\n",
    "X_train, X_test, y_train, y_test = train_test_split(X_R1[0::5], y_R1[0::5], random_state = 0)\n",
    "\n",
    "for thisaxisrow, thisactivation in zip(subaxes, ['tanh', 'relu']):\n",
    "    for thisalpha, thisaxis in zip([0.0001, 1.0, 100], thisaxisrow):\n",
    "        mlpreg = MLPRegressor(hidden_layer_sizes = [100,100],\n",
    "                             activation = thisactivation,\n",
    "                             alpha = thisalpha,\n",
    "                             solver = 'lbfgs').fit(X_train, y_train)\n",
    "        y_predict_output = mlpreg.predict(X_predict_input)\n",
    "        thisaxis.set_xlim([-2.5, 0.75])\n",
    "        thisaxis.plot(X_predict_input, y_predict_output,\n",
    "                     '^', markersize = 10)\n",
    "        thisaxis.plot(X_train, y_train, 'o')\n",
    "        thisaxis.set_xlabel('Input feature')\n",
    "        thisaxis.set_ylabel('Target value')\n",
    "        thisaxis.set_title('MLP regression\\nalpha={}, activation={})'\n",
    "                          .format(thisalpha, thisactivation))\n",
    "        plt.tight_layout()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Application to real-world dataset for classification"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "from sklearn.neural_network import MLPClassifier\n",
    "from sklearn.preprocessing import MinMaxScaler\n",
    "\n",
    "\n",
    "scaler = MinMaxScaler()\n",
    "\n",
    "X_train, X_test, y_train, y_test = train_test_split(X_cancer, y_cancer, random_state = 0)\n",
    "X_train_scaled = scaler.fit_transform(X_train)\n",
    "X_test_scaled = scaler.transform(X_test)\n",
    "\n",
    "clf = MLPClassifier(hidden_layer_sizes = [100, 100], alpha = 5.0,\n",
    "                   random_state = 0, solver='lbfgs').fit(X_train_scaled, y_train)\n",
    "\n",
    "print('Breast cancer dataset')\n",
    "print('Accuracy of NN classifier on training set: {:.2f}'\n",
    "     .format(clf.score(X_train_scaled, y_train)))\n",
    "print('Accuracy of NN classifier on test set: {:.2f}'\n",
    "     .format(clf.score(X_test_scaled, y_test)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "./addresses.csv\r\n",
      "./train.csv\r\n",
      "./Module 2.ipynb\r\n",
      "./Assignment 3.ipynb\r\n",
      "./Module 4.ipynb\r\n",
      "./Assignment 1.ipynb\r\n",
      "./test.csv\r\n",
      "./CommViolPredUnnormalizedData.txt\r\n",
      "./adspy_shared_utilities.py\r\n",
      "./Module 3.ipynb\r\n",
      "./fraud_data.csv\r\n",
      "./fruit_data_with_colors.txt\r\n",
      "./Assignment 4.ipynb\r\n",
      "./Assignment 2.ipynb\r\n",
      "./mushrooms.csv\r\n",
      "./Classifier Visualization.ipynb\r\n",
      "./latlons.csv\r\n",
      "./Module 1.ipynb\r\n"
     ]
    }
   ],
   "source": [
    "!find . -maxdepth 1 -not -type d"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "addresses.csv  adspy_temp.dot  polynomialreg1.png  train.csv\r\n"
     ]
    }
   ],
   "source": [
    "!ls readonly"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "cp: target ‘2.ipynb’ is not a directory\r\n"
     ]
    }
   ],
   "source": [
    "!cp ./Module 2.ipynb readonly/Module 2.ipynb"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.5.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
