<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE article PUBLIC "-//NLM//DTD Journal Publishing DTD v3.0 20080202//EN" "http://dtd.nlm.nih.gov/publishing/3.0/journalpublishing3.dtd">
<article xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink" dtd-version="3.0" xml:lang="en" article-type="research article">
 <front>
  <journal-meta>
   <journal-id journal-id-type="publisher-id">
    jdaip
   </journal-id>
   <journal-title-group>
    <journal-title>
     Journal of Data Analysis and Information Processing
    </journal-title>
   </journal-title-group>
   <issn pub-type="epub">
    2327-7211
   </issn>
   <issn publication-format="print">
    2327-7203
   </issn>
   <publisher>
    <publisher-name>
     Scientific Research Publishing
    </publisher-name>
   </publisher>
  </journal-meta>
  <article-meta>
   <article-id pub-id-type="doi">
    10.4236/jdaip.2025.134029
   </article-id>
   <article-id pub-id-type="publisher-id">
    jdaip-146944
   </article-id>
   <article-categories>
    <subj-group subj-group-type="heading">
     <subject>
      Articles
     </subject>
    </subj-group>
    <subj-group subj-group-type="Discipline-v2">
     <subject>
      Computer Science 
     </subject>
     <subject>
       Communications, Physics 
     </subject>
     <subject>
       Mathematics
     </subject>
    </subj-group>
   </article-categories>
   <title-group>
    Performance of Different Machine Learning Algorithms for Credit Risk Classification
   </title-group>
   <contrib-group>
    <contrib contrib-type="author" xlink:type="simple">
     <name name-style="western">
      <surname>
       Martin M.
      </surname>
      <given-names>
       Kasina
      </given-names>
     </name> 
     <xref ref-type="aff" rid="aff1"> 
      <sup>1</sup>
     </xref>
    </contrib>
    <contrib contrib-type="author" xlink:type="simple">
     <name name-style="western">
      <surname>
       John M.
      </surname>
      <given-names>
       Kihoro
      </given-names>
     </name> 
     <xref ref-type="aff" rid="aff1"> 
      <sup>1</sup>
     </xref>
    </contrib>
    <contrib contrib-type="author" xlink:type="simple">
     <name name-style="western">
      <surname>
       Alex
      </surname>
      <given-names>
       Kibet
      </given-names>
     </name> 
     <xref ref-type="aff" rid="aff2"> 
      <sup>2</sup>
     </xref>
    </contrib>
   </contrib-group> 
   <aff id="aff1">
    <addr-line>
     aDepartment of Information Technology and Computer Science, School of Computing and Mathematics, The Cooperative University of Kenya, Nairobi, Kenya
    </addr-line> 
   </aff> 
   <aff id="aff2">
    <addr-line>
     aDepartment of Computing and Informatics, School of Science and Applied Technology, Laikipia University, Nairobi, Kenya
    </addr-line> 
   </aff> 
   <pub-date pub-type="epub">
    <day>
     23
    </day> 
    <month>
     09
    </month>
    <year>
     2025
    </year>
   </pub-date> 
   <volume>
    13
   </volume> 
   <issue>
    04
   </issue>
   <fpage>
    504
   </fpage>
   <lpage>
    519
   </lpage>
   <history>
    <date date-type="received">
     <day>
      23,
     </day>
     <month>
      September
     </month>
     <year>
      2025
     </year>
    </date>
    <date date-type="published">
     <day>
      1,
     </day>
     <month>
      September
     </month>
     <year>
      2025
     </year> 
    </date> 
    <date date-type="accepted">
     <day>
      1,
     </day>
     <month>
      November
     </month>
     <year>
      2025
     </year> 
    </date>
   </history>
   <permissions>
    <copyright-statement>
     © Copyright 2014 by authors and Scientific Research Publishing Inc. 
    </copyright-statement>
    <copyright-year>
     2014
    </copyright-year>
    <license>
     <license-p>
      This work is licensed under the Creative Commons Attribution International License (CC BY). http://creativecommons.org/licenses/by/4.0/
     </license-p>
    </license>
   </permissions>
   <abstract>
    Microfinance institutions in Kenya play a unique role in promoting financial inclusion, loans, and savings provision, especially to low-income individuals and small-scale entrepreneurs. However, despite their benefits, most of their products and programs in Machakos County have been reducing due to repayment challenges, threatening their financial ability to extend further credit. This could be attributed to ineffective credit scoring models which are not able to establish the nuanced non-linear repayment behavior and patterns of the loan applicants. The research objective was to enhance credit risk scoring for microfinance institutions in Machakos County using supervised machine learning algorithms. The study adopted a mixed research design under supervised machine learning approach. It randomly sampled 6771 loan application account records and repayment history. Rstudio and Python programming languages were deployed for data pre-processing and analysis. Logistic regression algorithm, XG Boosting and the random forest ensemble method were used. Metric evaluations used included the performance accuracy, Area under the Curve and F1-Score. Based on the study findings: XG Boosting was the best performer with 83.3% accuracy and 0.202 Brier score. Development of legal framework to govern ethical and open use of machine learning assessment was recommended. A similar research but using different machine learning algorithms, locations, and institutions, to ascertain the validity, reliability and the generalizability of the study findings was recommended for further research.
   </abstract>
   <kwd-group> 
    <kwd>
     Supervised Machine Learning
    </kwd> 
    <kwd>
      Loan Payment Default
    </kwd> 
    <kwd>
      Random Forest
    </kwd> 
    <kwd>
      XG Boost
    </kwd> 
    <kwd>
      Logistic Regression
    </kwd> 
    <kwd>
      Confusion Matrix
    </kwd> 
    <kwd>
      F1-Score
    </kwd>
   </kwd-group>
  </article-meta>
 </front>
 <body>
  <sec id="s1">
   <title>1. Introduction</title>
   <p>Microfinance Institutions (MFIs) are financial establishments that offer financial services, basically loans and savings accounts, to individuals and Small and Medium Enterprises (SMEs) who more often fail to meet the traditional banking threshold due to lack of formal regular income or collateral to secure credit advance services. According to <xref ref-type="bibr" rid="scirp.146944-1">
     [1]
    </xref> “the financial performance of MFIs in Kenya continues to plummet and fluctuate unpredictably despite having implemented measures to limit loan defaults, as demonstrated over a five-year period spanning the years 2016 to 2020”. The study noted that the default rate among Microfinance Institutions (MFIs) was significantly higher than it was in the broader banking sector. Although the specific default rate varied, it was generally considered to be around 15% or higher, sometimes reaching 30.8%. This roughly doubled the acceptable industry average and was considerably higher than the non-performing loan rates in the commercial banking sector, which typically ranged from 13.8% to 14.47%.</p>
  </sec><sec id="s2">
   <title>2. Statement of the Problem</title>
   <p>Despite the fact that Microfinance institutions (MFIs) in Machakos County play a crucial role in providing financial support to underserved populations, specifically low-income individuals with no formal regular income and small-scale entrepreneurs who may not access the traditional banking system. According to <xref ref-type="bibr" rid="scirp.146944-2">
     [2]
    </xref> and <xref ref-type="bibr" rid="scirp.146944-3">
     [3]
    </xref>, most of their products and programs have collapsed due to repayment problems, threatening their financial sustainability and the ability to extend additional credit. This challenge could be attributed to poor credit risk assessment of loan applicants prior to advancing loans. The current available Machine Learning algorithms present a prime opportunity not only to improve credit risk assessment and reduce the current high nonperforming loan ratios but also to give the MFIs a competing edge. The adoption and application of machine learning in microfinance institutions in Kenya, particularly in Machakos County, remains underexplored. Therefore, this research sought to improve credit risk assessment by applying machine learning techniques among MFIs operating within Machakos, Kenya.</p>
  </sec><sec id="s3">
   <title>3. Literature Review</title>
   <p>The research findings by <xref ref-type="bibr" rid="scirp.146944-4">
     [4]
    </xref> showed that poor credit risk assessment, had a significant impact on the nonperformance of loans advanced by MFIs in Kigali, Rwanda. The study by <xref ref-type="bibr" rid="scirp.146944-5">
     [5]
    </xref> recommended that an application of effective credit risk score management procedures which is sequentially developed and executed to specification, particularly through credit risk management information systems among all money lending institutions, would drop the default rates to the bare minimum in Kenya. Based on the study by <xref ref-type="bibr" rid="scirp.146944-6">
     [6]
    </xref>, which utilized the machine learning methodology and techniques for credit scoring analysis by deploying logistic regression, random forest and XG boosting algorithms. XGBoost method approach was the best performer in all metrics evaluated. However, logistic regression remained the benchmark in the classification tasks mainly because of its interpretability compatible with the requirements of financial regulators. According to the study conducted by <xref ref-type="bibr" rid="scirp.146944-7">
     [7]
    </xref>, “XGBoost has been optimized to increase GMB’s speed and prediction performance; it is advantageous because it is scalable and it can be integrated into a different platform”. Besides, “it is faster than other algorithms due to less resource usage”, the study noted. In their research <xref ref-type="bibr" rid="scirp.146944-8">
     [8]
    </xref>, who implemented a machine learning model using the light gradient boosting machine (LightGBM) classification algorithm, and it was optimized using extreme gradient boosting (XGBoost) and identify feature importance to increase the accuracy of bankruptcy prediction. The research results obtained after going through the model testing process using different evaluation metrics that included the confusion matrix got the performance accuracy of “LightGBM + XGBoost feature importance of 99.227%”. The research by <xref ref-type="bibr" rid="scirp.146944-9">
     [9]
    </xref> on machine learning and credit risk scoring titled: “Empirical evidence from small- and mid-sized businesses” observed that one of the benefits of random forests is their capacity to handle unbalanced data and variables with missing values. Additionally, the algorithm mitigates the issue of arbitrary variable selection seen by certain alternative models. The integration of diverse data collecting, processing and analysis methods enhances precision and innovation in problem-solving. The interrelationships between the variables of the study are illustrated in the conceptual framework given in <xref ref-type="fig" rid="fig1">
     Figure 1
    </xref>.</p>
   <fig id="fig1" position="float">
    <label>Figure 1</label>
    <caption>
     <title>
      <xref ref-type="bibr" rid="scirp.146944-"></xref>Figure 1. The conceptual framework.</title>
    </caption>
    <graphic mimetype="image" position="float" xlink:type="simple" xlink:href="https://html.scirp.org/file/2870849-rId15.jpeg?20251104110430" />
   </fig>
   <p>The loan requested could be categorized into different types depending on the criteria used. Individual loan applicant characteristics included the sex category, the number of years lived, marriage status, residence, and the highest formal training level attained. The details of SMEs business unit included, the business location, time in operation, previous loan payment behavior, and cash flow. The response variable was a credit risk status, categorical label of a loan applicant, categorized as either a default or non-default.</p>
  </sec><sec id="s4">
   <title>4. Methodology</title>
   <p>The study adopted a mixed research design under supervised machine learning approach. The target population for this project were the loaned individuals and SMEs within the period 2020 to 2024 by the 21 registered MFIs operating in Machakos County, Kenya. The predictor variables included: the loan; amount, time dispersed, loan applicant’s income and the loan purpose. The applicants bio data captured included: age, gender, highest formal education level, location, previous loan repayment history, marital status and the number of dependants. Business related factors included: cash flow, area of operation, previous loan repayment history. The response variable was the individual’s and SMEs credit status as a categorical label (defaulter or non-defaulter).</p>
   <sec id="s4_1">
    <title>Preprocessing</title>
    <p>To ensure the data structure conformed to the machine learning formats, a preprocessing analysis was carried out. In order to ensure that there was no vital information unnecessarily got lost, mean imputation was performed for numeric features to address the missing data values while mode imputation was used for categorical features. Capping off the most extreme data values, categorical encoding, erasing all the duplicates was done before scaling the continuous variables into a zero to one range using normalization techniques so as to accommodate most of the ML algorithms.</p>
   </sec>
  </sec><sec id="s5">
   <title>5. Models</title>
   <p>The study used: Logistic Regression algorithm, Extreme Gradient Boosting and Random forests ensemble method to analyze the data for prediction and classification of loan applicants as defaulters or non-defaulters. Rstudio, Excel and Python programming languages were deployed for data pre-processing, manipulation and classification.</p>
   <sec id="s5_1">
    <title>5.1. Logistic Regression</title>
    <p>Logistic regression method for classification was used Such that the dichotomous response variable of whether the applicant’s status is non-defaulter (0) or defaulter (1) such that; by letting the independent design matrix be X, then the response variable y with the binary values was:</p>
    <p>
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <mi>
         Y 
       </mi> 
       <mo>
         = 
       </mo> 
       <mrow> 
        <mo>
          { 
        </mo> 
        <mrow> 
         <mtable columnalign="left"> 
          <mtr columnalign="left"> 
           <mtd columnalign="left"> 
            <mn>
              0 
            </mn> 
           </mtd> 
           <mtd columnalign="left"> 
            <mrow> 
             <mtext>
               if non-defaulter 
             </mtext> 
            </mrow> 
           </mtd> 
          </mtr> 
          <mtr columnalign="left"> 
           <mtd columnalign="left"> 
            <mn>
              1 
            </mn> 
           </mtd> 
           <mtd columnalign="left"> 
            <mrow> 
             <mtext>
               if a defaulter 
             </mtext> 
            </mrow> 
           </mtd> 
          </mtr> 
         </mtable> 
        </mrow> 
       </mrow> 
      </mrow> 
     </math></p>
    <p>Then the 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <mi>
         log 
       </mi> 
       <mrow> 
        <mo>
          ( 
        </mo> 
        <mrow> 
         <mtext>
           Odds 
         </mtext> 
         <mrow> 
          <mo>
            ( 
          </mo> 
          <mrow> 
           <mtext>
             defaulter 
           </mtext> 
          </mrow> 
          <mo>
            ) 
          </mo> 
         </mrow> 
        </mrow> 
        <mo>
          ) 
        </mo> 
       </mrow> 
       <mo>
         = 
       </mo> 
       <mtext>
         logit 
       </mtext> 
       <mtext>
           
       </mtext> 
       <mi>
         π 
       </mi> 
      </mrow> 
     </math> such that:</p>
    <p>
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <mi>
         log 
       </mi> 
       <mfrac> 
        <mi>
          π 
        </mi> 
        <mrow> 
         <mn>
           1 
         </mn> 
         <mo>
           − 
         </mo> 
         <mi>
           π 
         </mi> 
        </mrow> 
       </mfrac> 
       <mo>
         = 
       </mo> 
       <msub> 
        <mi>
          β 
        </mi> 
        <mn>
          0 
        </mn> 
       </msub> 
       <mo>
         + 
       </mo> 
       <msub> 
        <mi>
          β 
        </mi> 
        <mn>
          1 
        </mn> 
       </msub> 
       <msub> 
        <mi>
          x 
        </mi> 
        <mn>
          1 
        </mn> 
       </msub> 
       <mo>
         + 
       </mo> 
       <mo>
         ⋯ 
       </mo> 
       <mo>
         + 
       </mo> 
       <msub> 
        <mi>
          β 
        </mi> 
        <mi>
          p 
        </mi> 
       </msub> 
       <msub> 
        <mi>
          x 
        </mi> 
        <mi>
          p 
        </mi> 
       </msub> 
      </mrow> 
     </math> (5.1)</p>
    <p>where 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mi>
        π 
      </mi> 
     </math> is the likelihood of the credit risk score status of a loan applicant. The sigmoid function is most appropriate for performing logistic regression because it maps the linear combination of input features to a probability. The sigmoid function is given by Equation (5.2).</p>
    <p>
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <mi>
         S 
       </mi> 
       <mrow> 
        <mo>
          ( 
        </mo> 
        <mi>
          x 
        </mi> 
        <mo>
          ) 
        </mo> 
       </mrow> 
       <mo>
         = 
       </mo> 
       <mfrac> 
        <mn>
          1 
        </mn> 
        <mrow> 
         <mn>
           1 
         </mn> 
         <mo>
           + 
         </mo> 
         <msup> 
          <mtext>
            e 
          </mtext> 
          <mrow> 
           <mo>
             − 
           </mo> 
           <mi>
             x 
           </mi> 
          </mrow> 
         </msup> 
        </mrow> 
       </mfrac> 
      </mrow> 
     </math> (5.2)</p>
    <p>where 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mi>
        x 
      </mi> 
     </math> is the input variable such that; As 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <mi>
         x 
       </mi> 
       <mo>
         → 
       </mo> 
       <mi>
         ∞ 
       </mi> 
      </mrow> 
     </math>, the function approaches 1 and as 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <mi>
         x 
       </mi> 
       <mo>
         → 
       </mo> 
       <mo>
         − 
       </mo> 
       <mi>
         ∞ 
       </mi> 
      </mrow> 
     </math>, the function approaches 0 resulting in the sigmoid shape illustrated in <xref ref-type="fig" rid="fig2">
      Figure 2
     </xref>. The sigmoid function takes any real input log-odds and gives output probability. Such that 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <mi>
         σ 
       </mi> 
       <mo>
         : 
       </mo> 
       <mi>
         ℝ 
       </mi> 
       <mo>
         → 
       </mo> 
       <mrow> 
        <mo>
          ( 
        </mo> 
        <mrow> 
         <mn>
           0 
         </mn> 
         <mo>
           , 
         </mo> 
         <mn>
           1 
         </mn> 
        </mrow> 
        <mo>
          ) 
        </mo> 
       </mrow> 
      </mrow> 
     </math>. where x is a linear function of multiple explanatory variables such that</p>
    <p>
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <mi>
         S 
       </mi> 
       <mrow> 
        <mo>
          ( 
        </mo> 
        <mi>
          x 
        </mi> 
        <mo>
          ) 
        </mo> 
       </mrow> 
       <mo>
         = 
       </mo> 
       <mi>
         p 
       </mi> 
       <mrow> 
        <mo>
          ( 
        </mo> 
        <mi>
          x 
        </mi> 
        <mo>
          ) 
        </mo> 
       </mrow> 
       <mo>
         = 
       </mo> 
       <mfrac> 
        <mn>
          1 
        </mn> 
        <mrow> 
         <mn>
           1 
         </mn> 
         <mo>
           + 
         </mo> 
         <msup> 
          <mtext>
            e 
          </mtext> 
          <mrow> 
           <msub> 
            <mi>
              β 
            </mi> 
            <mn>
              0 
            </mn> 
           </msub> 
           <mo>
             + 
           </mo> 
           <msub> 
            <mi>
              β 
            </mi> 
            <mi>
              i 
            </mi> 
           </msub> 
           <msub> 
            <mi>
              x 
            </mi> 
            <mi>
              i 
            </mi> 
           </msub> 
          </mrow> 
         </msup> 
        </mrow> 
       </mfrac> 
      </mrow> 
     </math></p>
    <fig id="fig2" position="float">
     <label>Figure 2</label>
     <caption>
      <title>
       <xref ref-type="bibr" rid="scirp.146944-"></xref>Figure 2. The Sigmoid function.</title>
     </caption>
     <graphic mimetype="image" position="float" xlink:type="simple" xlink:href="https://html.scirp.org/file/2870849-rId36.jpeg?20251104110432" />
    </fig>
    <p>In the logistic model, 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <mi>
         p 
       </mi> 
       <mrow> 
        <mo>
          ( 
        </mo> 
        <mi>
          x 
        </mi> 
        <mo>
          ) 
        </mo> 
       </mrow> 
      </mrow> 
     </math> is interpreted as the probability of a binary response variable 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mi>
        y 
      </mi> 
     </math> whereby, the normal threshhold for the event being successful ranges between 0.5 to 1, otherwise it is deemed not successful. That is in this case, the probability of failing to pay will range between 0.5 to 1. Next, the log odds inverse is explained as</p>
    <p>
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <mtext>
         logit 
       </mtext> 
       <mtext>
           
       </mtext> 
       <mi>
         p 
       </mi> 
       <mrow> 
        <mo>
          ( 
        </mo> 
        <mi>
          x 
        </mi> 
        <mo>
          ) 
        </mo> 
       </mrow> 
       <mo>
         = 
       </mo> 
       <mi>
         ln 
       </mi> 
       <mfrac> 
        <mrow> 
         <mi>
           p 
         </mi> 
         <mrow> 
          <mo>
            ( 
          </mo> 
          <mi>
            x 
          </mi> 
          <mo>
            ) 
          </mo> 
         </mrow> 
        </mrow> 
        <mrow> 
         <mn>
           1 
         </mn> 
         <mo>
           − 
         </mo> 
         <mi>
           p 
         </mi> 
         <mrow> 
          <mo>
            ( 
          </mo> 
          <mi>
            x 
          </mi> 
          <mo>
            ) 
          </mo> 
         </mrow> 
        </mrow> 
       </mfrac> 
       <mo>
         = 
       </mo> 
       <msub> 
        <mi>
          β 
        </mi> 
        <mn>
          0 
        </mn> 
       </msub> 
       <mo>
         + 
       </mo> 
       <msub> 
        <mi>
          β 
        </mi> 
        <mi>
          i 
        </mi> 
       </msub> 
       <msub> 
        <mi>
          x 
        </mi> 
        <mi>
          i 
        </mi> 
       </msub> 
      </mrow> 
     </math> (5.3)</p>
    <p>Then equivalently after exponentiation in both sides, we get the odds such that:</p>
    <p>
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <mfrac> 
        <mrow> 
         <mi>
           p 
         </mi> 
         <mrow> 
          <mo>
            ( 
          </mo> 
          <mi>
            x 
          </mi> 
          <mo>
            ) 
          </mo> 
         </mrow> 
        </mrow> 
        <mrow> 
         <mn>
           1 
         </mn> 
         <mo>
           − 
         </mo> 
         <mi>
           p 
         </mi> 
         <mrow> 
          <mo>
            ( 
          </mo> 
          <mi>
            x 
          </mi> 
          <mo>
            ) 
          </mo> 
         </mrow> 
        </mrow> 
       </mfrac> 
       <mo>
         = 
       </mo> 
       <msup> 
        <mtext>
          e 
        </mtext> 
        <mrow> 
         <msub> 
          <mi>
            β 
          </mi> 
          <mn>
            0 
          </mn> 
         </msub> 
         <mo>
           + 
         </mo> 
         <msub> 
          <mi>
            β 
          </mi> 
          <mi>
            i 
          </mi> 
         </msub> 
         <msub> 
          <mi>
            x 
          </mi> 
          <mi>
            i 
          </mi> 
         </msub> 
        </mrow> 
       </msup> 
      </mrow> 
     </math> (5.4)</p>
    <p>where 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <mi>
         p 
       </mi> 
       <mrow> 
        <mo>
          ( 
        </mo> 
        <mi>
          x 
        </mi> 
        <mo>
          ) 
        </mo> 
       </mrow> 
      </mrow> 
     </math> is the probability that the loan is not paid given some linear combination of the features. 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <msub> 
        <mi>
          β 
        </mi> 
        <mn>
          0 
        </mn> 
       </msub> 
      </mrow> 
     </math> is the intercept from linear regression when the numeric feature is equal to zero and the categorical feature is equal to the referenced feature. The study used both the regression coefficients and the odds ratio to establish the feature contribution and importance in the model.</p>
   </sec>
   <sec id="s5_2">
    <title>5.2. Random Forest</title>
    <p>Decision tree which is a simple model that divides data into different categories based on certain characteristics, is the foundation of the random forest. Decision trees mostly use entropy and information gain to decide where to split the data. Such that letting</p>
    <p>
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <mtext>
         entropy 
       </mtext> 
       <mo>
         = 
       </mo> 
       <mi>
         H 
       </mi> 
       <mo>
         , 
       </mo> 
       <mtext>
           
       </mtext> 
       <mtext>
         then 
       </mtext> 
       <mtext>
           
       </mtext> 
       <mi>
         H 
       </mi> 
       <mrow> 
        <mo>
          ( 
        </mo> 
        <mi>
          S 
        </mi> 
        <mo>
          ) 
        </mo> 
       </mrow> 
       <mo>
         = 
       </mo> 
       <mstyle displaystyle="true"> 
        <msubsup> 
         <mo>
           ∑ 
         </mo> 
         <mi>
           i 
         </mi> 
         <mi>
           n 
         </mi> 
        </msubsup> 
        <mrow> 
         <msub> 
          <mi>
            p 
          </mi> 
          <mi>
            i 
          </mi> 
         </msub> 
         <msub> 
          <mrow> 
           <mi>
             log 
           </mi> 
          </mrow> 
          <mn>
            2 
          </mn> 
         </msub> 
         <msub> 
          <mi>
            p 
          </mi> 
          <mi>
            i 
          </mi> 
         </msub> 
        </mrow> 
       </mstyle> 
      </mrow> 
     </math>.</p>
    <p>where 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <msub> 
        <mi>
          p 
        </mi> 
        <mi>
          i 
        </mi> 
       </msub> 
      </mrow> 
     </math> is the probability of each class in the dataset and n represents the number of classes. Main idea is to select the feature that leads to the greatest reduction in entropy (information gain). According to <xref ref-type="bibr" rid="scirp.146944-10">
      [10]
     </xref>, “A Random Forest model is a robust supervised ML algorithm composed of a tree-like structure that uses a set of decision trees to make predictions. Whereby each tree is trained on a random subset (with replacement) and a random subset of features”. This concept is well illustrated in <xref ref-type="fig" rid="fig3">
      Figure 3
     </xref>.</p>
    <fig id="fig3" position="float">
     <label>Figure 3</label>
     <caption>
      <title>
       <xref ref-type="bibr" rid="scirp.146944-"></xref>Figure 3. The random forest structure.</title>
     </caption>
     <graphic mimetype="image" position="float" xlink:type="simple" xlink:href="https://html.scirp.org/file/2870849-rId53.jpeg?20251104110433" />
    </fig>
    <p>The final prediction for classification tasks is decided upon by a majority vote, while for the regression ones, it is the arithmetic mean of the predictions from all the trees.</p>
   </sec>
   <sec id="s5_3">
    <title>5.3. Extreme Gradient Boosting</title>
    <p>The Extreme Gradient Boosting, also referred to as XGBoost, is a ML model used for supervised learning challenges. It uses training data to predict a target variable. Its main strength is that it is a scalable and optimized algorithm that does improve the speed and prediction performance of Gradient Boosting Machines (GMB). It does either classification or regression based on the explanatory variables which could either be quantitative and, or qualitative. The XGBoost relies on the intuition that the best possible succeeding model, when combined with preceding models, minimizes the overall prediction error as illustrated in <xref ref-type="fig" rid="fig4">
      Figure 4
     </xref>. The errors for the classification tasks are minimized through the random forest process illustrated in <xref ref-type="fig" rid="fig4">
      Figure 4
     </xref>. Each succeeding model majors on misclassifications or errors of the preceding model and tries to reduce it in the succeeding iterations.</p>
    <fig id="fig4" position="float">
     <label>Figure 4</label>
     <caption>
      <title>
       <xref ref-type="bibr" rid="scirp.146944-"></xref>Figure 4. The Xgboost for classification.</title>
     </caption>
     <graphic mimetype="image" position="float" xlink:type="simple" xlink:href="https://html.scirp.org/file/2870849-rId54.jpeg?20251104110433" />
    </fig>
   </sec>
   <sec id="s5_4">
    <title>5.4. Model Evaluation Metrics</title>
    <p>The following classification metrics were used to evaluate the performance of different machine learning algorithms for this study. The selected metrics were preferred under the assumptions that, in a binary classification task, the instances of data are typically predicted to be either positive or negative such that, where the instance is present (loan default) is labeled positive while a negative implies that the instance does not differ from the baseline in this respect, no default. Consequently, each predicted binary label has four possible outcomes: True Positive (TP) which is a correctly predicted positive outcome, True Negative (TN) which is a correctly predicted negative outcome, False Positive (FP) which is a negative instance predicted to be positive, and a False Negative (FN) which is a positive instance predicted to be negative. Therefore, the metrics included; A confusion matrix, which is a 2 by 2 matrix containing the counts of TP, TN, FP, and FN observations. A confusion matrix shows how well the classification model is performing, and it was an output of Python and R codes used to analyze the data for this study. The confusion matrix is expressed as:</p>
    <fig id="fig5" position="float">
     <label>Figure 5</label>
     <caption>
      <title>The confusion matrix counts were used to determine other metric evaluation measurements, as discussed below.
       <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
  
         <mtext>
          
   Accuracy
  
         </mtext>
  
         <mo>
          
   =
  
         </mo>
  
         <mfrac> 
   
          <mrow> 
    
           <mi>
            
     T
    
           </mi>
    
           <mi>
            
     P
    
           </mi>
    
           <mo>
            
     +
    
           </mo>
    
           <mi>
            
     T
    
           </mi>
    
           <mi>
            
     N
    
           </mi>
   
          </mrow> 
   
          <mrow> 
    
           <mi>
            
     T
    
           </mi>
    
           <mi>
            
     P
    
           </mi>
    
           <mo>
            
     +
    
           </mo>
    
           <mi>
            
     T
    
           </mi>
    
           <mi>
            
     N
    
           </mi>
    
           <mo>
            
     +
    
           </mo>
    
           <mi>
            
     F
    
           </mi>
    
           <mi>
            
     P
    
           </mi>
    
           <mo>
            
     +
    
           </mo>
    
           <mi>
            
     F
    
           </mi>
    
           <mi>
            
     N
    
           </mi>
   
          </mrow> 
  
         </mfrac> 
  
         <mo>
          
   ∈
  
         </mo>
  
         <mrow>
   
          <mo>
           
    [
   
          </mo> 
   
          <mrow> 
    
           <mn>
            
     0
    
           </mn>
    
           <mo>
            
     ,
    
           </mo>
    
           <mn>
            
     1
    
           </mn>
   
          </mrow> 
   
          <mo>
           
    ]
   
          </mo>
  
         </mrow>
 
        </mrow>

       </math>Accuracy was used to display the proportion of correctly classified instances, whether negative or positive and its value lies within 0 and 1.The Precision score used to estimate the proportion of true positive predictions out of all positive predictions. Precision score is calculated as.
       <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
  
         <mtext>
          
   Precision
  
         </mtext>
  
         <mo>
          
   =
  
         </mo>
  
         <mfrac> 
   
          <mrow> 
    
           <mi>
            
     T
    
           </mi>
    
           <mi>
            
     P
    
           </mi>
   
          </mrow> 
   
          <mrow> 
    
           <mi>
            
     T
    
           </mi>
    
           <mi>
            
     P
    
           </mi>
    
           <mo>
            
     +
    
           </mo>
    
           <mi>
            
     F
    
           </mi>
    
           <mi>
            
     P
    
           </mi>
   
          </mrow> 
  
         </mfrac> 
  
         <mo>
          
   ∈
  
         </mo>
  
         <mrow>
   
          <mo>
           
    [
   
          </mo> 
   
          <mrow> 
    
           <mn>
            
     0
    
           </mn>
    
           <mo>
            
     ,
    
           </mo>
    
           <mn>
            
     1
    
           </mn>
   
          </mrow> 
   
          <mo>
           
    ]
   
          </mo>
  
         </mrow>
 
        </mrow>

       </math>Sensitivity, which is usually referred to as recall, was also used to evaluate the performance of the models. It is calculated as:
       <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
  
         <mtext>
          
   Recall
  
         </mtext>
  
         <mo>
          
   =
  
         </mo>
  
         <mfrac> 
   
          <mrow> 
    
           <mi>
            
     T
    
           </mi>
    
           <mi>
            
     P
    
           </mi>
   
          </mrow> 
   
          <mrow> 
    
           <mi>
            
     T
    
           </mi>
    
           <mi>
            
     P
    
           </mi>
    
           <mo>
            
     +
    
           </mo>
    
           <mi>
            
     F
    
           </mi>
    
           <mi>
            
     N
    
           </mi>
   
          </mrow> 
  
         </mfrac> 
  
         <mo>
          
   ∈
  
         </mo>
  
         <mrow>
   
          <mo>
           
    [
   
          </mo> 
   
          <mrow> 
    
           <mn>
            
     0
    
           </mn>
    
           <mo>
            
     ,
    
           </mo>
    
           <mn>
            
     1
    
           </mn>
   
          </mrow> 
   
          <mo>
           
    ]
   
          </mo>
  
         </mrow>
 
        </mrow>

       </math>Measures the proportion of true positive predictions out of all actual positives. The F1-Score which is the harmonic mean of precision and recall, was used to rank the performance of the models. It is calculated as;
       <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
  
         <mi>
          
   F
  
         </mi>
  
         <mn>
          
   1
  
         </mn>
  
         <mtext>
          
    
  
         </mtext>
  
         <mtext>
          
   Score
  
         </mtext>
  
         <mo>
          
   =
  
         </mo>
  
         <mfrac> 
   
          <mrow> 
    
           <mn>
            
     2
    
           </mn>
    
           <mo>
            
     ∗
    
           </mo>
    
           <mtext>
            
     Precison
    
           </mtext>
    
           <mo>
            
     ∗
    
           </mo>
    
           <mtext>
            
     Recall
    
           </mtext>
   
          </mrow> 
   
          <mrow> 
    
           <mtext>
            
     Precision
    
           </mtext>
    
           <mo>
            
     +
    
           </mo>
    
           <mtext>
            
     Recall
    
           </mtext>
   
          </mrow> 
  
         </mfrac> 
  
         <mo>
          
   ∈
  
         </mo>
  
         <mrow>
   
          <mo>
           
    [
   
          </mo> 
   
          <mrow> 
    
           <mn>
            
     0
    
           </mn>
    
           <mo>
            
     ,
    
           </mo>
    
           <mn>
            
     1
    
           </mn>
   
          </mrow> 
   
          <mo>
           
    ]
   
          </mo>
  
         </mrow>
 
        </mrow>

       </math>It is always better to apply different evaluations metrics, especially in imbalanced datasets. Therefore, in addition to the above classification metrics, Area Under the Receiver Operating Characteristic (ROC) Curve and the decision tree classifier were also used. The AUC plots, True Positive Rate (Recall) vs. False Positive Rate at various thresholds. It ranges from 0 to 1, whereby a closer value to 1 means better performance. The Brier score (BS) which is a statistical measure used to evaluate the accuracy of probabilistic predictions—particularly in binary classification problems was also used.</title>
     </caption>
     <graphic mimetype="image" position="float" xlink:type="simple" xlink:href="https://html.scirp.org/file/2870849-rId55.jpeg?20251104110433" />
    </fig>
    <p>
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <mtext>
         BS 
       </mtext> 
       <mo>
         = 
       </mo> 
       <mfrac> 
        <mn>
          1 
        </mn> 
        <mi>
          N 
        </mi> 
       </mfrac> 
       <munderover> 
        <mstyle mathsize="140%" displaystyle="true"> 
         <mo>
           ∑ 
         </mo> 
        </mstyle> 
        <mrow> 
         <mi>
           i 
         </mi> 
         <mo>
           = 
         </mo> 
         <mn>
           1 
         </mn> 
        </mrow> 
        <mi>
          N 
        </mi> 
       </munderover> 
       <msup> 
        <mrow> 
         <mrow> 
          <mo>
            ( 
          </mo> 
          <mrow> 
           <msub> 
            <mi>
              f 
            </mi> 
            <mi>
              i 
            </mi> 
           </msub> 
           <mo>
             − 
           </mo> 
           <msub> 
            <mi>
              o 
            </mi> 
            <mi>
              i 
            </mi> 
           </msub> 
          </mrow> 
          <mo>
            ) 
          </mo> 
         </mrow> 
        </mrow> 
        <mn>
          2 
        </mn> 
       </msup> 
      </mrow> 
     </math> (5.5)</p>
    <p>where</p>
    <p>1) 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mi>
        N 
      </mi> 
     </math> = total number of predictions.</p>
    <p>2) 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <msub> 
        <mi>
          f 
        </mi> 
        <mi>
          i 
        </mi> 
       </msub> 
      </mrow> 
     </math> = predicted probability that default will occur.</p>
    <p>3) 
     <math xmlns="http://www.w3.org/1998/Math/MathML"> <mrow> 
       <msub> 
        <mi>
          o 
        </mi> 
        <mi>
          i 
        </mi> 
       </msub> 
      </mrow> 
     </math> = actual outcome (1 if default occurred, 0 otherwise).</p>
   </sec>
  </sec><sec id="s6">
   <title>6. Results</title>
   <sec id="s6_1">
    <title>6.1. Sample Size</title>
    <p>The study used learning curve to choose a sample size appropriate for model training. Typically, the ideal sample was the saturation point where the curve no longer rises but plateau, indicating that there was no further significant performance improvement by adding more data. Learning models may stabilize at slightly different levels of sample size as shown in <xref ref-type="fig" rid="fig5">
      Figure 5
     </xref> and the other models used in this study, plateau started at 3000 training sample size.</p>
    <fig id="fig6" position="float">
     <label>Figure 6</label>
     <caption>
      <title><p class="imgGroupCss_v"><img class=" imgMarkCss lazy" data-original="https://html.scirp.org/file/2870849-rId73.jpeg?20251104110435" /></p><xref ref-type="bibr" rid="scirp.146944-"></xref>Figure 5. The learning curve.</title>
     </caption>
     <graphic mimetype="image" position="float" xlink:type="simple" xlink:href="https://html.scirp.org/file/2870849-rId72.jpeg?20251104110435" />
    </fig>
    <p>Therefore, based on the learning curves from the three models, the ideal sample size for training data ranged between 3000 to 6000. The study used 6770 individual and small business loan accounts from the 21 registered microfinance institutions operating within Machakos County. Each microfinance was stratified to preserve representation, and then a unique identifier was assigned for each account. The accounts were randomly sampled within each stratum proportional to size without replacement.</p>
   </sec>
   <sec id="s6_2">
    <title>6.2. Study Features and Label</title>
    <p>The study features included demographic factors such as marital status, gender, age of the applicant, loan amount, credit history of the applicant, operating area and the date of disbursement between 2020 to 2024. Each loan was identified by the unique loan ID with labeled information on the status of the default payments. <xref ref-type="table" rid="table1">
      Table 1
     </xref> gives the features and label summary.</p>
    <table-wrap id="table1">
     <label>
      <xref ref-type="table" rid="table1">
       Table 1
      </xref></label>
     <caption>
      <title>
       <xref ref-type="bibr" rid="scirp.146944-"></xref>Table 1. Study features and label.</title>
     </caption>
     <table class="MsoTableGrid custom-table" border="0" cellspacing="0" cellpadding="0"> 
      <tr> 
       <td class="custom-bottom-td acenter" width="13.79%"><p style="text-align:center"></p></td> 
       <td class="custom-bottom-td acenter" width="20.91%"><p style="text-align:center">Name</p></td> 
       <td class="custom-bottom-td acenter" width="17.36%"><p style="text-align:center">Data type</p></td> 
       <td class="custom-bottom-td acenter" width="15.62%"><p style="text-align:center">Units</p></td> 
       <td class="custom-bottom-td acenter" width="32.32%"><p style="text-align:center">Coding of levels</p></td> 
      </tr> 
      <tr> 
       <td class="custom-top-td acenter" width="13.79%"><p style="text-align:center">Features</p></td> 
       <td class="custom-top-td acenter" width="20.91%"><p style="text-align:center">Loan ID</p></td> 
       <td class="custom-top-td acenter" width="17.36%"><p style="text-align:center">Numeric</p></td> 
       <td class="custom-top-td acenter" width="15.62%"><p style="text-align:center"></p></td> 
       <td class="custom-top-td acenter" width="32.32%"><p style="text-align:center"></p></td> 
      </tr> 
      <tr> 
       <td class="acenter" width="13.79%"><p style="text-align:center"></p></td> 
       <td class="acenter" width="20.91%"><p style="text-align:center">Gender</p></td> 
       <td class="acenter" width="17.36%"><p style="text-align:center">Categorical</p></td> 
       <td class="acenter" width="15.62%"><p style="text-align:center"></p></td> 
       <td class="acenter" width="32.32%"><p style="text-align:center">1 = female, 2 = male</p></td> 
      </tr> 
      <tr> 
       <td class="acenter" width="13.79%"><p style="text-align:center"></p></td> 
       <td class="acenter" width="20.91%"><p style="text-align:center">Marital status</p></td> 
       <td class="acenter" width="17.36%"><p style="text-align:center">Categorical</p></td> 
       <td class="acenter" width="15.62%"><p style="text-align:center"></p></td> 
       <td class="acenter" width="32.32%"><p style="text-align:center">1 = single, 2 = married, 3 = others</p></td> 
      </tr> 
      <tr> 
       <td class="acenter" width="13.79%"><p style="text-align:center"></p></td> 
       <td class="acenter" width="20.91%"><p style="text-align:center">Dependents</p></td> 
       <td class="acenter" width="17.36%"><p style="text-align:center">Categorical</p></td> 
       <td class="acenter" width="15.62%"><p style="text-align:center"></p></td> 
       <td class="acenter" width="32.32%"><p style="text-align:center">0 = None, 1 = One, 2 = Two, +3 = over three</p></td> 
      </tr> 
      <tr> 
       <td class="acenter" width="13.79%"><p style="text-align:center"></p></td> 
       <td class="acenter" width="20.91%"><p style="text-align:center">Education</p></td> 
       <td class="acenter" width="17.36%"><p style="text-align:center">Categorical</p></td> 
       <td class="acenter" width="15.62%"><p style="text-align:center"></p></td> 
       <td class="acenter" width="32.32%"><p style="text-align:center">1 = Primary, 2 = Secondary, 3 = Post-Secondary</p></td> 
      </tr> 
      <tr> 
       <td class="acenter" width="13.79%"><p style="text-align:center"></p></td> 
       <td class="acenter" width="20.91%"><p style="text-align:center">Loan Purpose</p></td> 
       <td class="acenter" width="17.36%"><p style="text-align:center">Categorical</p></td> 
       <td class="acenter" width="15.62%"><p style="text-align:center"></p></td> 
       <td class="acenter" width="32.32%"><p style="text-align:center">1 = Business, 2 = Personal, 3 = Others</p></td> 
      </tr> 
      <tr> 
       <td class="acenter" width="13.79%"><p style="text-align:center"></p></td> 
       <td class="acenter" width="20.91%"><p style="text-align:center">Applicant Income</p></td> 
       <td class="acenter" width="17.36%"><p style="text-align:center">Numeric</p></td> 
       <td class="acenter" width="15.62%"><p style="text-align:center">Kenya Shs</p></td> 
       <td class="acenter" width="32.32%"><p style="text-align:center"></p></td> 
      </tr> 
      <tr> 
       <td class="acenter" width="13.79%"><p style="text-align:center"></p></td> 
       <td class="acenter" width="20.91%"><p style="text-align:center">Applicant Age</p></td> 
       <td class="acenter" width="17.36%"><p style="text-align:center">Numeric</p></td> 
       <td class="acenter" width="15.62%"><p style="text-align:center">Years</p></td> 
       <td class="acenter" width="32.32%"><p style="text-align:center"></p></td> 
      </tr> 
      <tr> 
       <td class="acenter" width="13.79%"><p style="text-align:center"></p></td> 
       <td class="acenter" width="20.91%"><p style="text-align:center">Loan amount</p></td> 
       <td class="acenter" width="17.36%"><p style="text-align:center">Numeric</p></td> 
       <td class="acenter" width="15.62%"><p style="text-align:center">Kenya Shs</p></td> 
       <td class="acenter" width="32.32%"><p style="text-align:center"></p></td> 
      </tr> 
      <tr> 
       <td class="acenter" width="13.79%"><p style="text-align:center"></p></td> 
       <td class="acenter" width="20.91%"><p style="text-align:center">Month Disbursed</p></td> 
       <td class="acenter" width="17.36%"><p style="text-align:center">Categorical</p></td> 
       <td class="acenter" width="15.62%"><p style="text-align:center"></p></td> 
       <td class="acenter" width="32.32%"><p style="text-align:center">January to December</p></td> 
      </tr> 
      <tr> 
       <td class="acenter" width="13.79%"><p style="text-align:center"></p></td> 
       <td class="acenter" width="20.91%"><p style="text-align:center">Area of operation</p></td> 
       <td class="acenter" width="17.36%"><p style="text-align:center">Categorical</p></td> 
       <td class="acenter" width="15.62%"><p style="text-align:center"></p></td> 
       <td class="acenter" width="32.32%"><p style="text-align:center">1 = Rural, 2 = Urban, 3 = Semi urban</p></td> 
      </tr> 
      <tr> 
       <td class="acenter" width="13.79%"><p style="text-align:center">Label</p></td> 
       <td class="acenter" width="20.91%"><p style="text-align:center">Default status</p></td> 
       <td class="acenter" width="17.36%"><p style="text-align:center">Categorical</p></td> 
       <td class="acenter" width="15.62%"><p style="text-align:center"></p></td> 
       <td class="acenter" width="32.32%"><p style="text-align:center">0 = Not defaulted, 1 = Defaulted</p></td> 
      </tr> 
     </table>
    </table-wrap>
   </sec>
   <sec id="s6_3">
    <title>6.3. Data Exploratory</title>
    <p>The study explored both the target and the features to get an overview of the target and features distribution and their general relationships. The findings are discussed in the following sections.</p>
   </sec>
   <sec id="s6_4">
    <title>6.4. Target Distribution</title>
    <p>The distribution of the response variable among the sampled loan accounts was performed. About a third of the loan applicants defaulted on payment, as shown in <xref ref-type="fig" rid="fig6">
      Figure 6
     </xref>. Based on the findings displayed in <xref ref-type="fig" rid="fig6">
      Figure 6
     </xref>, non-defaulters outnumbered</p>
    <fig id="fig7" position="float">
     <label>Figure 7</label>
     <caption>
      <title>
       <xref ref-type="bibr" rid="scirp.146944-"></xref>Figure 6. The loan default status.</title>
     </caption>
     <graphic mimetype="image" position="float" xlink:type="simple" xlink:href="https://html.scirp.org/file/2870849-rId74.jpeg?20251104110436" />
    </fig>
    <p>the defaulters implying an imbalanced dataset. Since no resampling techniques such as SMOTE or under sampling were applied, the use of class weighting mitigated bias. The residual imbalance is acknowledged as a limitation. The dataset was partitioned into an 80/20 stratified train/test split. Further visualization was performed as displayed in the following sections.</p>
   </sec>
   <sec id="s6_5">
    <title>6.5. Target and Features Distribution</title>
    <p>This section related the target to the features of the study such as sex, marital status, credit history of the applicants and loan purpose as summarized in <xref ref-type="fig" rid="fig7">
      Figure 7
     </xref>.</p>
    <p>Proportionately the higher default was by loan applicants with secondary school certificates, more default was by business loan applicants 18% compared to loan applicants for personal reasons 15.1%. The least default was by those without any credit history followed by those with more than three years’ experience. Male applicants were more likely to default compared to their female counterpart applicants.</p>
    <fig id="fig8" position="float">
     <label>Figure 8</label>
     <caption>
      <title>
       <xref ref-type="bibr" rid="scirp.146944-"></xref>Figure 7. The target feature exploratory.</title>
     </caption>
     <graphic mimetype="image" position="float" xlink:type="simple" xlink:href="https://html.scirp.org/file/2870849-rId75.jpeg?20251104110437" />
    </fig>
   </sec>
  </sec><sec id="s7">
   <title>7. Metric Evaluations</title>
   <sec id="s7_1">
    <title>7.1. Logistic Regression Model Evaluation</title>
    <p>Several model performance evaluations were carried out, including confusion matrix, recall, and F1-score. A confusion matrix also known as error matrix was used to visualize the breakdown of the predicted class of loan default status based on the historical loan default from loan applicant accounts in Machakos County. The confusion matrix summarized the true positives, false positives, true negatives and false negatives as shown in <xref ref-type="table" rid="table2">
      Table 2
     </xref>. Based on the Confusion matrix values, the model posted 935 true negatives but it also misclassified 45 accounts as positives. There were 237 false negatives alongside 137 true positives, the computed accuracy level was 0.791728212. The study also used ROC (Receiver Operating Characteristic) curve to plot the true positive rate (TPR) against the false positive rate (FPR) at various threshold settings as shown in <xref ref-type="fig" rid="fig8">
      Figure 8
     </xref>. The Area Under the ROC Curve (AUC) was 0.785 implying a strong degree of separability between the binary classification of defaulters and non-defaulters. Other evaluation scores which included recall and F1-Score are summarized in <xref ref-type="table" rid="table3">
      Table 3
     </xref>.</p>
    <table-wrap id="table2">
     <label>
      <xref ref-type="table" rid="table2">
       Table 2
      </xref></label>
     <caption>
      <title>
       <xref ref-type="bibr" rid="scirp.146944-"></xref>Table 2. The confusion matrix.</title>
     </caption>
     <table class="MsoTableGrid custom-table" border="0" cellspacing="0" cellpadding="0"> 
      <tr> 
       <td class="custom-bottom-td acenter" width="33.34%"><p style="text-align:center">Classification</p></td> 
       <td class="custom-bottom-td acenter" width="33.33%"><p style="text-align:center">0</p></td> 
       <td class="custom-bottom-td acenter" width="33.33%"><p style="text-align:center">1</p></td> 
      </tr> 
      <tr> 
       <td class="custom-top-td acenter" width="33.34%"><p style="text-align:center">0</p></td> 
       <td class="custom-top-td acenter" width="33.33%"><p style="text-align:center">935</p></td> 
       <td class="custom-top-td acenter" width="33.33%"><p style="text-align:center">45</p></td> 
      </tr> 
      <tr> 
       <td class="acenter" width="33.34%"><p style="text-align:center">1</p></td> 
       <td class="acenter" width="33.33%"><p style="text-align:center">237</p></td> 
       <td class="acenter" width="33.33%"><p style="text-align:center">137</p></td> 
      </tr> 
     </table>
    </table-wrap>
    <fig id="fig9" position="float">
     <label>Figure 9</label>
     <caption>
      <title>
       <xref ref-type="bibr" rid="scirp.146944-"></xref>Figure 8. The ROC curve.</title>
     </caption>
     <graphic mimetype="image" position="float" xlink:type="simple" xlink:href="https://html.scirp.org/file/2870849-rId76.jpeg?20251104110437" />
    </fig>
    <table-wrap id="table3">
     <label>
      <xref ref-type="table" rid="table3">
       Table 3
      </xref></label>
     <caption>
      <title>
       <xref ref-type="bibr" rid="scirp.146944-"></xref>Table 3. The logistic regression evaluation results.</title>
     </caption>
     <table class="MsoTableGrid custom-table" border="0" cellspacing="0" cellpadding="0"> 
      <tr> 
       <td class="custom-bottom-td acenter" width="16.68%"><p style="text-align:center"></p></td> 
       <td class="custom-bottom-td acenter" width="16.66%"><p style="text-align:center">Classification</p></td> 
       <td class="custom-bottom-td acenter" width="16.66%"><p style="text-align:center">Precision</p></td> 
       <td class="custom-bottom-td acenter" width="16.66%"><p style="text-align:center">Recall</p></td> 
       <td class="custom-bottom-td acenter" width="16.66%"><p style="text-align:center">F1-Score</p></td> 
       <td class="custom-bottom-td acenter" width="16.66%"><p style="text-align:center">Support</p></td> 
      </tr> 
      <tr> 
       <td class="custom-top-td acenter" width="16.68%"><p style="text-align:center"></p></td> 
       <td class="custom-top-td acenter" width="16.66%"><p style="text-align:center">0</p></td> 
       <td class="custom-top-td acenter" width="16.66%"><p style="text-align:center">0.95</p></td> 
       <td class="custom-top-td acenter" width="16.66%"><p style="text-align:center">0.79</p></td> 
       <td class="custom-top-td acenter" width="16.66%"><p style="text-align:center">0.86</p></td> 
       <td class="custom-top-td acenter" width="16.66%"><p style="text-align:center">896</p></td> 
      </tr> 
      <tr> 
       <td class="acenter" width="16.68%"><p style="text-align:center"></p></td> 
       <td class="acenter" width="16.66%"><p style="text-align:center">1</p></td> 
       <td class="acenter" width="16.66%"><p style="text-align:center">0.37</p></td> 
       <td class="acenter" width="16.66%"><p style="text-align:center">0.75</p></td> 
       <td class="acenter" width="16.66%"><p style="text-align:center">0.50</p></td> 
       <td class="acenter" width="16.66%"><p style="text-align:center">458</p></td> 
      </tr> 
      <tr> 
       <td class="acenter" width="16.68%"><p style="text-align:center">Accuracy</p></td> 
       <td class="acenter" width="16.66%"><p style="text-align:center"></p></td> 
       <td class="acenter" width="16.66%"><p style="text-align:center"></p></td> 
       <td class="acenter" width="16.66%"><p style="text-align:center"></p></td> 
       <td class="acenter" width="16.66%"><p style="text-align:center">0.79</p></td> 
       <td class="acenter" width="16.66%"><p style="text-align:center">1354</p></td> 
      </tr> 
      <tr> 
       <td class="acenter" width="16.68%"><p style="text-align:center">Macro avg</p></td> 
       <td class="acenter" width="16.66%"><p style="text-align:center"></p></td> 
       <td class="acenter" width="16.66%"><p style="text-align:center">0.66</p></td> 
       <td class="acenter" width="16.66%"><p style="text-align:center">0.77</p></td> 
       <td class="acenter" width="16.66%"><p style="text-align:center">0.68</p></td> 
       <td class="acenter" width="16.66%"><p style="text-align:center">1354</p></td> 
      </tr> 
      <tr> 
       <td class="acenter" width="16.68%"><p style="text-align:center">Weighted avg</p></td> 
       <td class="acenter" width="16.66%"><p style="text-align:center"></p></td> 
       <td class="acenter" width="16.66%"><p style="text-align:center">0.75</p></td> 
       <td class="acenter" width="16.66%"><p style="text-align:center">0.78</p></td> 
       <td class="acenter" width="16.66%"><p style="text-align:center">0.73</p></td> 
       <td class="acenter" width="16.66%"><p style="text-align:center">1354</p></td> 
      </tr> 
     </table>
    </table-wrap>
   </sec>
   <sec id="s7_2">
    <title>7.2. Random Forest Model Evaluation</title>
    <p>The necessary libraries were imported prior to data preprocessing and data analysis. Data were split into training and testing sets (80% train, 20% test) prior to training random forest model. The random forest algorithm performed better than the logistic classification algorithm in contrary to <xref ref-type="bibr" rid="scirp.146944-11">
      [11]
     </xref> whose logistic regression models through stepwise selection criteria outperformed the other models with an overall accuracy of 93.33% in his research on identifying the optimal model for financial distress prediction. However, the predictions in the test data by using the random forest model were in accordance with <xref ref-type="bibr" rid="scirp.146944-9">
      [9]
     </xref>. whose research on empirical evidence from small and medium businesses observed that one of the benefits of random forests over logistic regressions was their capacity to handle unbalanced data and variables with missing values. The predictions on the test data results of the random forest model are summarized in <xref ref-type="table" rid="table4">
      Table 4
     </xref>. The model performed better than logistic classification model in precision, F1-score and accuracy.</p>
    <table-wrap id="table4">
     <label>
      <xref ref-type="table" rid="table4">
       Table 4
      </xref></label>
     <caption>
      <title>
       <xref ref-type="bibr" rid="scirp.146944-"></xref>Table 4. The random forest evaluation results.</title>
     </caption>
     <table class="MsoTableGrid custom-table" border="0" cellspacing="0" cellpadding="0"> 
      <tr> 
       <td class="custom-bottom-td acenter" width="22.81%"><p style="text-align:center"></p></td> 
       <td class="custom-bottom-td acenter" width="22.81%"><p style="text-align:center">Classification</p></td> 
       <td class="custom-bottom-td acenter" width="22.81%"><p style="text-align:center">Precision</p></td> 
       <td class="custom-bottom-td acenter" width="22.81%"><p style="text-align:center">Recall</p></td> 
       <td class="custom-bottom-td acenter" width="22.81%"><p style="text-align:center">F1-Score</p></td> 
       <td class="custom-bottom-td acenter" width="22.81%"><p style="text-align:center">Support</p></td> 
      </tr> 
      <tr> 
       <td class="custom-top-td acenter" width="22.81%"><p style="text-align:center"></p></td> 
       <td class="custom-top-td acenter" width="22.81%"><p style="text-align:center">0</p></td> 
       <td class="custom-top-td acenter" width="22.81%"><p style="text-align:center">0.92</p></td> 
       <td class="custom-top-td acenter" width="22.81%"><p style="text-align:center">0.99</p></td> 
       <td class="custom-top-td acenter" width="22.81%"><p style="text-align:center">0.95</p></td> 
       <td class="custom-top-td acenter" width="22.81%"><p style="text-align:center">896</p></td> 
      </tr> 
      <tr> 
       <td class="acenter" width="22.81%"><p style="text-align:center"></p></td> 
       <td class="acenter" width="22.81%"><p style="text-align:center">1</p></td> 
       <td class="acenter" width="22.81%"><p style="text-align:center">0.80</p></td> 
       <td class="acenter" width="22.81%"><p style="text-align:center">0.39</p></td> 
       <td class="acenter" width="22.81%"><p style="text-align:center">0.52</p></td> 
       <td class="acenter" width="22.81%"><p style="text-align:center">458</p></td> 
      </tr> 
      <tr> 
       <td class="acenter" width="22.81%"><p style="text-align:center">Accuracy</p></td> 
       <td class="acenter" width="22.81%"><p style="text-align:center"></p></td> 
       <td class="acenter" width="22.81%"><p style="text-align:center"></p></td> 
       <td class="acenter" width="22.81%"><p style="text-align:center"></p></td> 
       <td class="acenter" width="22.81%"><p style="text-align:center">0.81</p></td> 
       <td class="acenter" width="22.81%"><p style="text-align:center">1354</p></td> 
      </tr> 
      <tr> 
       <td class="acenter" width="22.81%"><p style="text-align:center">Macro avg</p></td> 
       <td class="acenter" width="22.81%"><p style="text-align:center"></p></td> 
       <td class="acenter" width="22.81%"><p style="text-align:center">0.86</p></td> 
       <td class="acenter" width="22.81%"><p style="text-align:center">0.69</p></td> 
       <td class="acenter" width="22.81%"><p style="text-align:center">0.74</p></td> 
       <td class="acenter" width="22.81%"><p style="text-align:center">1354</p></td> 
      </tr> 
      <tr> 
       <td class="acenter" width="22.81%"><p style="text-align:center">Weighted avg</p></td> 
       <td class="acenter" width="22.81%"><p style="text-align:center"></p></td> 
       <td class="acenter" width="22.81%"><p style="text-align:center">0.88</p></td> 
       <td class="acenter" width="22.81%"><p style="text-align:center">0.79</p></td> 
       <td class="acenter" width="22.81%"><p style="text-align:center">0.80</p></td> 
       <td class="acenter" width="22.81%"><p style="text-align:center">1354</p></td> 
      </tr> 
     </table>
    </table-wrap>
   </sec>
   <sec id="s7_3">
    <title>7.3. XG Boost Model Evaluation</title>
    <p>The XG Boost findings are summarized in <xref ref-type="table" rid="table5">
      Table 5
     </xref>. The model had a good accuracy level (83%) with a strong detection to non-defaulters which posted very high recall and high F1-score. Its detection to actual positives was comparatively low but good enough to detect two thirds. The weighted average was very good across different metric evaluation methods. The findings were in agreement with the study by <xref ref-type="bibr" rid="scirp.146944-12">
      [12]
     </xref>, that machine learning has come out as a strong apparatus in overcoming the limitations of traditional business analysis statistics.</p>
    <table-wrap id="table5">
     <label>
      <xref ref-type="table" rid="table5">
       Table 5
      </xref></label>
     <caption>
      <title>
       <xref ref-type="bibr" rid="scirp.146944-"></xref>Table 5. The XG Boost evaluation results.</title>
     </caption>
     <table class="MsoTableGrid custom-table" border="0" cellspacing="0" cellpadding="0"> 
      <tr> 
       <td class="custom-bottom-td acenter" width="22.81%"><p style="text-align:center"></p></td> 
       <td class="custom-bottom-td acenter" width="22.81%"><p style="text-align:center">Classification</p></td> 
       <td class="custom-bottom-td acenter" width="22.81%"><p style="text-align:center">Precision</p></td> 
       <td class="custom-bottom-td acenter" width="22.81%"><p style="text-align:center">Recall</p></td> 
       <td class="custom-bottom-td acenter" width="22.81%"><p style="text-align:center">F1-Score</p></td> 
       <td class="custom-bottom-td acenter" width="22.81%"><p style="text-align:center">Support</p></td> 
      </tr> 
      <tr> 
       <td class="custom-top-td acenter" width="22.81%"><p style="text-align:center"></p></td> 
       <td class="custom-top-td acenter" width="22.81%"><p style="text-align:center">0</p></td> 
       <td class="custom-top-td acenter" width="22.81%"><p style="text-align:center">0.82</p></td> 
       <td class="custom-top-td acenter" width="22.81%"><p style="text-align:center">0.97</p></td> 
       <td class="custom-top-td acenter" width="22.81%"><p style="text-align:center">0.89</p></td> 
       <td class="custom-top-td acenter" width="22.81%"><p style="text-align:center">896</p></td> 
      </tr> 
      <tr> 
       <td class="acenter" width="22.81%"><p style="text-align:center"></p></td> 
       <td class="acenter" width="22.81%"><p style="text-align:center">1</p></td> 
       <td class="acenter" width="22.81%"><p style="text-align:center">0.89</p></td> 
       <td class="acenter" width="22.81%"><p style="text-align:center">0.53</p></td> 
       <td class="acenter" width="22.81%"><p style="text-align:center">0.66</p></td> 
       <td class="acenter" width="22.81%"><p style="text-align:center">458</p></td> 
      </tr> 
      <tr> 
       <td class="acenter" width="22.81%"><p style="text-align:center">Accuracy</p></td> 
       <td class="acenter" width="22.81%"><p style="text-align:center"></p></td> 
       <td class="acenter" width="22.81%"><p style="text-align:center"></p></td> 
       <td class="acenter" width="22.81%"><p style="text-align:center"></p></td> 
       <td class="acenter" width="22.81%"><p style="text-align:center">0.83</p></td> 
       <td class="acenter" width="22.81%"><p style="text-align:center">1354</p></td> 
      </tr> 
      <tr> 
       <td class="acenter" width="22.81%"><p style="text-align:center">Macro avg</p></td> 
       <td class="acenter" width="22.81%"><p style="text-align:center"></p></td> 
       <td class="acenter" width="22.81%"><p style="text-align:center">0.85</p></td> 
       <td class="acenter" width="22.81%"><p style="text-align:center">0.75</p></td> 
       <td class="acenter" width="22.81%"><p style="text-align:center">0.78</p></td> 
       <td class="acenter" width="22.81%"><p style="text-align:center">1354</p></td> 
      </tr> 
      <tr> 
       <td class="acenter" width="22.81%"><p style="text-align:center">Weighted avg</p></td> 
       <td class="acenter" width="22.81%"><p style="text-align:center"></p></td> 
       <td class="acenter" width="22.81%"><p style="text-align:center">0.84</p></td> 
       <td class="acenter" width="22.81%"><p style="text-align:center">0.82</p></td> 
       <td class="acenter" width="22.81%"><p style="text-align:center">0.81</p></td> 
       <td class="acenter" width="22.81%"><p style="text-align:center">1354</p></td> 
      </tr> 
     </table>
    </table-wrap>
   </sec>
   <sec id="s7_4">
    <title>7.4. Brier Score</title>
    <p>For each model, the predicted probabilities of loan default were compared with the actual outcomes of the defaults in the test set. Calibration curves were constructed using 10 equally spaced probability bins, plotting the observed default rate within each bin against the mean predicted probability. The calibration curves generated to visualize the agreement between predicted probabilities and observed default rates is shown in <xref ref-type="fig" rid="fig9">
      Figure 9
     </xref>. Among the three models, XG Boost showed the best calibration (lowest Brier score), followed by Logistic Regression, while Random Forest exhibited comparatively weaker probability calibration. This meant that Logistic Regression and XG Boost predictions aligned more closely with the diagonal line of perfect calibration.</p>
    <fig id="fig10" position="float">
     <label>Figure 10</label>
     <caption>
      <title>
       <xref ref-type="bibr" rid="scirp.146944-"></xref>Figure 9. The Brier score.</title>
     </caption>
     <graphic mimetype="image" position="float" xlink:type="simple" xlink:href="https://html.scirp.org/file/2870849-rId77.jpeg?20251104110439" />
    </fig>
   </sec>
  </sec><sec id="s8">
   <title>8. Summary of the Findings</title>
   <p>This study focused on performing different machine learning techniques in order to enhance credit risk assessment for microfinance institutions in Machakos County, Kenya. The study findings demonstrated that machine learning models, especially the XG Boost models which outperformed both the logistic regression models and random forest models by posting 83% prediction accuracy and 0.202 brier score was most appropriate in predicting loan applicants’ repayment outcome. The models proved more effective in classifying high- and low-risk loan applicants. The weighted average was very good across different metric evaluation methods. Alongside the classification evaluation metrics, Area Under the Receiver Operating Characteristic Curve (ROC) and the Confusion matrix were used to evaluate the logistic algorithm performance. The study findings were clear indication that by integrating machine learning into credit assessment risks can reduce loan default rates, improve on the institutional credit advancement sustainability, and expand financial inclusion by lending more low income applicants and SMEs. The study also confirmed the suitability and applicability of machine learning techniques, in predictive and classification performance within the microfinance institutions. The findings underscore the probable of data-driven decision-making in transforming the microfinance institutions’ lending practices in Kenya.</p>
  </sec><sec id="s9">
   <title>9. Recommendations</title>
   <p>Microfinance institutions must invest in capacity building for handling big data, modeling, and output interpretation for evidence-based decision making. County and National governments should develop a legal framework to govern ethical and open use of machine learning assessment while observing the data protection Act. Explore more different machine learning techniques and compare their performance with the traditional credit score assessment performance.</p>
  </sec><sec id="s10">
   <title>Author Contributions</title>
   <p>Conceptualization: MMK and JMK, methodology: MMK, JMK and AK, software: MMK and JMK, Data Analysis: MMK, MMK, AK and writing original draft preparation: MMK, JMK and AK, supervision: JMK and AK.</p>
  </sec>
 </body><back>
  <ref-list>
   <title>References</title>
   <ref id="scirp.146944-ref1">
    <label>1</label>
    <mixed-citation publication-type="other" xlink:type="simple">
     Nyambu, C.M. and Ogada, J.M. (2024) Non-Performing Loan Characteristics and Financial Performance of Microfinance Banks in Kenya. International Journal of Social Sciences Management and Entrepreneurship, 8, 926-940. 
    </mixed-citation>
   </ref>
   <ref id="scirp.146944-ref2">
    <label>2</label>
    <mixed-citation publication-type="other" xlink:type="simple">
     Kimani, A., Arasa, R. and Karau, J. (2024) Resource Allocation and Performance of Microfinance Institutions in Machakos County, Kenya. International Journal of Finance and Accounting, 3, 28-35. &gt;https://doi.org/10.37284/ijfa.3.1.2191 
    </mixed-citation>
   </ref>
   <ref id="scirp.146944-ref3">
    <label>3</label>
    <mixed-citation publication-type="other" xlink:type="simple">
     Muthini, J.M. and Ndede, F.W.S. (2022) Socio-Economic Factors and Table Banking Loans Default Levels among Women Groups in Machakos County, Kenya. International Journal of Current Aspects in Finance, Banking and Accounting, 4, 91-103. &gt;https://doi.org/10.35942/ijcfa.v4i1.235 
    </mixed-citation>
   </ref>
   <ref id="scirp.146944-ref4">
    <label>4</label>
    <mixed-citation publication-type="other" xlink:type="simple">
     Twesige, D., Uwamahoro, A., Ndikubwimana, P., Gasheja, F., Misago, I.K. and Hategikimana, U. (2021) Causes of Loan Defaults within Microfinance Institutions: Learning from Micro and Small Business Owners in Rwanda: A Case of MSEs in Kigali. Rwanda Journal of Social Sciences, Humanities and Business, 2, 27-49. &gt;https://doi.org/10.4314/rjsshb.v2i1.3 
    </mixed-citation>
   </ref>
   <ref id="scirp.146944-ref5">
    <label>5</label>
    <mixed-citation publication-type="other" xlink:type="simple">
     Karanja, S.G. and Simiyu, E.M. (2022) Credit Management Practices and Loan Performance of Microfinance Banks in Kenya. Journal of Finance and Accounting, 6, 108-139. &gt;https://doi.org/10.53819/81018102t6009
    </mixed-citation>
   </ref>
   <ref id="scirp.146944-ref6">
    <label>6</label>
    <mixed-citation publication-type="other" xlink:type="simple">
     Susana, D.M.P. (2024) Optimizing Credit Scoring Models in Face of Global Economic Uncertainty: A Comprehensive Risk Analysis in Banking Loans. Master’s Thesis, Universidade NOVA de Lisboa (Portugal).
    </mixed-citation>
   </ref>
   <ref id="scirp.146944-ref7">
    <label>7</label>
    <mixed-citation publication-type="other" xlink:type="simple">
     Trizoglou, P., Liu, X.L. and Lin, Z. (2021) Fault Detection by an Ensemble Framework of Extreme Gradient Boosting (XGBoost) in the Operation of Offshore Wind Turbines. Renewable Energy, 179, 945-962. &gt;https://doi.org/10.1016/j.renene.2021.07.085 
    </mixed-citation>
   </ref>
   <ref id="scirp.146944-ref8">
    <label>8</label>
    <mixed-citation publication-type="other" xlink:type="simple">
     Syafei, R.M. and Efrilianda, D.A. (2023) Machine Learning Model Using Extreme Gradient Boosting (XGBoost) Feature Importance and Light Gradient Boosting Machine (LightGBM) to Improve Accurate Prediction of Bankruptcy. Recursive Journal of Informatics, 1, 64-72. &gt;https://doi.org/10.15294/rji.v1i2.71229 
    </mixed-citation>
   </ref>
   <ref id="scirp.146944-ref9">
    <label>9</label>
    <mixed-citation publication-type="other" xlink:type="simple">
     Bitetto, A., Cerchiello, P., Filomeni, S., Tanda, A. and Tarantino, B. (2023) Machine Learning and Credit Risk: Empirical Evidence from Small-and Mid-Sized Businesses. Socio-Economic Planning Sciences, 90, Article 101746. &gt;https://doi.org/10.1016/j.seps.2023.101746 
    </mixed-citation>
   </ref>
   <ref id="scirp.146944-ref10">
    <label>10</label>
    <mixed-citation publication-type="other" xlink:type="simple">
     Salman, H.A., Kalakech, A. and Steiti, A. (2024) Random Forest Algorithm Overview. Babylonian Journal of Machine Learning, 2024, 69-79. &gt;https://doi.org/10.58496/bjml/2024/007 
    </mixed-citation>
   </ref>
   <ref id="scirp.146944-ref11">
    <label>11</label>
    <mixed-citation publication-type="other" xlink:type="simple">
     Zizi, Y., Jamali-Alaoui, A., El Goumi, B., Oudgou, M. and El Moudden, A. (2021) An Optimal Model of Financial Distress Prediction: A Comparative Study between Neural Networks and Logistic Regression. Risks, 9, Article 200. &gt;https://doi.org/10.3390/risks9110200 
    </mixed-citation>
   </ref>
   <ref id="scirp.146944-ref12">
    <label>12</label>
    <mixed-citation publication-type="other" xlink:type="simple">
     Rahaman, M., Rani, S., Islam, R. and Bhuiyan, M.M.R. (2023) Machine Learning in Business Analytics: Advancing Statistical Methods for Data-Driven Innovation. Journal of Computer Science and Technology Studies, 5, 104-111. &gt;https://doi.org/10.32996/jcsts.2023.5.3.8
    </mixed-citation>
   </ref>
  </ref-list>
 </back>
</article>