{"cells":[{"metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","trusted":true},"cell_type":"code","source":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load in \n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\n# Input data files are available in the \"../input/\" directory.\n# For example, running this (by clicking run or pressing Shift+Enter) will list the files in the input directory\n\nimport os\nprint(os.listdir(\"../input\"))\n\n# Any results you write to the current directory are saved as output.","execution_count":null,"outputs":[]},{"metadata":{"_cell_guid":"79c7e3d0-c299-4dcb-8224-4455121ee9b0","_uuid":"d629ff2d2480ee46fbb7e2d37f6b5fab8052498a","trusted":true},"cell_type":"code","source":"train = pd.read_csv('../input/train.csv')\nprint(f\"Train: {len(train)}\")\ntest = pd.read_csv('../input/test.csv')\nprint(f\"Test: {len(test)}\")","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"f71918152aeb4baae4bc59dd46adf731a8462815"},"cell_type":"code","source":"img = train[1:2].drop('label',axis=1).values[0]","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"3e5110014f6f83e28159c6fbbdf3ef1d6c0cb07c"},"cell_type":"code","source":"import matplotlib.pyplot as plt\nimport matplotlib.image as mpimg\nplt.imshow(np.array([[img[x] for x in range(i-28,i)] for i in range(28,785,28)]))","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"5037ba8f875c54a0cda33add82a8ad5d9eedb775"},"cell_type":"code","source":"plt.imshow(train[2:3].drop('label',axis=1).values[0].reshape(28,28),cmap=\"terrain\")","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"6fd27354517be240cec9ffc27d38b96403b03feb"},"cell_type":"code","source":"from sklearn.model_selection import train_test_split\ny = train.label.values\nX = train.drop(\"label\",axis=1).values\nX_train, X_val, y_train, y_val = train_test_split(X, y, test_size=0.4, random_state=0)\nfig1, ax1 = plt.subplots(1,15, figsize=(15,10))\nfor i in range(15):\n    ax1[i].imshow(X_train[i].reshape((28,28)), cmap=\"autumn_r\")\n    ax1[i].axis('off')\n    ax1[i].set_title(y_train[i])","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"4ee60f811bbdb388b5546fb1a143307be0d6657f"},"cell_type":"code","source":"import seaborn as sns\nprint(train.label.value_counts())\nsns.countplot(train.label,palette=\"RdBu\")","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"2f91b1a5a3342c96af219c14a3618cd6bc8f93bf"},"cell_type":"code","source":"","execution_count":null,"outputs":[]}],"metadata":{"kernelspec":{"display_name":"Python 3","language":"python","name":"python3"},"language_info":{"name":"python","version":"3.6.6","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"}},"nbformat":4,"nbformat_minor":1}