{"id":14068989,"url":"https://github.com/ShichenXie/scorecard","last_synced_at":"2025-07-30T05:30:51.670Z","repository":{"id":41565991,"uuid":"97569409","full_name":"ShichenXie/scorecard","owner":"ShichenXie","description":"Scorecard Development in R, 评分卡","archived":false,"fork":false,"pushed_at":"2024-04-13T05:38:30.000Z","size":16560,"stargazers_count":164,"open_issues_count":2,"forks_count":63,"subscribers_count":17,"default_branch":"master","last_synced_at":"2025-07-02T03:50:47.673Z","etag":null,"topics":["binning","credit-scoring","r","release","scorecard","woe","woebinning"],"latest_commit_sha":null,"homepage":"http://shichen.name/scorecard","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ShichenXie.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2017-07-18T07:45:42.000Z","updated_at":"2025-04-28T11:01:40.000Z","dependencies_parsed_at":"2024-01-03T01:20:23.048Z","dependency_job_id":"36ccb718-f5bb-4775-861d-79b1a55dc67f","html_url":"https://github.com/ShichenXie/scorecard","commit_stats":{"total_commits":433,"total_committers":7,"mean_commits":"61.857142857142854","dds":"0.018475750577367167","last_synced_commit":"c0bfc4ccfc950d50fc2cbcbd3504aef40ffb9cbb"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ShichenXie/scorecard","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShichenXie%2Fscorecard","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShichenXie%2Fscorecard/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShichenXie%2Fscorecard/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShichenXie%2Fscorecard/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ShichenXie","download_url":"https://codeload.github.com/ShichenXie/scorecard/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ShichenXie%2Fscorecard/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267815187,"owners_count":24148356,"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","status":"online","status_checked_at":"2025-07-30T02:00:09.044Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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","r","release","scorecard","woe","woebinning"],"created_at":"2024-08-13T07:06:31.629Z","updated_at":"2025-07-30T05:30:50.827Z","avatar_url":"https://github.com/ShichenXie.png","language":"R","funding_links":["https://www.paypal.me/shichenxie","http://shichen.name/donate"],"categories":["Finance","R"],"sub_categories":[],"readme":"# scorecard\n\n[![CRAN\\_Status\\_Badge](https://www.r-pkg.org/badges/version/scorecard)](https://cran.r-project.org/package=scorecard)\n[![](http://cranlogs.r-pkg.org/badges/grand-total/scorecard)](https://cran.r-project.org/package=scorecard)\n[![](http://cranlogs.r-pkg.org/badges/scorecard)](https://cran.r-project.org/package=scorecard)\n\n\nThe goal of `scorecard` package is to make the development of the traditional credit risk scorecard model easier and efficient by providing functions for some common tasks that summarized in below. This package can also used in the development of machine learning models on binary classification. \n\n- data preprocessing (`split_df`, `replace_na`, `one_hot`, `var_scale`)\n- weight of evidence (woe) binning (`woebin`, `woebin_plot`, `woebin_adj`, `woebin_ply`)\n- variable selection (`var_filter`, `iv`, `vif`)\n- performance evaluation (`perf_eva`, `perf_cv`, `perf_psi`)\n- scorecard scaling (`scorecard`, `scorecard2`, `scorecard_ply`)\n- scorecard report (`gains_table`, `report`)\n\n\n## Installation\n\n- Install the release version of `scorecard` from [CRAN](https://cran.r-project.org/package=scorecard) with:\n``` r\ninstall.packages(\"scorecard\")\n```\n\n- Install the latest version of `scorecard` from [github](https://github.com/ShichenXie/scorecard) with:\n``` r\n# install.packages(\"devtools\")\ndevtools::install_github(\"shichenxie/scorecard\")\n```\n\n## Example\n\nThis is a basic example which shows you how to develop a common credit risk scorecard:\n\n``` r\n# Traditional Credit Scoring Using Logistic Regression\nlibrary(scorecard)\n\n# data preparing ------\n# load germancredit data\ndata(\"germancredit\")\n# filter variable via missing rate, iv, identical value rate\ndt_f = var_filter(germancredit, y=\"creditability\")\n# breaking dt into train and test\ndt_list = split_df(dt_f, y=\"creditability\", ratios = c(0.6, 0.4), seed = 30)\nlabel_list = lapply(dt_list, function(x) x$creditability)\n\n# woe binning ------\nbins = woebin(dt_f, y=\"creditability\")\n# woebin_plot(bins)\n\n# binning adjustment\n## adjust breaks interactively\n# breaks_adj = woebin_adj(dt_f, \"creditability\", bins) \n## or specify breaks manually\nbreaks_adj = list(\n  age.in.years=c(26, 35, 40),\n  other.debtors.or.guarantors=c(\"none\", \"co-applicant%,%guarantor\"))\nbins_adj = woebin(dt_f, y=\"creditability\", breaks_list=breaks_adj)\n\n# converting train and test into woe values\ndt_woe_list = lapply(dt_list, function(x) woebin_ply(x, bins_adj))\n\n# glm / selecting variables ------\nm1 = glm( creditability ~ ., family = binomial(), data = dt_woe_list$train)\n# vif(m1, merge_coef = TRUE) # summary(m1)\n# Select a formula-based model by AIC (or by LASSO for large dataset)\nm_step = step(m1, direction=\"both\", trace = FALSE)\nm2 = eval(m_step$call)\n# vif(m2, merge_coef = TRUE) # summary(m2)\n\n# performance ks \u0026 roc ------\n## predicted proability\npred_list = lapply(dt_woe_list, function(x) predict(m2, x, type='response'))\n## Adjusting for oversampling (support.sas.com/kb/22/601.html)\n# card_prob_adj = scorecard2(bins_adj, dt=dt_list$train, y='creditability', \n#                x=sub('_woe$','',names(coef(m2))[-1]), badprob_pop=0.03, return_prob=TRUE)\n                \n## performance\nperf = perf_eva(pred = pred_list, label = label_list)\n# perf_adj = perf_eva(pred = card_prob_adj$prob, label = label_list$train)\n\n# score ------\n## scorecard\ncard = scorecard(bins_adj, m2)\n## credit score\nscore_list = lapply(dt_list, function(x) scorecard_ply(x, card))\n## psi\nperf_psi(score = score_list, label = label_list)\n\n# make cutoff decisions -----\n## gains table\ngtbl = gains_table(score = unlist(score_list), label = unlist(label_list))\n\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FShichenXie%2Fscorecard","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FShichenXie%2Fscorecard","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FShichenXie%2Fscorecard/lists"}