How to hold a competition at Coda Lab

CodaLab.org is a competition holding platform (also). You can also build your own server with Open source published on github.

A memorandum of know-how for holding competitions at CodaLab.org.

Click here for documentation:

template

For reference, Iris example challenge. Download the bundle from here (click "DOWNLOAD THE BUNDLE OF THE CHALLENGE" on the "Learn the Details" tab) and rewrite the yaml file to create a new one. Even if you write it appropriately, you can modify it later on the web.

Bundle is zipped and uploaded, but not if the folder is compressed. If you do not make only the file appear when you unzip the zip, an error will occur.

Reference material

-Help list

Competition to submit code

Iris example challenge is a code submission competition, so it's hard to tell what's going on. The following is an outline.

submission

--The user submits the zip. Zipped version of the following files without a directory

metadata specifies code execution command.

metadata


command: python $program/cat.py $input $output
description: Compute scores for the competition

File to be submitted together. Anything is OK.

submission.txt


0
1
0
....

The file to be executed. Read the file to be submitted together from run_dir, execute it, and Write the resulting file to output_dir (which will be called later by the evaluator)

cat.py


#!/usr/bin/env python

import os
from sys import argv
from shutil import copyfile

if __name__=="__main__":

    if len(argv)==1:
        input_dir  = os.path.join('..', 'input')
        output_dir = os.path.join('..', 'output')
    else:
        input_dir  = argv[1]
        output_dir = argv[2]

    run_dir = os.path.abspath(".")

    copyfile(os.path.join(run_dir, 'program', 'submission.txt'),
             os.path.join(output_dir, 'submission.txt'))

In the above sample, the submitted file is simply copied to output_dir.

In the case of a code submission competition, the script and the trained model can be submitted together. In that case, it is necessary to read the test data (private) in input_dir.

Evaluation

--The organizer uploads the zip as a scoring program. Zipped version of the following files without a directory

metadata specifies code execution command.

metadata


command: python $program/evaluate.py $input $output
description: Compute scores for the competition

The file to be executed.

evaluate.py


#!/usr/bin/env python

import os
from sys import argv
import numpy as np

if __name__=="__main__":

    if len(argv)==1:
        input_dir  = os.path.join('..', 'input')
        output_dir = os.path.join('..', 'output')
    else:
        input_dir  = argv[1]
        output_dir = argv[2]

    y_submit_file = os.path.join(input_dir, 'res', 'submission.txt')
    y_ref_file = os.path.join(input_dir, 'ref', 'test_labels.csv')

    load_y_ref = np.loadtxt(y_ref_file)
    load_y_submission = np.loadtxt(y_submit_file)

    score = np.abs(load_y_ref - load_y_submission).sum() / float(load_y_ref.size)
    print("score: %.2f\n" % score)

    score_file = open(os.path.join(output_dir, 'scores.txt'), 'w')
    score_file.write("score: %.2f\n" % score)

    score_file.close()

The operation of the above sample.

--First, the user's code is executed (prediction step), where the result is written to output_dir (as described above). --The result is copied to input_dir / res of evaluation (scoring step) (this is confusing) --True labels test_labels.csv have been uploaded to input_dir / ref --Compare it and save the result in output_dir as "scores.txt" (fixed file name)

scores.txt


score: 0.98

This result file is displayed on the leader board. The keyword "score:" is specified in the yaml file (or in the web GUI).

Caution

Currently, python and module libraries are older versions (python is 2), so code that uses the latest modules will fail.

python module 2017/02/14


Python version: 2.7.10 |Anaconda 2.4.0 (64-bit)| (default, Oct 19 2015, 18:04:42) 
numpy==1.10.1
scikit-learn==0.16.1
scipy==0.16.0

I don't know if it can be used for anything other than python. Since the server seems to be windows (according to the documentation), it is also possible to upload a compiled binary file. If you want to use the latest python module, other scripts are OK, etc., it is better to build your own server.

Competition to submit only the result

Just check "Results Scoring Only" in the web GUI.

Since the user's submission is saved directly in the evaluation input_dir / res, the evaluation can be done simply by reading it, reading the true value of input_dir / ref, evaluating it, and writing it to output_dir / scores.txt.

Note: Even if there is only one submission file, you cannot submit it unless you zip it into a zip file.

Recommended Posts

How to hold a competition at Coda Lab
I read "How to make a hacking lab"
How to hold a hands-on seminar using Jupyter using docker
How to call a function
How to hack a terminal
How to run a Python file at a Windows 10 command prompt
How to shuffle a part of a Python list (at random.shuffle)
How to make a Japanese-English translation
How to write a Python class
How to put a symbolic link
How to make a slack bot
How to create a Conda package
How to make a crawler --Advanced
How to make a recursive function
How to create a virtual bridge
How to make a deadman's switch
How to create a Dockerfile (basic)
[Blender] How to make a Blender plugin
How to delete a Docker container
How to make a crawler --Basic
How to create a config file
How to specify a .py file to load at startup in IPython 0.13
How to create a clone from Github
How to split and save a DataFrame
How to build a sphinx translation environment
How to create a git clone folder
Qiita (1) How to write a code name
How to add a package with PyCharm
[Python] How to make a class iterable
How to draw a graph using Matplotlib
[Python] How to convert a 2D list to a 1D list
[Colab] How to copy a huge dataset
[Python] How to invert a character string
How to install a package using a repository
[Ubuntu] How to execute a shell script
How to get a stacktrace in python
How to put a line number at the beginning of a CSV file
How to create a repository from media
How to make a Backtrader custom indicator
How to choose a Seaborn color palette
How to test on a Django-authenticated page
How to make a Pelican site map
How to run a Maya Python script
How to put a lot of pipelines together and put them away at once
How to make a dialogue system dedicated to beginners
How to read a CSV file with Python 2/3
How to disguise a ZIP file as a PNG file
How to create large files at high speed
A simple example of how to use ArgumentParser
How to save all Instagram photos at once
How to send a message to LINE with curl
How to create a Python virtual environment (venv)
How to code a drone using image recognition
How to clear tuples in a list (Python)
How to draw a 2-axis graph with pyplot
How to embed a variable in a python string
How to create a function object from a string
How to draw a 3D graph before optimization
How to develop a cart app with Django
How to create a JSON file in Python
How to make a dictionary with a hierarchical structure.