{"cells":[{"metadata":{"_uuid":"104203d2fe74b7bca2c12502aafab7e7581ca0a1","_execution_state":"idle","trusted":true},"cell_type":"code","source":"## Importing packages\n\n# This R environment comes with all of CRAN and many other helpful packages preinstalled.\n# You can see which packages are installed by checking out the kaggle/rstats docker image: \n# https://github.com/kaggle/docker-rstats\n\nlibrary(tidyverse) # metapackage with lots of helpful functions\n\n## Running code\n\n# In a notebook, you can run a single code cell by clicking in the cell and then hitting \n# the blue arrow to the left, or by clicking in the cell and pressing Shift+Enter. In a script, \n# you can run code by highlighting the code you want to run and then clicking the blue arrow\n# at the bottom of this window.\n\n## Reading in files\n\n# You can access files from datasets you've added to this kernel in the \"../input/\" directory.\n# You can see the files added to this kernel by running the code below. \n\nlist.files(path = \"../input\")\n\n## Saving data\n\n# If you save any files or images, these will be put in the \"output\" directory. You \n# can see the output directory by committing and running your kernel (using the \n# Commit & Run button) and then checking out the compiled version of your kernel.","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"05742dbb0cf1bd8d709bddd3ea3e7b91b9f6c8f2"},"cell_type":"markdown","source":"## Read the datasets"},{"metadata":{"trusted":true,"_uuid":"05703f86b72159994c20297b25575e70cba8d354"},"cell_type":"code","source":"df_class_descriptions = read.csv(\"../input/class-descriptions.csv\")\ndf_class_trainable = read.csv(\"../input/classes-trainable.csv\")\ndf_stage_1_attributes = read.csv(\"../input/stage_1_attributions.csv\")\ndf_stage_1_sample_submission = read.csv(\"../input/stage_1_sample_submission.csv\")\ndf_train_bounding_boxes = read.csv(\"../input/train_bounding_boxes.csv\")\ndf_train_human_labels = read.csv(\"../input/train_human_labels.csv\")\ndf_train_machine_labels = read.csv(\"../input/train_machine_labels.csv\")\n","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"f16dec4300260ece36e925ff7c56f8ef2b249f1e"},"cell_type":"code","source":"df_tuning_labels = read.csv('../input//tuning_labels.csv',header = FALSE)","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"3e028d248b612ac0a7ec10a0ea63ec0687032ba0"},"cell_type":"markdown","source":"## See the value of 5 rows of all datasets"},{"metadata":{"trusted":true,"_uuid":"8666093c554bbe5362283952e45c66fb9bc26981"},"cell_type":"code","source":"print(df_class_descriptions[0:5, ])\nprint(df_class_trainable[0:5, ])\nprint(df_stage_1_attributes[0:5, ])\nprint(df_stage_1_sample_submission[0:5, ])\nprint(df_train_bounding_boxes[0:5, ])\nprint(df_train_human_labels[0:5, ] )\nprint(df_train_machine_labels[0:5,])\nprint(df_tuning_labels[0:5, ] )","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"26363f6141177189798e7b6da4e6d692c230e507"},"cell_type":"code","source":"head(df_tuning_labels, 5) # Read first 5 rows","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"9e543f8ef7736943cc2b2fff5391ba407ba9b724"},"cell_type":"code","source":"head(df_tuning_labels$V1, 5) # Read first 5 rows of column V1","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"77ce986c714fb24df13051e233c83452035ad618"},"cell_type":"markdown","source":"## Shape of datasets"},{"metadata":{"trusted":true,"_uuid":"aa6a7ad81b48889577c7518a719e2e49d039b552"},"cell_type":"code","source":"# sprintf(\"Dimensions of df_class_descriptions: %s\\n\", dim(df_class_descriptions))\n# sprintf(\"Dimensions of df_class_trainable: %s\\n\", dim(df_class_trainable))\n# sprintf(\"Dimensions of df_stage_1_attributes: %s\\n\", dim(df_stage_1_attributes))\n# sprintf(\"Dimensions of df_stage_1_sample_submission: %s\\n\", dim(df_stage_1_sample_submission))\n# sprintf(\"Dimensions of df_train_bounding_boxes: %s\\n\", dim(df_train_bounding_boxes))\n# sprintf(\"Dimensions of df_train_human_labels: %s\\n\", dim(df_train_human_labels))\n# sprintf(\"Dimensions of df_train_machine_labels: %s\\n\", dim(df_train_machine_labels))\n# sprintf(\"Dimensions of df_tuning_labels: %s\\n\", dim(df_tuning_labels))\n","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"c6894103e8fa6abda28662a6e1e1c7fda4ec98de"},"cell_type":"code","source":" dim(df_class_descriptions)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"aefc54b229d48c0718a6cd06f7553b5a73b308db"},"cell_type":"code","source":"dim(df_class_trainable)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"557b44ba85bde9fcc166734b40890ae2083c1517"},"cell_type":"code","source":"dim(df_stage_1_attributes)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"998fe2fd23ec3163b52e9d75aa42798f694ff7ab"},"cell_type":"code","source":"dim(df_stage_1_sample_submission)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"29a149fabc072ad07ec1ba7d1f8a5fc3bd92e462"},"cell_type":"code","source":"dim(df_train_bounding_boxes)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"09745691234528c93b79bb753f9644c7a19e59ad"},"cell_type":"code","source":"dim(df_train_human_labels)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"89e5bb40c66a6426fbbe28d5e39e7a257a10ee45"},"cell_type":"code","source":"dim(df_train_machine_labels)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"936096ba8629e5357b734d342e496269db7d3fc1"},"cell_type":"code","source":"dim(df_tuning_labels)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"aca1034a56d130e8d349fab5189928a046e51f6f"},"cell_type":"code","source":"# lapply(df_tuning_labels, function(elt) elt[df_tuning_labels$V2])","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"1d7d502fa571b0c72ddcdd5b8c2de240dffe026f"},"cell_type":"code","source":"","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"737689573617d158d97480965aa56304921e06e5"},"cell_type":"code","source":"","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"62d479da91867edadf535f6e593c3f9d0f12a2b5"},"cell_type":"code","source":"","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"a7746fdc7e6774306cfcee90eeb6351cbf112ff2"},"cell_type":"code","source":"","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"4a38fcb01fc66d109f9d443892144d1b67d9311b"},"cell_type":"code","source":"","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"b11a1a7a57c8517f2d00b7af0d4d5d4763cc35a7"},"cell_type":"markdown","source":"## Test images"},{"metadata":{"trusted":true,"_uuid":"7d3a48c5a892138a080f2478486518328d028670","scrolled":true},"cell_type":"code","source":"library(tidyverse)\nlibrary(EBImage)\nlibrary(gridExtra)\nlibrary(RGraphics)\nlibrary(magrittr)\nlibrary(skimr)\nlibrary(imager)\nlibrary(jpeg)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"scrolled":true,"_uuid":"1c9c8dee3531e32c1e01319fa4d865d2c011859d"},"cell_type":"code","source":"#df_class_trainable$label_code[0:5]\nimgs = df_tuning_labels$V1[0:5]\nf = sprintf(\"../input/inclusive-images-challenge/stage_1_test_images/%s.jpg\", imgs)\n# print(f)\nprint(f)\n","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"486c6e593da694a47981d2fab05b80b3d438c5da"},"cell_type":"code","source":"for (img in imgs){\n#     print(img )\n    k <- paste(img, \".jpg\")\n    print(k)\n}","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"c18e91d46661a76818d8c77c2fbfb8222b1466d4"},"cell_type":"code","source":"# This R environment comes with all of CRAN preinstalled, as well as many other helpful packages\n# The environment is defined by the kaggle/rstats docker image: https://github.com/kaggle/docker-rstats\n# For example, here's several helpful packages to load in \n\nlibrary(ggplot2) # Data visualization\nlibrary(readr) # CSV file I/O, e.g. the read_csv function\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\nsystem(\"ls ../input\")\n\nlibrary(imager)\nFOLDER <- \"../input/stage_1_test_images\"\nnames <- list.files(FOLDER)\n\n# COPY TO LOCAL\nfname <- paste(FOLDER,\"/\",names[1], sep='')\nlocal_name = '2b364f547a395231796a593d.jpg'\nsystem(paste('cp',fname,local_name))\n\n# PLOT using IMAGER library\nim <- load.image(local_name)\nplot(im)","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"82881946f31824f175b9941c31edc175c7469e91"},"cell_type":"code","source":"\nfor (img in imgs){\n    fname <- paste(FOLDER,\"/\",names[1], sep='')\n    k <- paste(img, \".jpg\")\n    local_name = k \n    system(paste('cp',fname,local_name))\n\n    # PLOT using IMAGER library\n    im <- load.image(local_name)\n    plot(im)\n}","execution_count":null,"outputs":[]},{"metadata":{"trusted":true,"_uuid":"0624783352c3753c4cf875b0c23a6c52c59106cb"},"cell_type":"code","source":"","execution_count":null,"outputs":[]}],"metadata":{"kernelspec":{"display_name":"R","language":"R","name":"ir"},"language_info":{"mimetype":"text/x-r-source","name":"R","pygments_lexer":"r","version":"3.4.2","file_extension":".r","codemirror_mode":"r"}},"nbformat":4,"nbformat_minor":1}