Giter Site home page Giter Site logo

onlookerliu / pyscorecard Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ncoghlan/pyscorecard

0.0 1.0 0.0 28 KB

Python client for submitting PMML ScoreCard models and queries against them to OpenScoring

License: Apache License 2.0

Python 100.00%

pyscorecard's Introduction

Note: I'm not currently working on this, if you're interested in picking it up, file an issue over on https://github.com/ncoghlan/admin-meta

pyscorecard

Python client for submitting PMML ScoreCard models and queries against them to OpenScoring

PMML ScoreCards: http://dmg.org/pmml/v4-2-1/Scorecard.html for additional background

OpenScoring REST API: https://github.com/jpmml/openscoring Demo instance: http://openscoring-ncoghlan.rhcloud.com/openscoring/ Demo git repo: https://github.com/ncoghlan/openscoring-openshift

PMML ScoreCard generation from JSON input

Command line invocation:

pyscorecard input_spec.json pmml_output_dir

Output PMML file names are generated based on a combination of "model_name" and "param_grid" entries as described below.

In the Python API, scorecard.pmml_scorecard generates PMML scorecard definitions from a JSON-compatible input mapping.

See examples/risk_example.json (input) and examples/risk_example.xml (output)

All ScoreCards produce a single predicted risk score and up to 3 reason codes:

  • RiskScore
  • ReasonCode1
  • ReasonCode2
  • ReasonCode3

Generated ScoreCards are also currently all hardcoded to use the "pointsAbove" reason code algorithm, the "min" baseline score algorithm, 0 as the initial score for the overall scorecard evaluation and 1 as the baseline score for each individual characteristic (this ensures that characteristics achieving a partial score of 0 are never reported as reason codes for the overall risk scoring).

The input format is a JSON mapping with the following fields:

  • model_name: name of the model (also used as output filename prefix)

  • param_grid: parameter definitions for use in characteristic predicates

    • key is the variable name that can be substituted into predicates
    • value is a mapping of output filename suffixes to substition values
    • when multiple grid parameters are defined, keys are lexically sorted when determining the combined output filename
  • data_fields: sequence of field definitions for the DataDictionary and MiningSchema sections in the generated PMML Scorecard

    • name: used in both the DataField entry and the MiningField entry
    • dataType: used in the DataField entry
    • optype: used in the DataField entry to define handling of comparisons
    • values: permitted values for categorical and ordinal fields
  • characteristics: sequence of definitions for the Characteristic section in the generated PMML Scorecard

    • name: data field used by this characteristic. Also used to derive the characteristic name as name + "Score" and the overall characteristic reason code as name + "RC"

    • attributes: sequence of attribute definitions used by the characteristic

      • reasonCode: specific reason code when this criterion is met
      • partialScore: contribution to the risk score when this criterion is met
      • predicate: predicate defining this criterion (see below for details)

Predicates can be defined as either a single string, or as a sequence of such strings. Each string predicate is of the form "OP value", with the data field named in the characteristic definition being the implied left hand side of the operation. Predicate sequences are implicitly and'ed together to define the overall criterion to be met for that attribute. Predicate values may start with $ to indicate a grid parameter - these will be substituted with the appropriate value for the scorecard currently being generated.

Permitted operations are == for data fields with the categorical optype, and ==, <, <=, >=, and > for data fields with the ordinal or continuous optype.

pyscorecard's People

Contributors

ncoghlan avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.