Building a Personal Credit Risk Scoring Model from Scratch: Feature Engineering and Rule Engine Design

    This guide explains how to design a personal credit risk system for applicants with complex credit profiles, often characterized by frequent recent inquiries, multiple lending accounts, and complicated debt structures. It covers credit report parsing, feature engineering, the combination of hard rules and scorecards, flexible review strategies, whitelist processing, and key engineering and compliance considerations.

    1. Why “Credit-Seeking Behavior” Is a Core Risk Control Challenge

    In lending, a “messy credit profile” typically refers to a credit report showing frequent recent inquiries, a relatively large number of accounts across multiple lenders, and a complex debt structure. From a technical perspective, these applicants are not necessarily destined to default. Instead, they represent a gray area that traditional rule engines often cannot classify accurately using a single threshold.

    In practice, lenders have different tolerance levels for this type of profile. Some may automatically decline an application when the number of inquiries over the past three months exceeds a defined threshold. Others may route the application to manual underwriting or evaluate additional attributes, such as employer type, social insurance or retirement contribution levels, and assets.

    For developers, this is essentially a modeling problem involving multidimensional feature integration and flexible rule layering.

    2. Data Layer Design: Structuring Credit Report Data

    2.1 Key Credit Report Fields

    Raw credit reports are often semi-structured or unstructured documents and must first be parsed into structured data. Commonly used fields include:

    • Inquiry records: Inquiring institution, inquiry date, and inquiry purpose, such as loan approval, credit card approval, or post-loan monitoring
    • Account information: Account type, credit limit, used balance, and account status
    • Delinquency records: Number of delinquent periods, delinquent amount, and maximum days past due
    • Basic information: Employer, housing status, marital status, and other profile attributes

    A simplified data model might look like this:

    1. from dataclasses import dataclass
    2. from datetime import datetime
    3. from typing import List
    4. @dataclass
    5. class InquiryRecord:
    6. org: str
    7. date: datetime
    8. reason: str # loan_approval / credit_card / post_loan
    9. @dataclass
    10. class CreditProfile:
    11. inquiries: List[InquiryRecord]
    12. open_accounts: int
    13. total_debt: float
    14. has_severe_overdue: bool # Consecutive or cumulative delinquency above the limit

    2.2 Key Points in Feature Engineering

    In risk modeling, raw data must be transformed into computable features. For applicants with complex credit profiles, commonly used features include:

    1. Inquiry density: The number of institutional inquiries during the past 1, 3, 6, and 12 months. Approval-related inquiries should be distinguished from post-loan monitoring inquiries because they have different risk implications.
    2. Multiple-lender indicators: Number of open accounts, number of institutions providing credit, and newly opened credit facilities over the past three months.
    3. Debt indicators: Total debt, debt-to-income ratio, and credit card utilization.
    4. Qualification indicators: Social insurance or retirement contribution base, employment tenure, and employer type, such as whether the employer is a public-sector organization or a state-owned enterprise.
    1. def calc_inquiry_rate(profile: CreditProfile, window_days: int) -> int:
    2. """Count approval-related inquiries within the specified window."""
    3. now = datetime.now()
    4. return sum(
    5. 1 for q in profile.inquiries
    6. if (now - q.date).days <= window_days
    7. and q.reason == "loan_approval"
    8. )

    3. Combining a Rule Engine with a Scorecard

    3.1 Why Use Both Rules and Scores?

    A pure rule engine can create rigid boundaries. For example, an applicant with 15 inquiries may pass while one with 16 inquiries is rejected, even though the two risk profiles are nearly identical. This can lead to excessive declines around threshold boundaries.

    A pure scorecard, on the other hand, may not be suitable for blocking extreme risk events, such as severe consecutive or cumulative delinquency. Mature systems therefore commonly use a layered architecture:

    1. Application data → Hard-rule layer (automatic decline) → Scorecard layer (scoring) → Flexible strategy layer (differentiated decision)

    The hard-rule layer handles non-negotiable red lines. For example, an application may be automatically declined when the applicant has severe delinquency within the past two years.

    The scorecard layer assigns weighted values to individual features. Common approaches are based on logistic regression or tree-based models and produce a risk score or probability-like output:

    1. def score_application(features: dict, weights: dict) -> float:
    2. score = 0.0
    3. for feat, w in weights.items():
    4. score += w * features[feat]
    5. return score

    The flexible strategy layer is particularly important for applicants with complex credit profiles. One approach is to introduce a “qualification compensation” mechanism. If the number of recent inquiries is slightly above the standard threshold, but the applicant has a strong employer, a high contribution base, or property ownership, the application may be routed to manual review or approved with a reduced credit limit.

    This can be implemented as a conditional policy:

    1. def check_inquiry_rule(count_3m: int, is_quality_org: bool) -> str:
    2. threshold = 20 if is_quality_org else 15
    3. if count_3m <= threshold:
    4. return "PASS"
    5. return "MANUAL_REVIEW"

    3.2 Technical Implementation of Whitelists

    Many institutions use a whitelist mechanism. Applicants who meet specific asset or payroll deposit requirements are placed on a pre-qualified list and evaluated under less restrictive approval criteria.

    Technically, this is typically implemented as an offline batch processing plus list caching architecture:

    1. Periodically extract eligible applicants from internal data sources.
    2. Write the results to a whitelist service.
    3. Query the service in real time when a new application is submitted.

    The implementation must account for list freshness and support incremental updates so that outdated eligibility information is not used during decision-making.

    4. Engineering Considerations

    1. Data consistency: Credit data may differ between report requests. Store a snapshot of the data at application time so that underwriting and later analysis can refer to the same version.
    2. Feature freshness: Inquiry counts and outstanding balances are highly time-sensitive. Feature computation should be based on event time rather than processing time.
    3. Model monitoring: After deployment, monitor approval rates, delinquency rates, score distributions, and feature or model drift. Trigger model iteration when monitored metrics exceed defined limits.
    4. Digitizing manual underwriting: Manual review decisions should be fed back into the training dataset, creating a closed loop of rule interception, human judgment, and model learning. Over time, this can reduce dependence on manual review.
    5. Compliance: Feature usage must comply with applicable credit reporting and data protection requirements. Avoid discriminatory variables and retain complete decision records to support explainability and audits.

    5. Conclusion

    Approving applicants with complex credit profiles does not mean weakening risk controls. It means replacing crude, one-size-fits-all rules with more refined decision layers.

    For developers, the core tasks are:

    • Parse credit report data into high-quality features.
    • Build a layered decision architecture combining hard rules, a scorecard, and flexible strategies.
    • Continuously improve the model by feeding manual underwriting outcomes back into the learning process.

    This approach can help teams build lending risk systems that balance approval rates with effective risk control across a range of credit decision scenarios.