{"id":26249872,"url":"https://github.com/shichenxie/scorecardpy","last_synced_at":"2025-05-15T05:03:27.820Z","repository":{"id":41322164,"uuid":"130791365","full_name":"ShichenXie/scorecardpy","owner":"ShichenXie","description":"Scorecard Development in python, 评分卡","archived":false,"fork":false,"pushed_at":"2024-08-09T16:17:06.000Z","size":200,"stargazers_count":738,"open_issues_count":36,"forks_count":304,"subscribers_count":35,"default_branch":"master","last_synced_at":"2025-04-03T18:11:18.259Z","etag":null,"topics":["binning","credit-scoring","python","release","scorecard","woe","woebinning"],"latest_commit_sha":null,"homepage":"http://shichen.name/scorecard","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ShichenXie.png","metadata":{"files":{"readme":"README.md","changelog":"NEWS.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"custom":["https://www.paypal.me/shichenxie","http://shichen.name/donate"]}},"created_at":"2018-04-24T03:31:58.000Z","updated_at":"2025-03-28T08:56:20.000Z","dependencies_parsed_at":"2022-08-10T01:54:16.748Z","dependency_job_id":"f414a08d-df52-4b11-9555-5457328ccd5f","html_url":"https://github.com/ShichenXie/scorecardpy","commit_stats":{"total_commits":101,"total_committers":6,"mean_commits":"16.833333333333332","dds":"0.12871287128712872","last_synced_commit":"2f28b47b70086b30d253ac13670c452f0c654f03"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShichenXie%2Fscorecardpy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShichenXie%2Fscorecardpy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShichenXie%2Fscorecardpy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShichenXie%2Fscorecardpy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ShichenXie","download_url":"https://codeload.github.com/ShichenXie/scorecardpy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248387968,"owners_count":21095312,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["binning","credit-scoring","python","release","scorecard","woe","woebinning"],"created_at":"2025-03-13T15:50:30.039Z","updated_at":"2025-04-11T11:45:47.830Z","avatar_url":"https://github.com/ShichenXie.png","language":"Python","readme":"# scorecardpy\n\n[![PyPI version](https://img.shields.io/pypi/pyversions/scorecardpy.svg)](https://pypi.python.org/pypi/scorecardpy)\n[![PyPI release](https://img.shields.io/pypi/v/scorecardpy.svg)](https://pypi.python.org/pypi/scorecardpy)\n[![Downloads](http://pepy.tech/badge/scorecardpy)](http://pepy.tech/project/scorecardpy)\n[![Downloads](https://pepy.tech/badge/scorecardpy/month)](https://pepy.tech/project/scorecardpy/month)\n\n\nThis package is python version of R package [scorecard](https://github.com/ShichenXie/scorecard). \nIts goal is to make the development of traditional credit risk scorecard model easier and efficient by providing functions for some common tasks. \n- data partition (`split_df`)\n- variable selection (`iv`, `var_filter`)\n- weight of evidence (woe) binning (`woebin`, `woebin_plot`, `woebin_adj`, `woebin_ply`)\n- scorecard scaling (`scorecard`, `scorecard_ply`)\n- performance evaluation (`perf_eva`, `perf_psi`)\n\n## Installation\n\n- Install the release version of `scorecardpy` from [PYPI](https://pypi.org/project/scorecardpy/) with:\n```\npip install scorecardpy\n```\n\n- Install the latest version of `scorecardpy` from [github](https://github.com/shichenxie/scorecardpy) with:\n```\npip install git+git://github.com/shichenxie/scorecardpy.git\n```\n\n## Example\n\nThis is a basic example which shows you how to develop a common credit risk scorecard:\n\n``` python\n# Traditional Credit Scoring Using Logistic Regression\nimport scorecardpy as sc\n\n# data prepare ------\n# load germancredit data\ndat = sc.germancredit()\n\n# filter variable via missing rate, iv, identical value rate\ndt_s = sc.var_filter(dat, y=\"creditability\")\n\n# breaking dt into train and test\ntrain, test = sc.split_df(dt_s, 'creditability').values()\n\n# woe binning ------\nbins = sc.woebin(dt_s, y=\"creditability\")\n# sc.woebin_plot(bins)\n\n# binning adjustment\n# # adjust breaks interactively\n# breaks_adj = sc.woebin_adj(dt_s, \"creditability\", bins) \n# # or specify breaks manually\nbreaks_adj = {\n    'age.in.years': [26, 35, 40],\n    'other.debtors.or.guarantors': [\"none\", \"co-applicant%,%guarantor\"]\n}\nbins_adj = sc.woebin(dt_s, y=\"creditability\", breaks_list=breaks_adj)\n\n# converting train and test into woe values\ntrain_woe = sc.woebin_ply(train, bins_adj)\ntest_woe = sc.woebin_ply(test, bins_adj)\n\ny_train = train_woe.loc[:,'creditability']\nX_train = train_woe.loc[:,train_woe.columns != 'creditability']\ny_test = test_woe.loc[:,'creditability']\nX_test = test_woe.loc[:,train_woe.columns != 'creditability']\n\n# logistic regression ------\nfrom sklearn.linear_model import LogisticRegression\nlr = LogisticRegression(penalty='l1', C=0.9, solver='saga', n_jobs=-1)\nlr.fit(X_train, y_train)\n# lr.coef_\n# lr.intercept_\n\n# predicted proability\ntrain_pred = lr.predict_proba(X_train)[:,1]\ntest_pred = lr.predict_proba(X_test)[:,1]\n\n# performance ks \u0026 roc ------\ntrain_perf = sc.perf_eva(y_train, train_pred, title = \"train\")\ntest_perf = sc.perf_eva(y_test, test_pred, title = \"test\")\n\n# score ------\ncard = sc.scorecard(bins_adj, lr, X_train.columns)\n# credit score\ntrain_score = sc.scorecard_ply(train, card, print_step=0)\ntest_score = sc.scorecard_ply(test, card, print_step=0)\n\n# psi\nsc.perf_psi(\n  score = {'train':train_score, 'test':test_score},\n  label = {'train':y_train, 'test':y_test}\n)\n```\n","funding_links":["https://www.paypal.me/shichenxie","http://shichen.name/donate"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshichenxie%2Fscorecardpy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshichenxie%2Fscorecardpy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshichenxie%2Fscorecardpy/lists"}