|
| 1 | +{ |
| 2 | + "nbformat": 4, |
| 3 | + "nbformat_minor": 0, |
| 4 | + "metadata": { |
| 5 | + "colab": { |
| 6 | + "name": "m6_competition_entry.ipynb", |
| 7 | + "provenance": [], |
| 8 | + "authorship_tag": "ABX9TyNGzwgumNFE0UrfT87aFfBM", |
| 9 | + "include_colab_link": true |
| 10 | + }, |
| 11 | + "kernelspec": { |
| 12 | + "name": "python3", |
| 13 | + "display_name": "Python 3" |
| 14 | + }, |
| 15 | + "language_info": { |
| 16 | + "name": "python" |
| 17 | + } |
| 18 | + }, |
| 19 | + "cells": [ |
| 20 | + { |
| 21 | + "cell_type": "markdown", |
| 22 | + "metadata": { |
| 23 | + "id": "view-in-github", |
| 24 | + "colab_type": "text" |
| 25 | + }, |
| 26 | + "source": [ |
| 27 | + "<a href=\"https://colab.research.google.com/github/microprediction/precise/blob/main/examples_m6/m6_competition_entry.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>" |
| 28 | + ] |
| 29 | + }, |
| 30 | + { |
| 31 | + "cell_type": "code", |
| 32 | + "execution_count": null, |
| 33 | + "metadata": { |
| 34 | + "id": "U6Mky28wX5y8" |
| 35 | + }, |
| 36 | + "outputs": [], |
| 37 | + "source": [ |
| 38 | + "!pip install git+https://github.com/microprediction/precise.git" |
| 39 | + ] |
| 40 | + }, |
| 41 | + { |
| 42 | + "cell_type": "markdown", |
| 43 | + "source": [ |
| 44 | + "## Entering M6 using the precise package\n", |
| 45 | + "The precise package includes [csv examples](https://github.com/microprediction/precise/tree/main/examples_m6/full) of M6 competition entries. This notebook explains how they are created, but you may not be able to use the same data API from Google Colab (try it from your own machine instead). \n" |
| 46 | + ], |
| 47 | + "metadata": { |
| 48 | + "id": "fY3DQOlwX-MU" |
| 49 | + } |
| 50 | + }, |
| 51 | + { |
| 52 | + "cell_type": "markdown", |
| 53 | + "source": [ |
| 54 | + "## The Lazy way\n", |
| 55 | + "There's a script to generate M6 entries using a random choice of methods" |
| 56 | + ], |
| 57 | + "metadata": { |
| 58 | + "id": "GnbsOTDna8YX" |
| 59 | + } |
| 60 | + }, |
| 61 | + { |
| 62 | + "cell_type": "code", |
| 63 | + "source": [ |
| 64 | + "from precise.skatertools.m6.competition import m6_competition_entry\n", |
| 65 | + "random_entry = m6_competition_entry(verbose=False)" |
| 66 | + ], |
| 67 | + "metadata": { |
| 68 | + "id": "9zM9q2CkbEU4" |
| 69 | + }, |
| 70 | + "execution_count": null, |
| 71 | + "outputs": [] |
| 72 | + }, |
| 73 | + { |
| 74 | + "cell_type": "markdown", |
| 75 | + "source": [ |
| 76 | + "(yeah it will fail to get the data if run on Colab)" |
| 77 | + ], |
| 78 | + "metadata": { |
| 79 | + "id": "3Itnn0nccZbY" |
| 80 | + } |
| 81 | + }, |
| 82 | + { |
| 83 | + "cell_type": "markdown", |
| 84 | + "source": [ |
| 85 | + "## Parameters to mess with\n", |
| 86 | + "\n", |
| 87 | + " interval - sampling interval to use for cov estimation\n", |
| 88 | + " n_obs - number of time points to use in cov estimation (max 60 if interval='m')\n", |
| 89 | + " n_dim - Set at 100 for actual contest, but lower to test\n", |
| 90 | + " port - A portfolio creator (see /portfolioutil )\n", |
| 91 | + " f - A cov skater\n", |
| 92 | + " extra_shrink - If True, will perform additional shrinkage over and above the skater or portfolio method using\n", |
| 93 | + " phi - (Additional) Ridge parameter, suggest (1,1.5)\n", |
| 94 | + " lmbd - (Additional) Shrinkage parameter, suggest (0,0.5)\n" |
| 95 | + ], |
| 96 | + "metadata": { |
| 97 | + "id": "3ZdNt-Hcco6e" |
| 98 | + } |
| 99 | + }, |
| 100 | + { |
| 101 | + "cell_type": "markdown", |
| 102 | + "source": [ |
| 103 | + "## Change the method of estimating cov\n", |
| 104 | + "Pick a \"skater\" from somewhere in [precise/skaters/covariance](https://github.com/microprediction/precise/tree/main/precise/skaters/covariance)" |
| 105 | + ], |
| 106 | + "metadata": { |
| 107 | + "id": "pRZVehHBc0yu" |
| 108 | + } |
| 109 | + }, |
| 110 | + { |
| 111 | + "cell_type": "code", |
| 112 | + "source": [ |
| 113 | + "from precise.skaters.covariance.bufhuber import buf_huber_pcov_d0_a05_b2_n100 as f \n", |
| 114 | + "from precise.skaters.covariance.ewapm import ewa_pm_emp_scov_r01_n100_t0 as f \n", |
| 115 | + "entry = m6_competition_entry(f=f, verbose=False)" |
| 116 | + ], |
| 117 | + "metadata": { |
| 118 | + "id": "4Iz6A3WSc3AF" |
| 119 | + }, |
| 120 | + "execution_count": 5, |
| 121 | + "outputs": [] |
| 122 | + }, |
| 123 | + { |
| 124 | + "cell_type": "markdown", |
| 125 | + "source": [ |
| 126 | + "## Change the portfolio method\n", |
| 127 | + "Pick a \"port\" function from somewhere in [precise/skaters/portfolioutil](https://github.com/microprediction/precise/tree/main/precise/skaters/portfolioutil)" |
| 128 | + ], |
| 129 | + "metadata": { |
| 130 | + "id": "CICRLcxsdccF" |
| 131 | + } |
| 132 | + }, |
| 133 | + { |
| 134 | + "cell_type": "code", |
| 135 | + "source": [ |
| 136 | + "from precise.skaters.portfolioutil.weak import prc_weak_port as port\n", |
| 137 | + "entry = m6_competition_entry(f=f, port=port, verbose=False)" |
| 138 | + ], |
| 139 | + "metadata": { |
| 140 | + "id": "KgvOIh2ddoa2" |
| 141 | + }, |
| 142 | + "execution_count": null, |
| 143 | + "outputs": [] |
| 144 | + } |
| 145 | + ] |
| 146 | +} |
0 commit comments