{"cells":[{"metadata":{},"cell_type":"markdown","source":"# Kuzushiji Images (just for fun)\n\nWhile studying the dataset I was impressed by the drawings.\n\nI was already in love with japanese pictorial art, so I created this very simple kernel to extract the pages with no text and show one of them at random.\n\nI find some of them quite charming.\n"},{"metadata":{"_cell_guid":"79c7e3d0-c299-4dcb-8224-4455121ee9b0","_uuid":"d629ff2d2480ee46fbb7e2d37f6b5fab8052498a","trusted":true},"cell_type":"code","source":"import pandas as pd\nimport matplotlib.pyplot as plt\nimport matplotlib.image as mpimg\nimport numpy as np\n","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"train = pd.read_csv('../input/train.csv')","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"from matplotlib import font_manager as fm, rcParams\nimport math\n\ndef read_characters(line):\n    if type(line)==float and math.isnan(line):\n        return None\n    return line.split(' ')\n\ndef show_page(page, width=15, height=15):\n    im = mpimg.imread('../input/train_images/'+train.loc[page,'image_id']+'.jpg')\n    fig,ax = plt.subplots(1)\n    ax.imshow(im)\n    fig.set_figheight(height)\n    fig.set_figwidth(width)\n    plt.show()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"def find_images(train):\n    examples_with_images = train[train.apply(lambda x: isinstance(x.labels, float), axis=1)]\n    return examples_with_images\n        ","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"import random\n\nrandom.seed( 7 ) #Just to pick one of my favorites on this kernel\n\nimages_indexes = find_images(train).index\nchoice = random.choice(images_indexes)\nprint(\"Page index \"+str(choice))\nshow_page(choice, 25, 25)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"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.4","mimetype":"text/x-python","codemirror_mode":{"name":"ipython","version":3},"pygments_lexer":"ipython3","nbconvert_exporter":"python","file_extension":".py"}},"nbformat":4,"nbformat_minor":1}