# bvslusa
<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->
## Install
``` sh
pip install bvslusa
```
## How to use
``` python
import pandas as pd
from bvslusa.validate import remove_restritivos, target_mapping
from bvslusa.evaluate import evaluate_bvs_scores
from bvslusa.ratings import get_ratings
```
``` python
df = pd.read_csv('../data/AVZA_FB727003.csv', sep=';')
df
```
<div>
<style scoped>
.dataframe tbody tr th:only-of-type {
vertical-align: middle;
}
.dataframe tbody tr th {
vertical-align: top;
}
.dataframe thead th {
text-align: right;
}
</style>
| | DOC_NUMBER | SAFRA | QTD_SCPC | VL_SCPC | QTD_CCF | QTD_PROTESTO | VL_PROTESTO | FLAG_RESTRITIVO | SCRCRDMERPJ3 | SCRCRDMERPJ4 | SCRCRDMERPJ5 | SCRCRDATACAD | SCRCRDMERMEI | PERF_MERC_60D6M_EVER |
|-------|------------|--------|----------|---------|---------|--------------|-------------|-----------------|--------------|--------------|--------------|--------------|--------------|----------------------|
| 0 | 891026 | 202203 | 0 | 0 | 1 | 0 | 0 | 1 | 267 | 256 | 58 | 185 | 5 | MAU |
| 1 | 982383 | 202203 | 0 | 0 | 0 | 0 | 0 | 0 | 283 | 256 | 460 | 619 | 30 | BOM |
| 2 | 176129 | 202203 | 0 | 0 | 0 | 0 | 0 | 0 | 283 | 256 | 460 | 712 | 34 | BOM |
| 3 | 566081 | 202203 | 0 | 0 | 0 | 0 | 0 | 0 | 283 | 256 | 460 | 781 | 30 | BOM |
| 4 | 760613 | 202203 | 0 | 0 | 0 | 0 | 0 | 0 | 283 | 256 | 460 | 712 | 34 | BOM |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 35734 | 776859 | 202203 | 0 | 0 | 0 | 4 | 911 | 1 | 484 | 767 | 513 | 969 | 902 | MAU |
| 35735 | 94325 | 202203 | 0 | 0 | 0 | 4 | 911 | 1 | 484 | 767 | 513 | 969 | 902 | MAU |
| 35736 | 315930 | 202203 | 0 | 0 | 0 | 4 | 911 | 1 | 484 | 767 | 513 | 969 | 902 | MAU |
| 35737 | 668323 | 202203 | 0 | 0 | 0 | 4 | 911 | 1 | 484 | 767 | 513 | 969 | 902 | MAU |
| 35738 | 140483 | 202203 | 0 | 0 | 0 | 2 | 5285 | 1 | 487 | 767 | 531 | 956 | 131 | BOM |
<p>35739 rows × 14 columns</p>
</div>
``` python
df = remove_restritivos(df)
df = target_mapping(df, target='PERF_MERC_60D6M_EVER', map_dict={'BOM': 0, 'MAU': 1})
df.pipe(evaluate_bvs_scores)
```
<div>
<style scoped>
.dataframe tbody tr th:only-of-type {
vertical-align: middle;
}
.dataframe tbody tr th {
vertical-align: top;
}
.dataframe thead th {
text-align: right;
}
</style>
| | score | auc | ks |
|-----|--------------|----------|-------|
| 0 | SCRCRDMERPJ5 | 0.694770 | 30.86 |
| 1 | SCRCRDATACAD | 0.666147 | 28.28 |
| 2 | SCRCRDMERMEI | 0.610453 | 19.22 |
| 3 | SCRCRDMERPJ3 | 0.598126 | 16.93 |
| 4 | SCRCRDMERPJ4 | 0.574876 | 13.56 |
</div>
As the SCRCRDMERPJ5 is the best bvs score, let’s proceed to build
ratings with it:
``` python
df_ratings = get_ratings(df, target='PERF_MERC_60D6M_EVER', score='SCRCRDMERPJ5')
```
<div>
<style scoped>
.dataframe tbody tr th:only-of-type {
vertical-align: middle;
}
.dataframe tbody tr th {
vertical-align: top;
}
.dataframe thead th {
text-align: right;
}
</style>
| | Bin | Count | Count (%) | Non-event | Event | Event rate | WoE | IV | JS |
|--------|-------------------|-------|-----------|-----------|-------|------------|-----------|----------|--------------|
| 0 | (-inf, 294.50) | 3341 | 0.142900 | 2709 | 632 | 0.189165 | -0.892188 | 0.163145 | 1.974255e-02 |
| 1 | \[294.50, 357.50) | 1336 | 0.057143 | 1107 | 229 | 0.171407 | -0.771947 | 0.046611 | 5.685828e-03 |
| 2 | \[357.50, 405.50) | 1380 | 0.059025 | 1184 | 196 | 0.142029 | -0.549094 | 0.022291 | 2.751878e-03 |
| 3 | \[405.50, 457.50) | 1469 | 0.062831 | 1299 | 170 | 0.115725 | -0.314082 | 0.007055 | 8.782459e-04 |
| 4 | \[457.50, 491.50) | 1406 | 0.060137 | 1275 | 131 | 0.093172 | -0.072129 | 0.000322 | 4.028209e-05 |
| 5 | \[491.50, 535.50) | 1547 | 0.066168 | 1413 | 134 | 0.086619 | 0.007997 | 0.000004 | 5.272191e-07 |
| 6 | \[535.50, 570.50) | 1189 | 0.050855 | 1095 | 94 | 0.079058 | 0.107581 | 0.000563 | 7.034663e-05 |
| 7 | \[570.50, 597.50) | 1276 | 0.054577 | 1200 | 76 | 0.059561 | 0.41171 | 0.007813 | 9.698149e-04 |
| 8 | \[597.50, 629.50) | 1345 | 0.057528 | 1269 | 76 | 0.056506 | 0.467618 | 0.010386 | 1.286575e-03 |
| 9 | \[629.50, 682.50) | 2340 | 0.100086 | 2223 | 117 | 0.050000 | 0.596806 | 0.027941 | 3.441700e-03 |
| 10 | \[682.50, 748.50) | 3183 | 0.136142 | 3068 | 115 | 0.036129 | 0.936216 | 0.081821 | 9.869692e-03 |
| 11 | \[748.50, inf) | 3568 | 0.152609 | 3498 | 70 | 0.019619 | 1.563818 | 0.202677 | 2.303251e-02 |
| 12 | Special | 0 | 0.000000 | 0 | 0 | 0.000000 | 0.0 | 0.000000 | 0.000000e+00 |
| 13 | Missing | 0 | 0.000000 | 0 | 0 | 0.000000 | 0.0 | 0.000000 | 0.000000e+00 |
| Totals | | 23380 | 1.000000 | 21340 | 2040 | 0.087254 | | 0.570628 | 6.776995e-02 |
</div>

Raw data
{
"_id": null,
"home_page": "https://github.com/datarisk-io/bvslusa",
"name": "bvslusa",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7",
"maintainer_email": "",
"keywords": "nbdev jupyter notebook python",
"author": "Jo\u00e3o Nogueira",
"author_email": "joao.nogueira@datarisk.io",
"download_url": "https://files.pythonhosted.org/packages/34/9d/ea070c6355a5982d079657bd8fd4d685ba971913489ebe3044fcd2b6c031/bvslusa-0.0.2.tar.gz",
"platform": null,
"description": "# bvslusa\n\n<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->\n\n## Install\n\n``` sh\npip install bvslusa\n```\n\n## How to use\n\n``` python\nimport pandas as pd\nfrom bvslusa.validate import remove_restritivos, target_mapping\nfrom bvslusa.evaluate import evaluate_bvs_scores\nfrom bvslusa.ratings import get_ratings\n```\n\n``` python\ndf = pd.read_csv('../data/AVZA_FB727003.csv', sep=';')\ndf\n```\n\n<div>\n<style scoped>\n .dataframe tbody tr th:only-of-type {\n vertical-align: middle;\n }\n .dataframe tbody tr th {\n vertical-align: top;\n }\n .dataframe thead th {\n text-align: right;\n }\n</style>\n\n| | DOC_NUMBER | SAFRA | QTD_SCPC | VL_SCPC | QTD_CCF | QTD_PROTESTO | VL_PROTESTO | FLAG_RESTRITIVO | SCRCRDMERPJ3 | SCRCRDMERPJ4 | SCRCRDMERPJ5 | SCRCRDATACAD | SCRCRDMERMEI | PERF_MERC_60D6M_EVER |\n|-------|------------|--------|----------|---------|---------|--------------|-------------|-----------------|--------------|--------------|--------------|--------------|--------------|----------------------|\n| 0 | 891026 | 202203 | 0 | 0 | 1 | 0 | 0 | 1 | 267 | 256 | 58 | 185 | 5 | MAU |\n| 1 | 982383 | 202203 | 0 | 0 | 0 | 0 | 0 | 0 | 283 | 256 | 460 | 619 | 30 | BOM |\n| 2 | 176129 | 202203 | 0 | 0 | 0 | 0 | 0 | 0 | 283 | 256 | 460 | 712 | 34 | BOM |\n| 3 | 566081 | 202203 | 0 | 0 | 0 | 0 | 0 | 0 | 283 | 256 | 460 | 781 | 30 | BOM |\n| 4 | 760613 | 202203 | 0 | 0 | 0 | 0 | 0 | 0 | 283 | 256 | 460 | 712 | 34 | BOM |\n| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |\n| 35734 | 776859 | 202203 | 0 | 0 | 0 | 4 | 911 | 1 | 484 | 767 | 513 | 969 | 902 | MAU |\n| 35735 | 94325 | 202203 | 0 | 0 | 0 | 4 | 911 | 1 | 484 | 767 | 513 | 969 | 902 | MAU |\n| 35736 | 315930 | 202203 | 0 | 0 | 0 | 4 | 911 | 1 | 484 | 767 | 513 | 969 | 902 | MAU |\n| 35737 | 668323 | 202203 | 0 | 0 | 0 | 4 | 911 | 1 | 484 | 767 | 513 | 969 | 902 | MAU |\n| 35738 | 140483 | 202203 | 0 | 0 | 0 | 2 | 5285 | 1 | 487 | 767 | 531 | 956 | 131 | BOM |\n\n<p>35739 rows \u00d7 14 columns</p>\n</div>\n\n``` python\ndf = remove_restritivos(df)\ndf = target_mapping(df, target='PERF_MERC_60D6M_EVER', map_dict={'BOM': 0, 'MAU': 1})\ndf.pipe(evaluate_bvs_scores)\n```\n\n<div>\n<style scoped>\n .dataframe tbody tr th:only-of-type {\n vertical-align: middle;\n }\n .dataframe tbody tr th {\n vertical-align: top;\n }\n .dataframe thead th {\n text-align: right;\n }\n</style>\n\n| | score | auc | ks |\n|-----|--------------|----------|-------|\n| 0 | SCRCRDMERPJ5 | 0.694770 | 30.86 |\n| 1 | SCRCRDATACAD | 0.666147 | 28.28 |\n| 2 | SCRCRDMERMEI | 0.610453 | 19.22 |\n| 3 | SCRCRDMERPJ3 | 0.598126 | 16.93 |\n| 4 | SCRCRDMERPJ4 | 0.574876 | 13.56 |\n\n</div>\n\nAs the SCRCRDMERPJ5 is the best bvs score, let\u2019s proceed to build\nratings with it:\n\n``` python\ndf_ratings = get_ratings(df, target='PERF_MERC_60D6M_EVER', score='SCRCRDMERPJ5')\n```\n\n<div>\n<style scoped>\n .dataframe tbody tr th:only-of-type {\n vertical-align: middle;\n }\n .dataframe tbody tr th {\n vertical-align: top;\n }\n .dataframe thead th {\n text-align: right;\n }\n</style>\n\n| | Bin | Count | Count (%) | Non-event | Event | Event rate | WoE | IV | JS |\n|--------|-------------------|-------|-----------|-----------|-------|------------|-----------|----------|--------------|\n| 0 | (-inf, 294.50) | 3341 | 0.142900 | 2709 | 632 | 0.189165 | -0.892188 | 0.163145 | 1.974255e-02 |\n| 1 | \\[294.50, 357.50) | 1336 | 0.057143 | 1107 | 229 | 0.171407 | -0.771947 | 0.046611 | 5.685828e-03 |\n| 2 | \\[357.50, 405.50) | 1380 | 0.059025 | 1184 | 196 | 0.142029 | -0.549094 | 0.022291 | 2.751878e-03 |\n| 3 | \\[405.50, 457.50) | 1469 | 0.062831 | 1299 | 170 | 0.115725 | -0.314082 | 0.007055 | 8.782459e-04 |\n| 4 | \\[457.50, 491.50) | 1406 | 0.060137 | 1275 | 131 | 0.093172 | -0.072129 | 0.000322 | 4.028209e-05 |\n| 5 | \\[491.50, 535.50) | 1547 | 0.066168 | 1413 | 134 | 0.086619 | 0.007997 | 0.000004 | 5.272191e-07 |\n| 6 | \\[535.50, 570.50) | 1189 | 0.050855 | 1095 | 94 | 0.079058 | 0.107581 | 0.000563 | 7.034663e-05 |\n| 7 | \\[570.50, 597.50) | 1276 | 0.054577 | 1200 | 76 | 0.059561 | 0.41171 | 0.007813 | 9.698149e-04 |\n| 8 | \\[597.50, 629.50) | 1345 | 0.057528 | 1269 | 76 | 0.056506 | 0.467618 | 0.010386 | 1.286575e-03 |\n| 9 | \\[629.50, 682.50) | 2340 | 0.100086 | 2223 | 117 | 0.050000 | 0.596806 | 0.027941 | 3.441700e-03 |\n| 10 | \\[682.50, 748.50) | 3183 | 0.136142 | 3068 | 115 | 0.036129 | 0.936216 | 0.081821 | 9.869692e-03 |\n| 11 | \\[748.50, inf) | 3568 | 0.152609 | 3498 | 70 | 0.019619 | 1.563818 | 0.202677 | 2.303251e-02 |\n| 12 | Special | 0 | 0.000000 | 0 | 0 | 0.000000 | 0.0 | 0.000000 | 0.000000e+00 |\n| 13 | Missing | 0 | 0.000000 | 0 | 0 | 0.000000 | 0.0 | 0.000000 | 0.000000e+00 |\n| Totals | | 23380 | 1.000000 | 21340 | 2040 | 0.087254 | | 0.570628 | 6.776995e-02 |\n\n</div>\n\n\n",
"bugtrack_url": null,
"license": "Apache Software License 2.0",
"summary": "Functions to work with BVS enriched data",
"version": "0.0.2",
"project_urls": {
"Homepage": "https://github.com/datarisk-io/bvslusa"
},
"split_keywords": [
"nbdev",
"jupyter",
"notebook",
"python"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "e0073831d323e5b1e9263123d8f038e3d73e2c3bb543ef472b083c982d4fac90",
"md5": "c04d519df81905c3bc2686fff56adf4e",
"sha256": "ea5cf2a428a4c127142bd6c5e8710b68c898c3eab0f1a2fe9774a141f963bd15"
},
"downloads": -1,
"filename": "bvslusa-0.0.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "c04d519df81905c3bc2686fff56adf4e",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7",
"size": 10792,
"upload_time": "2023-05-31T16:39:19",
"upload_time_iso_8601": "2023-05-31T16:39:19.875329Z",
"url": "https://files.pythonhosted.org/packages/e0/07/3831d323e5b1e9263123d8f038e3d73e2c3bb543ef472b083c982d4fac90/bvslusa-0.0.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "349dea070c6355a5982d079657bd8fd4d685ba971913489ebe3044fcd2b6c031",
"md5": "d62dd65afffe309fbd2dbc5c99a4b683",
"sha256": "ead24fd692804050a5b368688cfb53d13eab1c74dec9b72d235d3774266ffc4a"
},
"downloads": -1,
"filename": "bvslusa-0.0.2.tar.gz",
"has_sig": false,
"md5_digest": "d62dd65afffe309fbd2dbc5c99a4b683",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7",
"size": 10972,
"upload_time": "2023-05-31T16:39:21",
"upload_time_iso_8601": "2023-05-31T16:39:21.982900Z",
"url": "https://files.pythonhosted.org/packages/34/9d/ea070c6355a5982d079657bd8fd4d685ba971913489ebe3044fcd2b6c031/bvslusa-0.0.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-05-31 16:39:21",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "datarisk-io",
"github_project": "bvslusa",
"github_not_found": true,
"lcname": "bvslusa"
}