{"cells":[{"metadata":{},"cell_type":"markdown","source":"# What's this\n- 主にチーム内での情報共有を目的とした文書ですがせっかくなのでpublicにしています\n- このNotebookは本コンペの概要と、提供データの各カラムの説明をまとめていきます\n"},{"metadata":{},"cell_type":"markdown","source":"# Riiid! Answer Correctness Prediction\n- 学生が問題を問いた時の情報を元に、学生の理解が足りない分野を推定します\n- 教育課題へのAIからのアプローチというテーマになります\n    > 受賞チームは、2021年2月に開催されるAI教育に関するAAAI-2021ワークショップ（AIを使用したCOVID後の教育を想像する）でモデルを発表するよう招待されます。すべてのコンテスト参加者は、ワークショップに記事を提出できます。\n- とのこと\n- submitファイルをuploadする形式ではなくkaggleの時系列データapiを利用したコンペ"},{"metadata":{},"cell_type":"markdown","source":"# Evaluation\n- AUCによる"},{"metadata":{},"cell_type":"markdown","source":"# Files"},{"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\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 read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\nimport os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))\n\n# You can write up to 5GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\" \n# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"- データが巨大すぎてpandasのread_csvするとメモリ不足になるためdatatableを利用"},{"metadata":{"trusted":true},"cell_type":"code","source":"!pip install ../input/python-datatable/datatable-0.11.0-cp37-cp37m-manylinux2010_x86_64.whl > /dev/null","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"import sklearn.datasets as datasets\nimport pandas as pd\n\nimport matplotlib.pyplot as plt\n\nimport seaborn as sns\nimport datatable as dt\n","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"pd.options.display.float_format = '{:.20g}'.format","execution_count":null,"outputs":[]},{"metadata":{"_uuid":"d629ff2d2480ee46fbb7e2d37f6b5fab8052498a","_cell_guid":"79c7e3d0-c299-4dcb-8224-4455121ee9b0","trusted":true},"cell_type":"code","source":"\ndata_types = {\n    'row_id': 'int32',\n    'timestamp': 'int64',\n    'user_id': 'int64',\n    'content_id': 'int16',\n    'content_type_id': 'int8',\n    'task_container_id': 'int16',\n    'user_answer': 'int8',\n    'answered_correctly': 'int8',\n    'prior_question_elapsed_time': 'float32',\n    'prior_question_had_explanation': 'boolean'\n}\n\ntrain_df = dt.fread('../input/riiid-test-answer-prediction/train.csv').to_pandas()\n\n# train_df = train_df.sample(len(train_df)//5,random_state=42)\nfor column, d_type in data_types.items():\n    train_df[column] = train_df[column].astype(d_type) ","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"# train.csv"},{"metadata":{"trusted":true},"cell_type":"code","source":"train_df.describe()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"train_df.head()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"## train.csv\n- row_id: (int64) ID code for the row.\n\n- timestamp: (int64) the time in milliseconds between this user interaction and the first event completion from that user.\n  - そのユーザーの直前のアクションからの経過時間(ミリ秒)\n\n- user_id: (int32) ID code for the user.\n\n- content_id: (int16) ID code for the user interaction\n\n- content_type_id: (int8) 0 if the event was a question being posed to the user, 1 if the event was the user watching a lecture.\n  - イベントがユーザーに提示された質問である場合は0、イベントが講義を見ているユーザーである場合は1。\n\n- task_container_id: (int16) Id code for the batch of questions or lectures. For example, a user might see three questions in a row before seeing the explanations for any of them. Those three would all share a task_container_id.\n  - 質問または講義のバッチのIDコード。 たとえば、ユーザーは、いずれかの説明を表示する前に、3つの質問を連続して表示する場合があります。 これら3つはすべてtask_container_idを共有します。\n  \n- user_answer: (int8) the user's answer to the question, if any. Read -1 as null, for lectures.\n  - 質問に対するユーザーの回答（ある場合）。 講義の場合は、-1をnullとして読み取ります。\n\n- answered_correctly: (int8) if the user responded correctly. Read -1 as null, for lectures.\n  - ユーザーが正しく応答した場合。 講義の場合は、-1をnullとして読み取ります。\n    - おそらく正答 1 誤答 0\n\n- prior_question_elapsed_time: (float32) The average time in milliseconds it took a user to answer each question in the previous question bundle, ignoring any lectures in between. Is null for a user's first question bundle or lecture. Note that the time is the average time a user took to solve each question in the previous bundle.\n  - ユーザーが前の質問バンドルの各質問に回答するのにかかった平均時間（ミリ秒単位）。その間の講義は無視されます。 ユーザーの最初の質問バンドルまたは講義ではnullです。 時間は、ユーザーが前のバンドルの各質問を解決するのにかかった平均時間であることに注意してください。\n\n- prior_question_had_explanation: (bool) Whether or not the user saw an explanation and the correct response(s) after answering the previous question bundle, ignoring any lectures in between. The value is shared across a single question bundle, and is null for a user's first question bundle or lecture. Typically the first several questions a user sees were part of an onboarding diagnostic test where they did not get any feedback.\n  - ユーザーが前の質問バンドルに回答した後、その間の講義を無視して、説明と正しい回答を見たかどうか。 値は単一の質問バンドル間で共有され、ユーザーの最初の質問バンドルまたは講義ではnullになります。 通常、ユーザーに表示される最初のいくつかの質問は、フィードバックが得られなかったオンボーディング診断テストの一部でした。\n\n"},{"metadata":{"trusted":true},"cell_type":"code","source":"questions_df = pd.read_csv('../input/riiid-test-answer-prediction/questions.csv')\nlectures_df = pd.read_csv('../input/riiid-test-answer-prediction/lectures.csv')\ntest_df = pd.read_csv('../input/riiid-test-answer-prediction/example_test.csv')","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"# questions.csv"},{"metadata":{"trusted":true},"cell_type":"code","source":"questions_df.describe()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"questions_df.head()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"## questions.csv\n- question_id: foreign key for the train/test content_id column, when the content type is question (0).\n  - コンテンツタイプが質問（0）の場合、train / testcontent_id列の外部キー。\n\n- bundle_id: code for which questions are served together.\n  - どの質問と同時送られたか\n\n- correct_answer: the answer to the question. Can be compared with the train user_answer column to check if the user was right.\n  - 質問への答え。 train user_answer列と比較して、ユーザーが正しいかどうかを確認できます。\n\n- part: the relevant section of the TOEIC test.\n  - TOEICテストの関連セクション。\n\n- tags: one or more detailed tag codes for the question. The meaning of the tags will not be provided, but these codes are sufficient for clustering the questions together.\n  - 質問の1つ以上の詳細なタグコード。 タグの意味は提供されませんが、これらのコードは質問をまとめるのに十分です。"},{"metadata":{},"cell_type":"markdown","source":"# lectures.csv"},{"metadata":{"trusted":true},"cell_type":"code","source":"lectures_df.describe()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"lectures_df.head()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"## lectures.csv\n- lecture_id: foreign key for the train/test content_id column, when the content type is lecture (1).\n  - コンテンツタイプが講義（1）の場合、train / testcontent_id列の外部キー。\n- part: top level category code for the lecture. \n  - 講義のトップレベルのカテゴリコード。\n- tag: one tag codes for the lecture. The meaning of the tags will not be provided, but these codes are sufficient for clustering the lectures together.\n  - 講義用の1つのタグコード。 タグの意味は提供されませんが、これらのコードは講義をまとめるのに十分です\n\n- type_of: brief description of the core purpose of the lecture\n  - 講義の主な目的の簡単な説明"},{"metadata":{},"cell_type":"markdown","source":"# example_test_rows.csv"},{"metadata":{"trusted":true},"cell_type":"code","source":"test_df.describe()","execution_count":null,"outputs":[]},{"metadata":{"trusted":true},"cell_type":"code","source":"test_df.head()","execution_count":null,"outputs":[]},{"metadata":{},"cell_type":"markdown","source":"# example_test_rows.csv\n- Three sample groups of the test set data as it will be delivered by the time-series API. The format is largely the same as train.csv. There are two different columns that mirror what information the AI tutor actually has available at any given time, but with the user interactions grouped together for the sake of API performance rather than strictly showing information for a single user at a time. Some users will appear in the hidden test set that have NOT been presented in the train set, emulating the challenge of quickly adapting to modeling new arrivals to a website.\n  - 時系列APIによって配信されるテストセットデータの3つのサンプルグループ。 形式はtrain.csvとほぼ同じです。 AIチューターがいつでも実際に利用できる情報を反映する、2つの異なる列がありますが、一度に1人のユーザーの情報を厳密に表示するのではなく、APIパフォーマンスのためにユーザーインタラクションをグループ化します。 一部のユーザーは、trainセットに表示されていない非表示のテストセットに表示され、Webサイトへの新着のモデリングにすばやく適応するという課題をエミュレートします。\n\n- prior_group_responses (string) provides all of the user_answer entries for previous group in a string representation of a list in the first row of the group. All other rows in each group are null. If you are using Python, you will likely want to call eval on the non-null rows. Some rows may be null, or empty lists.\n  - グループの最初の行のリストの文字列表現で、前のグループのすべてのuser_answerエントリを提供します。 各グループの他のすべての行はnullです。 Pythonを使用している場合は、null以外の行でevalを呼び出すことをお勧めします。 一部の行はnullまたは空のリストである可能性があります。\n\n- prior_group_answers_correct (string) provides all the answered_correctly field for previous group, with the same format and caveats as prior_group_responses. Some rows may be null, or empty lists.\n  - 以前のグループのすべてのanswered_correctlyフィールドを、prior_group_responsesと同じ形式と警告で提供します。 一部の行はnullまたは空のリストである可能性があります。"},{"metadata":{},"cell_type":"markdown","source":"#  "}],"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat":4,"nbformat_minor":4}