FOODCH
Getting Started Notebook for FOODCH
A getting started notebook with random submission for the challenge.
Getting Started Notebook for FOODCH Challenge¶
This notebook creates a random prediction for the test data and takes you through the workflow of how to download data and submit directly via the notebook.
Note: Create a copy of the notebook and use the copy for submission. Go to File > Save a Copy in Drive to create a new copy
In [ ]:
!pip install aicrowd-cli
%load_ext aicrowd.magic
Login to AIcrowd ㊗¶
In [ ]:
%aicrowd login
Download Dataset and Unzip¶
We will create a folder name data
and download and unzip the files there.
In [ ]:
# Downloading the Dataset
!rm -rf data
!mkdir data
%aicrowd ds dl -c foodch -o data
In [ ]:
!unzip data/train_images -d data/train_images > /dev/null
!unzip data/test_images -d data/test_images > /dev/null
Generating Random Submission ⚙️¶
Making a submission with random predictions. We will randomly select a class prensent in the training set for each image in test set.
In [ ]:
# Imporitng libraries
import pandas as pd
import os
import random
random.seed(42)
In [ ]:
# Testing images directory
test_images_dir = os.path.join("data", "test_images", "test_images")
test_name_ids = os.listdir(test_images_dir)
In [ ]:
# Making a list containing all unique classes in the training set
# Reading the training dataset
training_dataframe = pd.read_csv(os.path.join("data", "train.csv"))
# Classes column
classes = training_dataframe['ClassName'].unique()
# Creating a list containing random classes of size equal of no. of samples in test data
random_test_predictions = [random.choice(classes) for i in range(len(test_name_ids))]
In [ ]:
# Converting the list to dataframe
predictions_df = pd.DataFrame(random_test_predictions, columns=["ClassName"])
predictions_df
Out[ ]:
In [ ]:
# Saving the dataframe to csv
predictions_df.to_csv("submission.csv", index=False)
Submitting the predictions to AIcrowd¶
In [ ]:
# Submitting the Predictions
!aicrowd submission create -c foodch -f submission.csv
In [ ]:
Content
Comments
You must login before you can post a comment.