Skip to content

Commit

Permalink
Merge pull request #118 from crowdcent/bugfix/numerframe-meta-property
Browse files Browse the repository at this point in the history
Bugfix/numerframe meta property
  • Loading branch information
crowdcent authored Nov 18, 2022
2 parents e758bfb + 6274d98 commit 856b51e
Show file tree
Hide file tree
Showing 22 changed files with 3,574 additions and 1,630 deletions.
85 changes: 38 additions & 47 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,19 +141,13 @@ downloader = NumeraiClassicDownloader("data")
downloader.download_inference_data("current_round")

# --- 2. Initialize NumerFrame ---
metadata = {"version": 4,
"joblib_model_name": "test",
"joblib_model_path": "test_assets/joblib_v2_example_model.joblib",
"numerai_model_name": "test_model1",
"key_path": "test_assets/test_credentials.json"}
dataf = create_numerframe(file_path="data/current_round/live.parquet",
metadata=metadata)
dataf = create_numerframe(file_path="data/current_round/live.parquet")

# --- 3. Define and run pipeline ---
models = [SingleModel(dataf.meta.joblib_model_path,
model_name=dataf.meta.joblib_model_name)]
models = [SingleModel("test_assets/joblib_v2_example_model.joblib",
model_name="test")]
# No preprocessing and 0.5 feature neutralization
postprocessors = [FeatureNeutralizer(pred_name=f"prediction_{dataf.meta.joblib_model_name}",
postprocessors = [FeatureNeutralizer(pred_name=f"prediction_test",
proportion=0.5)]
pipeline = ModelPipeline(preprocessors=[],
models=models,
Expand All @@ -162,30 +156,29 @@ dataf = pipeline(dataf)

# --- 4. Submit ---
# Load credentials from .json (random credentials in this example)
key = load_key_from_json(dataf.meta.key_path)
key = load_key_from_json("test_assets/test_credentials.json")
submitter = NumeraiClassicSubmitter(directory_path="sub_current_round", key=key)
# full_submission checks contents, saves as csv and submits.
submitter.full_submission(dataf=dataf,
cols=f"prediction_{dataf.meta.joblib_model_name}_neutralized_0.5",
model_name=dataf.meta.numerai_model_name,
version=dataf.meta.version)
cols=f"prediction_test_neutralized_0.5",
model_name="test")

# --- 5. Clean up environment (optional) ---
downloader.remove_base_directory()
submitter.remove_base_directory()
```

<pre style="white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace">💻 Directory structure before starting
<span style="color: #808080; text-decoration-color: #808080">┗━━ </span>📁 test_assets
<span style="color: #808080; text-decoration-color: #808080"> ┣━━ </span>📄 joblib_v2_example_model.joblib
<span style="color: #808080; text-decoration-color: #808080"> ┗━━ </span>📄 test_credentials.json
<pre style="white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace">💻 Directory structure before starting
<span style="color: #808080; text-decoration-color: #808080">┗━━ </span>📁 test_assets
<span style="color: #808080; text-decoration-color: #808080"> ┣━━ </span>📄 joblib_v2_example_model.joblib
<span style="color: #808080; text-decoration-color: #808080"> ┗━━ </span>📄 test_credentials.json
</pre>
<pre style="white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace">💻 Directory structure after submitting
<span style="color: #808080; text-decoration-color: #808080">┣━━ </span>📁 data
<span style="color: #808080; text-decoration-color: #808080">┃ ┗━━ </span>📁 current_round
<span style="color: #808080; text-decoration-color: #808080">┃ ┗━━ </span>📄 numerai_tournament_data.parquet
<span style="color: #808080; text-decoration-color: #808080">┗━━ </span>📁 sub_current_round
<span style="color: #808080; text-decoration-color: #808080"> ┗━━ </span>📄 test_model1.csv
<pre style="white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace">💻 Directory structure after submitting
<span style="color: #808080; text-decoration-color: #808080">┣━━ </span>📁 data
<span style="color: #808080; text-decoration-color: #808080">┃ ┗━━ </span>📁 current_round
<span style="color: #808080; text-decoration-color: #808080">┃ ┗━━ </span>📄 numerai_tournament_data.parquet
<span style="color: #808080; text-decoration-color: #808080">┗━━ </span>📁 sub_current_round
<span style="color: #808080; text-decoration-color: #808080"> ┗━━ </span>📄 test_model1.csv
</pre>

#### 2.2.2. Numerai Signals
Expand All @@ -204,10 +197,8 @@ from numerblox.submission import NumeraiSignalsSubmitter
kd = KaggleDownloader("data")
kd.download_inference_data("code1110/yfinance-stock-price-data-for-numerai-signals")

# --- 2. Initialize NumerFrame with metadata ---
metadata = {"numerai_model_name": "test_model1",
"key_path": "test_assets/test_credentials.json"}
dataf = create_numerframe("data/full_data.parquet", metadata=metadata)
# --- 2. Initialize NumerFrame ---
dataf = create_numerframe("data/full_data.parquet")

# --- 3. Define and run pipeline ---
models = [SingleModel("models/signals_model.cbm", model_name="cb")]
Expand All @@ -220,31 +211,31 @@ dataf = pipeline(dataf)

# --- 4. Submit ---
# Load credentials from .json (random credentials in this example)
key = load_key_from_json(dataf.meta.key_path)
key = load_key_from_json("test_assets/test_credentials.json")
submitter = NumeraiSignalsSubmitter(directory_path="sub_current_round", key=key)
# full_submission checks contents, saves as csv and submits.
# cols selection must at least contain 1 ticker column and a signal column.
dataf['signal'] = dataf['prediction_cb']
submitter.full_submission(dataf=dataf,
cols=['bloomberg_ticker', 'signal'],
model_name=dataf.meta.numerai_model_name)
model_name="test_model1")

# --- 5. Clean up environment (optional) ---
kd.remove_base_directory()
submitter.remove_base_directory()
```

<pre style="white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace">💻 Directory structure before starting
<span style="color: #808080; text-decoration-color: #808080">┣━━ </span>📁 test_assets
<span style="color: #808080; text-decoration-color: #808080">┃ ┗━━ </span>📄 test_credentials.json
<span style="color: #808080; text-decoration-color: #808080">┗━━ </span>📁 models
<span style="color: #808080; text-decoration-color: #808080"> ┗━━ </span>📄 signals_model.cbm
<pre style="white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace">💻 Directory structure before starting
<span style="color: #808080; text-decoration-color: #808080">┣━━ </span>📁 test_assets
<span style="color: #808080; text-decoration-color: #808080">┃ ┗━━ </span>📄 test_credentials.json
<span style="color: #808080; text-decoration-color: #808080">┗━━ </span>📁 models
<span style="color: #808080; text-decoration-color: #808080"> ┗━━ </span>📄 signals_model.cbm
</pre>
<pre style="white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace">💻 Directory structure after submitting
<span style="color: #808080; text-decoration-color: #808080">┣━━ </span>📁 data
<span style="color: #808080; text-decoration-color: #808080">┃ ┗━━ </span>📄 full_data.parquet
<span style="color: #808080; text-decoration-color: #808080">┗━━ </span>📁 sub_current_round
<span style="color: #808080; text-decoration-color: #808080"> ┗━━ </span>📄 submission.csv
<pre style="white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace">💻 Directory structure after submitting
<span style="color: #808080; text-decoration-color: #808080">┣━━ </span>📁 data
<span style="color: #808080; text-decoration-color: #808080">┃ ┗━━ </span>📄 full_data.parquet
<span style="color: #808080; text-decoration-color: #808080">┗━━ </span>📁 sub_current_round
<span style="color: #808080; text-decoration-color: #808080"> ┗━━ </span>📄 submission.csv
</pre>

## 3. Contributing
Expand All @@ -263,13 +254,13 @@ Every new feature should be implemented in a branch that branches from
Explicit bugfixes should be named `bugfix/{FIX_DESCRIPTION}`. An example
structure is given below.

<pre style="white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace">Branch structure
<span style="color: #808080; text-decoration-color: #808080">┗━━ </span>📦 master (release)
<span style="color: #808080; text-decoration-color: #808080"> ┗━━ </span>👨‍💻 dev
<span style="color: #808080; text-decoration-color: #808080"> ┣━━ </span>✨ feature/ta-signals-features
<span style="color: #808080; text-decoration-color: #808080"> ┣━━ </span>✨ feature/news-api-downloader
<span style="color: #808080; text-decoration-color: #808080"> ┣━━ </span>✨ feature/staking-portfolio-management
<span style="color: #808080; text-decoration-color: #808080"> ┗━━ </span>✨ bugfix/evaluator-metrics-fix
<pre style="white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace">Branch structure
<span style="color: #808080; text-decoration-color: #808080">┗━━ </span>📦 master (release)
<span style="color: #808080; text-decoration-color: #808080"> ┗━━ </span>👨‍💻 dev
<span style="color: #808080; text-decoration-color: #808080"> ┣━━ </span>✨ feature/ta-signals-features
<span style="color: #808080; text-decoration-color: #808080"> ┣━━ </span>✨ feature/news-api-downloader
<span style="color: #808080; text-decoration-color: #808080"> ┣━━ </span>✨ feature/staking-portfolio-management
<span style="color: #808080; text-decoration-color: #808080"> ┗━━ </span>✨ bugfix/evaluator-metrics-fix
</pre>

## 5. Crediting sources
Expand Down
81 changes: 15 additions & 66 deletions _proc/00_misc.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,7 @@
"metadata": {
"language": "python"
},
"outputs": [
{
"data": {
"application/javascript": "\n setTimeout(function() {\n var nbb_cell_id = 1;\n var nbb_unformatted_code = \"%load_ext autoreload\\n%autoreload 2\\n%load_ext nb_black\\n%load_ext lab_black\";\n var nbb_formatted_code = \"%load_ext autoreload\\n%autoreload 2\\n%load_ext nb_black\\n%load_ext lab_black\";\n var nbb_cells = Jupyter.notebook.get_cells();\n for (var i = 0; i < nbb_cells.length; ++i) {\n if (nbb_cells[i].input_prompt_number == nbb_cell_id) {\n if (nbb_cells[i].get_text() == nbb_unformatted_code) {\n nbb_cells[i].set_text(nbb_formatted_code);\n }\n break;\n }\n }\n }, 500);\n ",
"text/plain": [
"<IPython.core.display.Javascript object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"#| include: false"
]
Expand Down Expand Up @@ -98,28 +87,7 @@
"metadata": {
"language": "python"
},
"outputs": [
{
"data": {
"text/plain": [
"('hello', 'world')"
]
},
"execution_count": null,
"metadata": {},
"output_type": "execute_result"
},
{
"data": {
"application/javascript": "\n setTimeout(function() {\n var nbb_cell_id = 4;\n var nbb_unformatted_code = \"test_dict = AttrDict({\\\"test1\\\": \\\"hello\\\", \\\"test2\\\": \\\"world\\\"})\\ntest_dict.test1, test_dict['test2']\";\n var nbb_formatted_code = \"test_dict = AttrDict({\\\"test1\\\": \\\"hello\\\", \\\"test2\\\": \\\"world\\\"})\\ntest_dict.test1, test_dict[\\\"test2\\\"]\";\n var nbb_cells = Jupyter.notebook.get_cells();\n for (var i = 0; i < nbb_cells.length; ++i) {\n if (nbb_cells[i].input_prompt_number == nbb_cell_id) {\n if (nbb_cells[i].get_text() == nbb_unformatted_code) {\n nbb_cells[i].set_text(nbb_formatted_code);\n }\n break;\n }\n }\n }, 500);\n ",
"text/plain": [
"<IPython.core.display.Javascript object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"test_dict = AttrDict({\"test1\": \"hello\", \"test2\": \"world\"})\n",
"test_dict.test1, test_dict['test2']"
Expand All @@ -138,41 +106,22 @@
"metadata": {
"language": "python"
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Converted 00_misc.ipynb.\n",
"Converted 01_download.ipynb.\n",
"Converted 02_numerframe.ipynb.\n",
"Converted 03_preprocessing.ipynb.\n",
"Converted 04_model.ipynb.\n",
"Converted 05_postprocessing.ipynb.\n",
"Converted 06_modelpipeline.ipynb.\n",
"Converted 07_evaluation.ipynb.\n",
"Converted 08_key.ipynb.\n",
"Converted 09_submission.ipynb.\n",
"Converted 10_staking.ipynb.\n",
"Converted index.ipynb.\n"
]
},
{
"data": {
"application/javascript": "\n setTimeout(function() {\n var nbb_cell_id = 5;\n var nbb_unformatted_code = \"# hide\\n# Run this cell to sync all changes with library\\nfrom nbdev import nbdev_export\\n\\nnbdev_export()\";\n var nbb_formatted_code = \"# hide\\n# Run this cell to sync all changes with library\\nfrom nbdev import nbdev_export\\n\\nnbdev_export()\";\n var nbb_cells = Jupyter.notebook.get_cells();\n for (var i = 0; i < nbb_cells.length; ++i) {\n if (nbb_cells[i].input_prompt_number == nbb_cell_id) {\n if (nbb_cells[i].get_text() == nbb_unformatted_code) {\n nbb_cells[i].set_text(nbb_formatted_code);\n }\n break;\n }\n }\n }, 500);\n ",
"text/plain": [
"<IPython.core.display.Javascript object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"outputs": [],
"source": [
"#| include: false\n",
"# Run this cell to sync all changes with library\n",
"from nbdev import nbdev_export\n",
"\n",
"from nbdev import nbdev_export"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"language": "python"
},
"outputs": [],
"source": [
"#| include: false\n",
"nbdev_export()"
]
}
Expand Down
Loading

0 comments on commit 856b51e

Please sign in to comment.