{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import os\n", "from pathlib import Path\n", "from typing import Optional, Union\n", "\n", "import pandas as pd\n", "from dotenv import load_dotenv\n", "\n", "\n", "load_dotenv()\n", "\n", "from pathlib import Path\n", "from typing import Optional\n", "\n", "import pandas as pd\n", "\n", "\n", "def set_env_if_kaggle_environ():\n", " if 'KAGGLE_DATA_PROXY_TOKEN' in os.environ:\n", " os.environ['DATA_PATH'] = '/kaggle/input/feedback-prize-english-language-learning/'\n", "\n", "\n", "class ConstantPredictorSolution():\n", " def __init__(self, config: Optional[dict] = None):\n", " super().__init__()\n", "\n", " def fit(self, X: pd.DataFrame, y: pd.DataFrame):\n", " pass\n", "\n", " def predict(self, X: pd.DataFrame) -> pd.DataFrame:\n", " submission_df = []\n", "\n", " for _, row in X.iterrows():\n", " submission_df.append({\n", " 'text_id': row.text_id,\n", " 'cohesion': 3.0,\n", " 'syntax': 3.0,\n", " 'vocabulary': 3.0,\n", " 'phraseology': 3.0,\n", " 'grammar': 3.0,\n", " 'conventions': 3.0\n", " })\n", "\n", " return pd.DataFrame(submission_df)\n", "\n", " def save(self, directory: Union[str,Path]):\n", " pass\n", "\n", " def load(self, directory: Union[str, Path]):\n", " pass\n", "\n", "\n", "def main():\n", " set_env_if_kaggle_environ()\n", "\n", " test_df_path = Path(os.environ['DATA_PATH']) / 'test.csv'\n", " if not test_df_path.is_file():\n", " raise OSError(f\"File not found: {test_df_path.absolute()}\")\n", "\n", " predictor = ConstantPredictorSolution()\n", "\n", " test_df = pd.read_csv(test_df_path)\n", " submission_df = predictor.predict(test_df)\n", "\n", " submission_df.to_csv(\"submission.csv\", index=False)\n", "\n", "\n", "if __name__ == '__main__':\n", " main()" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3.10.6 ('essay')", "language": "python", "name": "python3" }, "language_info": { "name": "python", "version": "3.10.6" }, "orig_nbformat": 4, "vscode": { "interpreter": { "hash": "d78f2c2de95f7b748174daf85b42b570c91869441d974f177c5a7efccbbdf121" } } }, "nbformat": 4, "nbformat_minor": 2 }