-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from perpetual-ml/json_dump
json dump before fit
- Loading branch information
Showing
10 changed files
with
225 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "perpetual" | ||
version = "0.6.0" | ||
version = "0.6.1" | ||
edition = "2021" | ||
authors = ["Mutlu Simsek <[email protected]>"] | ||
homepage = "https://perpetual-ml.com" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "py-perpetual" | ||
version = "0.6.0" | ||
version = "0.6.1" | ||
edition = "2021" | ||
authors = ["Mutlu Simsek <[email protected]>"] | ||
homepage = "https://perpetual-ml.com" | ||
|
@@ -19,7 +19,7 @@ crate-type = ["cdylib", "rlib"] | |
|
||
[dependencies] | ||
pyo3 = { version = "0.22.5", features = ["extension-module"] } | ||
perpetual_rs = {package="perpetual", version = "0.6.0", path = "../" } | ||
perpetual_rs = {package="perpetual", version = "0.6.1", path = "../" } | ||
numpy = "0.22.0" | ||
ndarray = "0.16.1" | ||
serde_plain = { version = "1.0" } | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,197 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"id": "967af9d9", | ||
"metadata": { | ||
"_cell_guid": "b1076dfc-b9ad-4769-8c92-a6c4dae69d19", | ||
"_uuid": "8f2839f25d086af736a60e9eeb907d3b93b6e0e5", | ||
"execution": { | ||
"iopub.execute_input": "2024-10-21T07:01:07.130508Z", | ||
"iopub.status.busy": "2024-10-21T07:01:07.130061Z", | ||
"iopub.status.idle": "2024-10-21T07:01:08.048111Z", | ||
"shell.execute_reply": "2024-10-21T07:01:08.046970Z" | ||
}, | ||
"papermill": { | ||
"duration": 0.926499, | ||
"end_time": "2024-10-21T07:01:08.050965", | ||
"exception": false, | ||
"start_time": "2024-10-21T07:01:07.124466", | ||
"status": "completed" | ||
}, | ||
"tags": [] | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"import numpy as np\n", | ||
"import pandas as pd\n", | ||
"from perpetual import PerpetualBooster\n", | ||
"from sklearn.metrics import roc_auc_score\n", | ||
"from sklearn.model_selection import KFold\n", | ||
"from autogluon.tabular import TabularPredictor" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"id": "c257f8fc", | ||
"metadata": { | ||
"execution": { | ||
"iopub.execute_input": "2024-10-21T07:01:28.223537Z", | ||
"iopub.status.busy": "2024-10-21T07:01:28.222764Z", | ||
"iopub.status.idle": "2024-10-21T07:01:34.667262Z", | ||
"shell.execute_reply": "2024-10-21T07:01:34.666013Z" | ||
}, | ||
"papermill": { | ||
"duration": 6.453134, | ||
"end_time": "2024-10-21T07:01:34.670004", | ||
"exception": false, | ||
"start_time": "2024-10-21T07:01:28.216870", | ||
"status": "completed" | ||
}, | ||
"tags": [] | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"X_train = pd.read_csv('../../resources/santander-train.csv', index_col=0)\n", | ||
"y_train = X_train.pop('TARGET')" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "e0590d0a", | ||
"metadata": { | ||
"execution": { | ||
"iopub.execute_input": "2024-10-21T07:01:34.680697Z", | ||
"iopub.status.busy": "2024-10-21T07:01:34.680290Z", | ||
"iopub.status.idle": "2024-10-21T07:01:34.689412Z", | ||
"shell.execute_reply": "2024-10-21T07:01:34.688210Z" | ||
}, | ||
"papermill": { | ||
"duration": 0.017414, | ||
"end_time": "2024-10-21T07:01:34.691792", | ||
"exception": false, | ||
"start_time": "2024-10-21T07:01:34.674378", | ||
"status": "completed" | ||
}, | ||
"tags": [] | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"X_train.shape" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 4, | ||
"id": "22eba1d7", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"cv = KFold(shuffle=True, random_state=42)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "921f491f", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"scores = []\n", | ||
"for train, test in cv.split(X_train, y_train):\n", | ||
" model = PerpetualBooster(objective=\"LogLoss\")\n", | ||
" model.fit(X_train.iloc[train], y_train.iloc[train], budget=1.0)\n", | ||
" probabilities = model.predict_proba(X_train.iloc[test])\n", | ||
" score = roc_auc_score(y_train.iloc[test], probabilities[:, 1])\n", | ||
" scores.append(score)\n", | ||
" print(model.number_of_trees)\n", | ||
"print(np.mean(scores))" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "0a04e569", | ||
"metadata": { | ||
"execution": { | ||
"iopub.execute_input": "2024-10-21T07:01:34.702317Z", | ||
"iopub.status.busy": "2024-10-21T07:01:34.701880Z", | ||
"iopub.status.idle": "2024-10-21T07:02:04.983918Z", | ||
"shell.execute_reply": "2024-10-21T07:02:04.982720Z" | ||
}, | ||
"papermill": { | ||
"duration": 30.294535, | ||
"end_time": "2024-10-21T07:02:04.990727", | ||
"exception": false, | ||
"start_time": "2024-10-21T07:01:34.696192", | ||
"status": "completed" | ||
}, | ||
"tags": [] | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"scores = []\n", | ||
"X_train['TARGET'] = y_train\n", | ||
"for train, test in cv.split(X_train, y_train):\n", | ||
" model = TabularPredictor(label=\"TARGET\", verbosity=0)\n", | ||
" model.fit(X_train.iloc[train])\n", | ||
" probabilities = model.predict_proba(X_train.iloc[test])\n", | ||
" score = roc_auc_score(y_train.iloc[test], probabilities.to_numpy()[:, 1])\n", | ||
" print(score)\n", | ||
" scores.append(score)\n", | ||
"print(np.mean(scores))" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kaggle": { | ||
"accelerator": "none", | ||
"dataSources": [ | ||
{ | ||
"databundleVersionId": 860641, | ||
"sourceId": 4986, | ||
"sourceType": "competition" | ||
} | ||
], | ||
"dockerImageVersionId": 30786, | ||
"isGpuEnabled": false, | ||
"isInternetEnabled": true, | ||
"language": "python", | ||
"sourceType": "notebook" | ||
}, | ||
"kernelspec": { | ||
"display_name": "py311", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"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.9" | ||
}, | ||
"papermill": { | ||
"default_parameters": {}, | ||
"duration": 62.454609, | ||
"end_time": "2024-10-21T07:02:06.520206", | ||
"environment_variables": {}, | ||
"exception": null, | ||
"input_path": "__notebook__.ipynb", | ||
"output_path": "__notebook__.ipynb", | ||
"parameters": {}, | ||
"start_time": "2024-10-21T07:01:04.065597", | ||
"version": "2.6.0" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters