|
36 | 36 | {
|
37 | 37 | "cell_type": "code",
|
38 | 38 | "execution_count": null,
|
39 |
| - "metadata": { |
40 |
| - "collapsed": true |
41 |
| - }, |
| 39 | + "metadata": {}, |
42 | 40 | "outputs": [],
|
43 | 41 | "source": [
|
44 | 42 | "# Import libraries necessary for this project\n",
|
|
56 | 54 | "try:\n",
|
57 | 55 | " data = pd.read_csv(\"customers.csv\")\n",
|
58 | 56 | " data.drop(['Region', 'Channel'], axis = 1, inplace = True)\n",
|
59 |
| - " print \"Wholesale customers dataset has {} samples with {} features each.\".format(*data.shape)\n", |
| 57 | + " print(\"Wholesale customers dataset has {} samples with {} features each.\".format(*data.shape))\n", |
60 | 58 | "except:\n",
|
61 |
| - " print \"Dataset could not be loaded. Is the dataset missing?\"" |
| 59 | + " print(\"Dataset could not be loaded. Is the dataset missing?\")" |
62 | 60 | ]
|
63 | 61 | },
|
64 | 62 | {
|
|
104 | 102 | "\n",
|
105 | 103 | "# Create a DataFrame of the chosen samples\n",
|
106 | 104 | "samples = pd.DataFrame(data.loc[indices], columns = data.keys()).reset_index(drop = True)\n",
|
107 |
| - "print \"Chosen samples of wholesale customers dataset:\"\n", |
| 105 | + "print(\"Chosen samples of wholesale customers dataset:\")\n", |
108 | 106 | "display(samples)"
|
109 | 107 | ]
|
110 | 108 | },
|
|
330 | 328 | " step = None\n",
|
331 | 329 | " \n",
|
332 | 330 | " # Display the outliers\n",
|
333 |
| - " print \"Data points considered outliers for the feature '{}':\".format(feature)\n", |
| 331 | + " print(\"Data points considered outliers for the feature '{}':\".format(feature))\n", |
334 | 332 | " display(log_data[~((log_data[feature] >= Q1 - step) & (log_data[feature] <= Q3 + step))])\n",
|
335 | 333 | " \n",
|
336 | 334 | "# OPTIONAL: Select the indices for data points you wish to remove\n",
|
|
704 | 702 | "source": [
|
705 | 703 | "# Display the predictions\n",
|
706 | 704 | "for i, pred in enumerate(sample_preds):\n",
|
707 |
| - " print \"Sample point\", i, \"predicted to be in Cluster\", pred" |
| 705 | + " print(\"Sample point\", i, \"predicted to be in Cluster\", pred)" |
708 | 706 | ]
|
709 | 707 | },
|
710 | 708 | {
|
|
820 | 818 | ],
|
821 | 819 | "metadata": {
|
822 | 820 | "kernelspec": {
|
823 |
| - "display_name": "Python 2", |
| 821 | + "display_name": "Python 3", |
824 | 822 | "language": "python",
|
825 |
| - "name": "python2" |
| 823 | + "name": "python3" |
826 | 824 | },
|
827 | 825 | "language_info": {
|
828 | 826 | "codemirror_mode": {
|
829 | 827 | "name": "ipython",
|
830 |
| - "version": 2 |
| 828 | + "version": 3 |
831 | 829 | },
|
832 | 830 | "file_extension": ".py",
|
833 | 831 | "mimetype": "text/x-python",
|
834 | 832 | "name": "python",
|
835 | 833 | "nbconvert_exporter": "python",
|
836 |
| - "pygments_lexer": "ipython2", |
837 |
| - "version": "2.7.12" |
| 834 | + "pygments_lexer": "ipython3", |
| 835 | + "version": "3.6.2" |
838 | 836 | }
|
839 | 837 | },
|
840 | 838 | "nbformat": 4,
|
|
0 commit comments