{"metadata":{"kernelspec":{"name":"python3","display_name":"Python 3","language":"python"},"language_info":{"codemirror_mode":{"name":"ipython","version":3},"file_extension":".py","mimetype":"text/x-python","name":"python","nbconvert_exporter":"python","pygments_lexer":"ipython3","version":"3.11.13"},"kaggle":{"accelerator":"nvidiaTeslaT4","dataSources":[{"sourceId":101849,"databundleVersionId":13093295,"sourceType":"competition"},{"sourceId":13155043,"sourceType":"datasetVersion","datasetId":8043942},{"sourceId":13155057,"sourceType":"datasetVersion","datasetId":8083087},{"sourceId":13188699,"sourceType":"datasetVersion","datasetId":7947722},{"sourceId":253107285,"sourceType":"kernelVersion"},{"sourceId":255090856,"sourceType":"kernelVersion"}],"dockerImageVersionId":31090,"isInternetEnabled":false,"language":"python","sourceType":"notebook","isGpuEnabled":true}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"markdown","source":"This code reproduces the winning submission for the 2025 Ariel Data Challenge. However, the underlying library has not been cleaned up and is pretty much unreadable. If you're trying to learn from this, I recommend this notebook instead: https://www.kaggle.com/code/jeroencottaar/ariel2025-1st-place-bayesian-exoplanet-analysis","metadata":{"tags":[],"execution":{"iopub.status.busy":"2025-09-25T07:16:31.166462Z","iopub.execute_input":"2025-09-25T07:16:31.166656Z","iopub.status.idle":"2025-09-25T07:17:11.105273Z","shell.execute_reply.started":"2025-09-25T07:16:31.166639Z","shell.execute_reply":"2025-09-25T07:17:11.104214Z"}}},{"cell_type":"code","source":"# Load modules\nimport sys\nsys.path.append('/kaggle/input/my-ariel2-library')\nimport kaggle_support as kgs\nimport ariel_model\n\n# Load data (just the outline, not the actual sensor readings)\ntrain_data = kgs.load_all_train_data()\ntest_data = kgs.load_all_test_data()\nif len(test_data)==1:\n    # If not in submission, run on a few of the training data instead\n    data_to_infer = train_data[:20]\nelse:\n    data_to_infer = test_data\n\n# Load the pretrained model\nmodel=kgs.dill_load('/kaggle/input/my-ariel2-model/evaluate_model_Baseline__1099.pickle')[2]\n# Alternatively, we could train the model from scratch like this (but too slow for submission):\n# model = ariel_model.baseline_model()\n# model.train(train_data)\n# Note that results would not be 100% the same, since I trained the model in a different environment.\n\n# Some post-training changes\n# Use multiple transits when available\nmodel = ariel_model.MultiTransit(model=model)\nmodel.variance_fudge = 1.4 # Increase variance by a bit, since prediction error tends to correlate between transits\nmodel.state = 1\n# Allow some planets to fail sanity checks, but raise an error if more than 2\nmodel = ariel_model.SanityWrapper(model=model)\nmodel.run_in_parallel = True\nmodel.state = 1\nmodel.action = 'do_nothing'\nmodel.max_errors = 2\n# Increase accuracy of sigma estimation\nmodel.model.model.model.model.model_options.n_samples_sigma_est *= 2\n\n# Make predictions\ninferred_data = model.infer(data_to_infer)\n\n# Show score if not submitting\nif len(test_data)==1:\n    print(kgs.score_metric(inferred_data, data_to_infer))\n\n# Write CSV\nkgs.write_submission_csv(kgs.make_submission_dataframe(inferred_data))","metadata":{"tags":[],"trusted":true,"execution":{"iopub.status.busy":"2025-09-27T12:49:27.239212Z","iopub.execute_input":"2025-09-27T12:49:27.239446Z"}},"outputs":[],"execution_count":null},{"cell_type":"code","source":"","metadata":{"trusted":true},"outputs":[],"execution_count":null}]}