<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Kibet Koech</title>
    <description>Essays and notes on engineering, data, artificial intelligence, software, economics, society, learning, and the things I find worth thinking through.</description>
    <link>https://www.kibetkoech.com/</link>
    <atom:link href="https://www.kibetkoech.com/feed/index.xml" rel="self" type="application/rss+xml"/>
    <pubDate>Sun, 04 Oct 2026 06:36:19 +0300</pubDate>
    <lastBuildDate>Sun, 04 Oct 2026 06:36:19 +0300</lastBuildDate>
    <generator>Jekyll v4.4.1</generator>
    
      
        <item>
          
            <title>Machine Learning Model To Predict Coups</title>
          
          <author> (Kibet Koech)</author>
          <description>
            &lt;p&gt;At 3 am on Sunday, 1 August 1982, a group of Kenya Air Force soldiers led by Senior Private Hezekiah Ochuka attempted to overthrow President Daniel arap Moi’s government. The Kenyan Army foiled the attempt, and President Moi’s government remained in power, although about 100 soldiers and more than 200 civilians died that day. This event would significantly influence the future of Kenya.&lt;/p&gt;

&lt;p&gt;Instability in a country involves political, social, or economic upheaval. It manifests as a coup or other illegal regime change, breakdown of institutions, widespread systemic corruption and state capture, organised crime, loss of territorial control, economic crisis, large-scale public unrest, and involuntary mass population displacement, including war, civil war, or other forms of conflict.&lt;/p&gt;

&lt;p&gt;I am fascinated by how society behaves, evolves, and reacts to external and internal events, as well as machine learning. Therefore, I decided to develop a machine learning model that can predict coups based on historical and socio-economic data.&lt;/p&gt;

&lt;h2 id=&quot;factors-that-lead-to-political-instability&quot;&gt;Factors that lead to political instability&lt;/h2&gt;

&lt;ul&gt;
  &lt;li&gt;Full democracies are least likely to undergo significant political upheaval and instability. Countries undergoing political transitions face high risks of political instability and violent conflict. Luckily, the &lt;a href=&quot;https://www.economistgroup.com/&quot;&gt;Economist Group&lt;/a&gt; publishes an annual democracy index that tracks the quality of democracy per country. The lower the value, the worse the democratic standards. Denmark, for example, had a near-perfect 9.28 (full democracy) while Syria had a dismal 1.32 (authoritarian) in 2024.&lt;/li&gt;
  &lt;li&gt;Democracy is often preceded by economic development, but this alone is not enough to sustain a democracy, especially in the presence of natural resources like oil, which lends massive financial resources to the regime. A study conducted in the period 1950-1990 showed that no democracy with a per capita income above US $6,000 (in 1985 prices) has had its democratic system collapse. However, economic growth neither leads necessarily to democratisation nor to improvements in other aspects of governance. For our investigation, this means that we will have to find data on GDP per capita to measure the economic development of countries.&lt;/li&gt;
  &lt;li&gt;As hinted at before, immense natural resource wealth like oil deposits can retard democratisation, by increasing the resources available to authoritarian regimes and simultaneously reducing the need for ruling elites to be responsive to the needs of their citizens. For this, we found a dataset of all oil-producing nations to represent natural wealth deposits.&lt;/li&gt;
  &lt;li&gt;The history of a coup is also a factor that will contribute to a future coup. Violence begets violence, and conflict breeds more conflict. This is our main focus, and we got data from &lt;a href=&quot;https://www.kaggle.com/datasets/michaelbryantds/coup-outcomes&quot;&gt;Kaggle&lt;/a&gt;.&lt;/li&gt;
  &lt;li&gt;High inequality also fuels tensions and conflict. Here we will use the Gini Index as published &lt;a href=&quot;https://worldpopulationreview.com/country-rankings/gini-coefficient-by-country&quot;&gt;here&lt;/a&gt;. This index measures the income distribution of a country, i.e. the gap between the rich and the poor. The lower the score, the more equal the country and vice versa.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;datasets&quot;&gt;Datasets&lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;Historical data (previous coups) : &lt;a href=&quot;https://www.kaggle.com/datasets/michaelbryantds/coup-outcomes&quot;&gt;Kaggle&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Economic/GDP data: &lt;a href=&quot;https://data.worldbank.org/indicator/NY.GDP.PCAP.CD&quot;&gt;World Bank&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Democracy Index: &lt;a href=&quot;https://www.eiu.com/n/campaigns/democracy-index-2022/&quot;&gt;Economist Intelligence&lt;/a&gt; and &lt;a href=&quot;https://en.wikipedia.org/wiki/The_Economist_Democracy_Index&quot;&gt;Wikipedia&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Oil deposits by country: &lt;a href=&quot;https://en.wikipedia.org/wiki/List_of_countries_by_proven_oil_reserves&quot;&gt;Wikipedia&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Inequality data: &lt;a href=&quot;https://worldpopulationreview.com/country-rankings/gini-coefficient-by-country&quot;&gt;gini index&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;List of countries: &lt;a href=&quot;https://en.wikipedia.org/wiki/List_of_countries_and_dependencies_by_area&quot;&gt;Wikipedia&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3 id=&quot;importing-the-libraries-and-loading-the-dataset&quot;&gt;Importing the Libraries and Loading the Dataset&lt;/h3&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pandas&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pd&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;numpy&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;np&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;matplotlib.pyplot&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;matplotlib&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;# from numpy import isnan
&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sklearn.tree&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;DecisionTreeClassifier&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sklearn.model_selection&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;train_test_split&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sklearn&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;metrics&lt;/span&gt;
&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sklearn.metrics&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;accuracy_score&lt;/span&gt;

&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;seaborn&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;as&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sns&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;sns&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;set_style&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;whitegrid&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;axes.grid&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;False&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;})&lt;/span&gt;

&lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;warnings&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;warnings&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;filterwarnings&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;ignore&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;o&quot;&gt;%&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;matplotlib&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;inline&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# load the Google Drive connector
&lt;/span&gt;&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;google.colab&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;drive&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;drive&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;mount&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;/content/drive&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# read the data
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;df&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;read_csv&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sa&quot;&gt;r&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;/content/drive/MyDrive/Coup_Data_v2.0.0.csv&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;df&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;sample&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;figure&gt;
  &lt;img alt=&quot;Coup data&quot; src=&quot;/images/coup_data.png&quot; /&gt;
  &lt;figcaption&gt;
   Feature importance for the basic random forest model
  &lt;/figcaption&gt;
&lt;/figure&gt;

&lt;h3 id=&quot;exploring-the-data-eda&quot;&gt;Exploring the Data (EDA)&lt;/h3&gt;

&lt;p&gt;When the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;realized&lt;/code&gt; column equals 1, it represents a coup.&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;df&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;columns&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Index([‘coup_id’, ‘cowcode’, ‘country’, ‘year’, ‘month’, ‘day’, ‘event_type’,
       ‘unrealized’, ‘realized’, ‘conspiracy’, ‘attempt’, ‘military’,
       ‘dissident’, ‘rebel’, ‘palace’, ‘foreign’, ‘auto’, ‘resign’, ‘popular’,
       ‘counter’, ‘other’, ‘noharm’, ‘injured’, ‘killed’, ‘harrest’, ‘jailed’,
       ‘tried’, ‘fled’, ‘exile’],
      dtype=’object’)&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;df&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;shape&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;(943, 29)&lt;/p&gt;

&lt;p&gt;There are 943 events recorded in the dataset.&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;df&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;info&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;class &apos;pandas.core.frame.DataFrame&apos;&amp;gt;&lt;/code&gt;&lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;RangeIndex: 943 entries, 0 to 942&lt;/code&gt;&lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Data columns (total 29 columns):&lt;/code&gt;&lt;br /&gt;
 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;#   Column      Non-Null Count  Dtype&lt;/code&gt; &lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;---  ------      --------------  -----&lt;/code&gt; &lt;br /&gt;
 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;0   coup_id     943 non-null    object&lt;/code&gt;&lt;br /&gt;
 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;1   cowcode     943 non-null    int64&lt;/code&gt; &lt;br /&gt;
 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;2   country     943 non-null    object&lt;/code&gt;&lt;br /&gt;
 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;3   year        943 non-null    int64&lt;/code&gt; &lt;br /&gt;
 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;4   month       943 non-null    int64&lt;/code&gt; &lt;br /&gt;
 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;5   day         943 non-null    int64&lt;/code&gt; &lt;br /&gt;
 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;6   event_type  943 non-null    object&lt;/code&gt;&lt;br /&gt;
 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;7   unrealized  943 non-null    int64&lt;/code&gt; &lt;br /&gt;
 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;8   realized    943 non-null    int64&lt;/code&gt; &lt;br /&gt;
 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;9   conspiracy  943 non-null    int64&lt;/code&gt; &lt;br /&gt;
 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;10  attempt     943 non-null    int64&lt;/code&gt; &lt;br /&gt;
 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;11  military    943 non-null    int64&lt;/code&gt; &lt;br /&gt;
 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;12  dissident   943 non-null    int64&lt;/code&gt; &lt;br /&gt;
 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;13  rebel       943 non-null    int64&lt;/code&gt; &lt;br /&gt;
 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;14  palace      943 non-null    int64&lt;/code&gt; &lt;br /&gt;
 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;15  foreign     943 non-null    int64&lt;/code&gt; &lt;br /&gt;
 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;16  auto        943 non-null    int64&lt;/code&gt; &lt;br /&gt;
 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;17  resign      943 non-null    int64&lt;/code&gt; &lt;br /&gt;
 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;18  popular     943 non-null    int64&lt;/code&gt; &lt;br /&gt;
 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;19  counter     943 non-null    int64&lt;/code&gt; &lt;br /&gt;
 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;20  other       943 non-null    int64&lt;/code&gt; &lt;br /&gt;
 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;21  noharm      943 non-null    int64&lt;/code&gt; &lt;br /&gt;
 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;22  injured     943 non-null    int64&lt;/code&gt; &lt;br /&gt;
 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;23  killed      943 non-null    int64&lt;/code&gt; &lt;br /&gt;
 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;24  harrest     943 non-null    int64&lt;/code&gt; &lt;br /&gt;
 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;25  jailed      943 non-null    int64&lt;/code&gt; &lt;br /&gt;
 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;26  tried       943 non-null    int64&lt;/code&gt; &lt;br /&gt;
 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;27  fled        943 non-null    int64&lt;/code&gt; &lt;br /&gt;
 &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;28  exile       943 non-null    int64&lt;/code&gt; &lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;dtypes: int64(26), object(3)&lt;/code&gt;&lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;memory usage: 213.8+ KB&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This dataset had data on instability events, including coups, conspiracies, etc. We shall focus only on coups as they are an obvious measurable event and they are the worst form of regime change.&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;pd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;pivot_table&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;df&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;sample&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;),&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;values&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;realized&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;country&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;figure&gt;
  &lt;img alt=&quot;Pivot data&quot; src=&quot;/images/pivot_table.png&quot; /&gt;
  &lt;figcaption&gt;
   Pivot table
  &lt;/figcaption&gt;
&lt;/figure&gt;

&lt;p&gt;When the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;realized&lt;/code&gt; column equals 1, it represents a coup. We shall now slice the dataframe to include only coup events, then we shall count the coups per country.&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;final_coups&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;coups&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;iloc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:,&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;6&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;final_coups&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;head&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;figure&gt;
  &lt;img alt=&quot;Coup data&quot; src=&quot;/images/final_coups.png&quot; /&gt;
  &lt;figcaption&gt;
   Coup Data
  &lt;/figcaption&gt;
&lt;/figure&gt;

&lt;p&gt;We don’t need the dates.&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;final_coups&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;drop&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;year&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;month&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;day&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;axis&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;columns&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;inplace&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;True&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;# then we can group by &apos;country&apos;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;final_coups&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;groupby&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;country&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])[&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;country&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;].&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;count&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;country&lt;/th&gt;
      &lt;th style=&quot;text-align: right&quot;&gt; &lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;strong&gt;Afghanistan&lt;/strong&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;8&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;strong&gt;Algeria&lt;/strong&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;7&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;strong&gt;Angola&lt;/strong&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;strong&gt;Argentina&lt;/strong&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;9&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;strong&gt;Azerbaijan&lt;/strong&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;2&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;strong&gt;…&lt;/strong&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;…&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;strong&gt;Venezuela&lt;/strong&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;4&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;strong&gt;Yemen&lt;/strong&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;strong&gt;Yemen Arab Republic&lt;/strong&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;3&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;strong&gt;Yemen PDR&lt;/strong&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;4&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;&lt;strong&gt;Zimbabwe&lt;/strong&gt;&lt;/td&gt;
      &lt;td style=&quot;text-align: right&quot;&gt;1&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;To clean this up, we need to drop the added index, then reset it and insert proper column names.&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# remove index name
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;country_coups&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;name&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;bp&quot;&gt;None&lt;/span&gt; 
&lt;span class=&quot;c1&quot;&gt;# reset the index
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;country_coups&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;country_coups&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;reset_index&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; 
&lt;span class=&quot;c1&quot;&gt;# insert the column names
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;country_coups&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;columns&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;country&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Number_of_coups&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;index&lt;/th&gt;
      &lt;th&gt;country&lt;/th&gt;
      &lt;th&gt;Number_of_coups&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;69&lt;/td&gt;
      &lt;td&gt;Paraguay&lt;/td&gt;
      &lt;td&gt;6&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;44&lt;/td&gt;
      &lt;td&gt;Honduras&lt;/td&gt;
      &lt;td&gt;7&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;8&lt;/td&gt;
      &lt;td&gt;Brazil&lt;/td&gt;
      &lt;td&gt;5&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;90&lt;/td&gt;
      &lt;td&gt;Thailand&lt;/td&gt;
      &lt;td&gt;11&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;73&lt;/td&gt;
      &lt;td&gt;Portugal&lt;/td&gt;
      &lt;td&gt;3&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;31&lt;/td&gt;
      &lt;td&gt;Ethiopia&lt;/td&gt;
      &lt;td&gt;7&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;51&lt;/td&gt;
      &lt;td&gt;Laos&lt;/td&gt;
      &lt;td&gt;7&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;4&lt;/td&gt;
      &lt;td&gt;Azerbaijan&lt;/td&gt;
      &lt;td&gt;2&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;3&lt;/td&gt;
      &lt;td&gt;Argentina&lt;/td&gt;
      &lt;td&gt;9&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;87&lt;/td&gt;
      &lt;td&gt;Swaziland&lt;/td&gt;
      &lt;td&gt;1&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;92&lt;/td&gt;
      &lt;td&gt;Tunisia&lt;/td&gt;
      &lt;td&gt;3&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;88&lt;/td&gt;
      &lt;td&gt;Syria&lt;/td&gt;
      &lt;td&gt;13&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;15&lt;/td&gt;
      &lt;td&gt;Chile&lt;/td&gt;
      &lt;td&gt;1&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;20&lt;/td&gt;
      &lt;td&gt;Costa Rica&lt;/td&gt;
      &lt;td&gt;2&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;80&lt;/td&gt;
      &lt;td&gt;Sao Tome and Principe&lt;/td&gt;
      &lt;td&gt;2&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;21&lt;/td&gt;
      &lt;td&gt;Cote d’Ivoire&lt;/td&gt;
      &lt;td&gt;2&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;64&lt;/td&gt;
      &lt;td&gt;Niger&lt;/td&gt;
      &lt;td&gt;4&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;102&lt;/td&gt;
      &lt;td&gt;Zimbabwe&lt;/td&gt;
      &lt;td&gt;1&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;94&lt;/td&gt;
      &lt;td&gt;USSR&lt;/td&gt;
      &lt;td&gt;2&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;63&lt;/td&gt;
      &lt;td&gt;Nicaragua&lt;/td&gt;
      &lt;td&gt;2&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;This looks much better. Let’s make sure we don’t have any missing values.&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;country_coups&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;isna&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;index&lt;/th&gt;
      &lt;th&gt;country&lt;/th&gt;
      &lt;th&gt;Number_of_coups&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;0&lt;/td&gt;
      &lt;td&gt;false&lt;/td&gt;
      &lt;td&gt;false&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;1&lt;/td&gt;
      &lt;td&gt;false&lt;/td&gt;
      &lt;td&gt;false&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;2&lt;/td&gt;
      &lt;td&gt;false&lt;/td&gt;
      &lt;td&gt;false&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;3&lt;/td&gt;
      &lt;td&gt;false&lt;/td&gt;
      &lt;td&gt;false&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;4&lt;/td&gt;
      &lt;td&gt;false&lt;/td&gt;
      &lt;td&gt;false&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;5&lt;/td&gt;
      &lt;td&gt;false&lt;/td&gt;
      &lt;td&gt;false&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;100&lt;/td&gt;
      &lt;td&gt;false&lt;/td&gt;
      &lt;td&gt;false&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;101&lt;/td&gt;
      &lt;td&gt;false&lt;/td&gt;
      &lt;td&gt;false&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;102&lt;/td&gt;
      &lt;td&gt;false&lt;/td&gt;
      &lt;td&gt;false&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;No missing values.&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;#Checking for duplicate values
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;country_coups&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;duplicated&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;().&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;sum&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;np.int64(0)&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Good, no missing values or duplicates.&lt;/p&gt;

&lt;p&gt;Next, we get a list of oil-producing countries. I have an R script that is short and sweet for scraping Wikipedia data.&lt;/p&gt;

&lt;div class=&quot;language-R highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# load the rvest library&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;library&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;rvest&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;oilurl&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;read_html&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;https://en.wikipedia.org/
wiki/List_of_countries_by_proven_oil_reserves&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;

&lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;# extract a list of tables in this page&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;oil_tables&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;html_table&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;oilurl&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;oil_tables&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;

&lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;# select the right table&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;oil_countries&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;data.frame&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;oil_tables&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;m&quot;&gt;2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;])&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;oil_countries&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;getwd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;

&lt;/span&gt;&lt;span class=&quot;c1&quot;&gt;# save the table locally as a csv file&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;setwd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;C:/Users/me/coup&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;write.csv&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;oil_countries&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;oil_countries.csv&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;n&quot;&gt;row.names&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;w&quot;&gt; &lt;/span&gt;&lt;span class=&quot;kc&quot;&gt;TRUE&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;dim&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;oil_countries&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;w&quot;&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This yields a table that looks like this:&lt;/p&gt;

&lt;figure&gt;
  &lt;img alt=&quot;Oil production data&quot; src=&quot;/images/oil_production.png&quot; /&gt;
  &lt;figcaption&gt;
   Oil Production Data
  &lt;/figcaption&gt;
&lt;/figure&gt;

&lt;p&gt;We do not need the production capacities, just a list of oil-producing nations. We will drop all the extra columns and create a column ‘oil_producing’ which we will fill with 1 for an oil-producing nation and 0 for the others.&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;oil_countries&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;drop&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;([&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Oil_production&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; 
&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Years_of_production_in_reserve&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;],&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;axis&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;inplace&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;True&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;oil_countries&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;oil_producing&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;oil_countries&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;to_csv&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;/content/drive/MyDrive/oil_countries.csv&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;oil_countries&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;sample&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;index&lt;/th&gt;
      &lt;th&gt;country&lt;/th&gt;
      &lt;th&gt;oil_producing&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;34&lt;/td&gt;
      &lt;td&gt;Australia&lt;/td&gt;
      &lt;td&gt;1&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;20&lt;/td&gt;
      &lt;td&gt;Azerbaijan&lt;/td&gt;
      &lt;td&gt;1&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;90&lt;/td&gt;
      &lt;td&gt;Belize&lt;/td&gt;
      &lt;td&gt;1&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;24&lt;/td&gt;
      &lt;td&gt;India&lt;/td&gt;
      &lt;td&gt;1&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;75&lt;/td&gt;
      &lt;td&gt;Japan&lt;/td&gt;
      &lt;td&gt;1&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;On to the Gini Index. To get the data, I did the same thing as the oil-producing countries’ data and loaded it into my notebook. This data also came with population data, which I will leave in there.&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# Data on inequality as measured by the Gini index 
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;gini_index&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;read_csv&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sa&quot;&gt;r&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;/content/drive/MyDrive/gini.csv&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;gini_index&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;head&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;index&lt;/th&gt;
      &lt;th&gt;population&lt;/th&gt;
      &lt;th&gt;country&lt;/th&gt;
      &lt;th&gt;gini_index&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;11&lt;/td&gt;
      &lt;td&gt;52085168&lt;/td&gt;
      &lt;td&gt;Colombia&lt;/td&gt;
      &lt;td&gt;51.3&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;71&lt;/td&gt;
      &lt;td&gt;1425671352&lt;/td&gt;
      &lt;td&gt;China&lt;/td&gt;
      &lt;td&gt;38.5&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;75&lt;/td&gt;
      &lt;td&gt;334506&lt;/td&gt;
      &lt;td&gt;Vanuatu&lt;/td&gt;
      &lt;td&gt;37.6&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;94&lt;/td&gt;
      &lt;td&gt;654768&lt;/td&gt;
      &lt;td&gt;Luxembourg&lt;/td&gt;
      &lt;td&gt;35.4&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;117&lt;/td&gt;
      &lt;td&gt;3210847&lt;/td&gt;
      &lt;td&gt;Bosnia and Herzegovina&lt;/td&gt;
      &lt;td&gt;33.0&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;Next was the democracy index data and I got it the same way as the others. Here is a sample.&lt;/p&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;index&lt;/th&gt;
      &lt;th&gt;country&lt;/th&gt;
      &lt;th&gt;democracy_index&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;0&lt;/td&gt;
      &lt;td&gt;Afghanistan&lt;/td&gt;
      &lt;td&gt;0.32&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;1&lt;/td&gt;
      &lt;td&gt;Albania&lt;/td&gt;
      &lt;td&gt;6.41&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;2&lt;/td&gt;
      &lt;td&gt;Algeria&lt;/td&gt;
      &lt;td&gt;3.66&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;3&lt;/td&gt;
      &lt;td&gt;Angola&lt;/td&gt;
      &lt;td&gt;3.96&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;4&lt;/td&gt;
      &lt;td&gt;Argentina&lt;/td&gt;
      &lt;td&gt;6.85&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;Finally, I got a list of all countries in the world to compare against. Looking at all these disparate datasets:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Democracy index data has 167 countries.&lt;/li&gt;
  &lt;li&gt;All countries dataset has 192 countries.&lt;/li&gt;
  &lt;li&gt;Gini index dataset has 177 countries.&lt;/li&gt;
  &lt;li&gt;Oil-producing nations dataset has 105 countries.&lt;/li&gt;
  &lt;li&gt;How do we reconcile all this data?&lt;/li&gt;
  &lt;li&gt;We will use the democracy data as our base; countries not in there will be dropped.&lt;/li&gt;
  &lt;li&gt;Oil data will be used in totality, as this is just the list of countries which produce oil; all others do not.&lt;/li&gt;
  &lt;li&gt;We can join all these dataframes by using the country columns, then drop all the null values.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I combined these datasets using pandas merge and an outer join on the countries column as exemplified below:&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;n&quot;&gt;combo&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;merge&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;demo_index&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;all_countries&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; 
&lt;span class=&quot;n&quot;&gt;on&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;country&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;how&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;outer&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;combo&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;sample&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;10&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;table&gt;
  &lt;thead&gt;
    &lt;tr&gt;
      &lt;th&gt;index&lt;/th&gt;
      &lt;th&gt;country&lt;/th&gt;
      &lt;th&gt;democracy_index&lt;/th&gt;
    &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
      &lt;td&gt;13&lt;/td&gt;
      &lt;td&gt;Barbados&lt;/td&gt;
      &lt;td&gt;NaN&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;75&lt;/td&gt;
      &lt;td&gt;Guinea&lt;/td&gt;
      &lt;td&gt;2.32&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;156&lt;/td&gt;
      &lt;td&gt;San Marino&lt;/td&gt;
      &lt;td&gt;NaN&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;40&lt;/td&gt;
      &lt;td&gt;Costa Rica&lt;/td&gt;
      &lt;td&gt;8.29&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;158&lt;/td&gt;
      &lt;td&gt;Saudi Arabia&lt;/td&gt;
      &lt;td&gt;2.08&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;52&lt;/td&gt;
      &lt;td&gt;Dominican Republic&lt;/td&gt;
      &lt;td&gt;6.39&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;146&lt;/td&gt;
      &lt;td&gt;Portugal&lt;/td&gt;
      &lt;td&gt;7.95&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;62&lt;/td&gt;
      &lt;td&gt;Fiji&lt;/td&gt;
      &lt;td&gt;5.55&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;141&lt;/td&gt;
      &lt;td&gt;Papua New Guinea&lt;/td&gt;
      &lt;td&gt;5.97&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
      &lt;td&gt;154&lt;/td&gt;
      &lt;td&gt;Saint Lucia&lt;/td&gt;
      &lt;td&gt;NaN&lt;/td&gt;
    &lt;/tr&gt;
  &lt;/tbody&gt;
&lt;/table&gt;

&lt;p&gt;After combining all of these datasets, this is what we have:&lt;/p&gt;

&lt;figure&gt;
  &lt;img alt=&quot;Final data&quot; src=&quot;/images/final_data.png&quot; /&gt;
  &lt;figcaption&gt;
   Final Dataset
  &lt;/figcaption&gt;
&lt;/figure&gt;

&lt;p&gt;The NaN values in the ‘oil_producing’ and ‘Number_of_coups’ columns were filled with 0 to represent no oil or no coup. All other rows with NaN values were dropped.&lt;/p&gt;

&lt;h2 id=&quot;modeling&quot;&gt;Modeling&lt;/h2&gt;

&lt;h3 id=&quot;random-forests&quot;&gt;Random Forests&lt;/h3&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# select features and target from the dataset
# features
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;X&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;final&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;loc&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[:,[&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;democracy_index&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;oil_producing&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;population&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;gini_index&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Number_of_coups&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;gdp_per_capita&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]]&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;# target
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;y&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;final&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;coup&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# create the train and test split
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;X_train&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;X_test&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_train&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_test&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;train_test_split&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;X&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt;
 &lt;span class=&quot;n&quot;&gt;test_size&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.3&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;#import random forest model
&lt;/span&gt;&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sklearn.ensemble&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;RandomForestClassifier&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# create a Gaussian classifier
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;clf&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;RandomForestClassifier&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;n_estimators&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# Train the model using the training data
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;clf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;fit&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;X_train&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_train&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;y_predicted&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;clf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;predict&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;X_test&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# model accuracy, how often is the classifier correct?
&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Accuracy: &lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;metrics&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;accuracy_score&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;y_test&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; 
&lt;span class=&quot;n&quot;&gt;y_predicted&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Accuracy:  1.0&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;An accuracy of 1 means our model is perfect, but it could just be overfitting. So let’s try using cross-validation.&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# Using StratifiedKFold
&lt;/span&gt;&lt;span class=&quot;kn&quot;&gt;from&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;sklearn.model_selection&lt;/span&gt; &lt;span class=&quot;kn&quot;&gt;import&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;StratifiedKFold&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; 
&lt;span class=&quot;n&quot;&gt;cross_val_score&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# create train/test split - stratified
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;X_train&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;X_test&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_train&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_test&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;train_test_split&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;n&quot;&gt;X&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;test_size&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.2&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;stratify&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;random_state&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;42&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# set up StratifiedKFold CV for training set
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;skf&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;StratifiedKFold&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;n_splits&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;shuffle&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;True&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; 
&lt;span class=&quot;n&quot;&gt;random_state&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;42&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# create model and run data
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;rf_model&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;RandomForestClassifier&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;random_state&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;42&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;cv_scores&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nf&quot;&gt;cross_val_score&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;rf_model&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;X_train&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; 
&lt;span class=&quot;n&quot;&gt;y_train&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cv&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;skf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;scoring&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;accuracy&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;nf&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;CV accuracy per fold: &lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cv_scores&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;nf&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Mean CV accuracy: &lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;cv_scores&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;mean&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;())&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# fit model on full training set
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;rf_model&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;fit&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;X_train&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_train&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;

&lt;span class=&quot;c1&quot;&gt;# Evaluate on holdout test set
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;test_accuracy&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;rf_model&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;score&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;X_test&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y_test&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;nf&quot;&gt;print&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Holdout test accuracy:&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;test_accuracy&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;CV accuracy per fold:  [0.96 1.   1.   1.   1.  ]&lt;/code&gt;&lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Mean CV accuracy:  0.992&lt;/code&gt;&lt;br /&gt;
&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Holdout test accuracy: 1.0&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;We get the same high accuracy even with cross-validation. Since the number of countries in the world is limited, we can increase the complexity of the data by increasing the columns to capture other dimensions of countries like the unemployment rate, the youth population, the average income, the economic complexity, the happiness index, the UN human development index, trade data, geographical data, poverty data etc.&lt;/p&gt;

&lt;h3 id=&quot;feature-importance&quot;&gt;Feature Importance&lt;/h3&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# feature importance on the basic random forest model
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;feature_imp&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;pd&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nc&quot;&gt;Series&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;clf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;feature_importances_&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; 
&lt;span class=&quot;n&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;X&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;columns&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;).&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;sort_values&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;ascending&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;bp&quot;&gt;False&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;sns&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;barplot&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;x&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;feature_imp&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;n&quot;&gt;y&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;feature_imp&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;index&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;c1&quot;&gt;# Add labels to your graph
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;xlabel&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Feature Importance Score&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;ylabel&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Features&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;Visualizing Important Features&lt;/span&gt;&lt;span class=&quot;sh&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;legend&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;span class=&quot;n&quot;&gt;plt&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;show&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;figure&gt;
  &lt;img alt=&quot;Feature importance for the basic random forest model&quot; src=&quot;/images/basic_model_feature_importance.png&quot; /&gt;
  &lt;figcaption&gt;
   Feature importance for the basic random forest model
  &lt;/figcaption&gt;
&lt;/figure&gt;

&lt;ul&gt;
  &lt;li&gt;From the bar chart above, the most important predictor for a coup is a history of previous coups. Remember at the beginning of this post when I said that the foiled Kenya Air Force coup of August 1982 would be important? This is it. The fact that the coup was unsuccessful meant that the chance of illegal and probably violent regime change was greatly reduced.&lt;/li&gt;
  &lt;li&gt;The GDP per capita is the next most important factor, and it makes sense; the poorer a country is, the more likely its population is to be dissatisfied enough with the current regime to attempt a violent takeover.* Next is the democracy levels, which look obvious but are of lower importance. You would think that it would be a much more important factor, but just look at communist China, 2.11 on the democracy index, but never had a coup, and they are definitely getting richer (GDP per capita of $18820.51 in 2023).&lt;/li&gt;
  &lt;li&gt;The wealth gap, as measured by the Gini index, is also surprisingly not that big a factor.&lt;/li&gt;
  &lt;li&gt;The presence of natural resources is the lowest predictor, which seems to go against the literature; it seems you can’t always trust the machines.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let us see what the cross-validated model has to say about feature importance.&lt;/p&gt;

&lt;figure&gt;
  &lt;img alt=&quot;Feature importance for the cross-validated random forest model&quot; src=&quot;/images/cross_validated_model_feature_importance.png&quot; /&gt;
  &lt;figcaption&gt;
   Feature importance for the cross-validated random forest model
  &lt;/figcaption&gt;
&lt;/figure&gt;

&lt;ul&gt;
  &lt;li&gt;Here we see a similar order, the top three most important factors are a history of coups, the country’s economic conditions and the democracy level. The presence of natural resources also features last here.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To predict whether a country may experience a coup, we need to pass its democracy index, whether it is oil-producing (1) or not (0), population, Gini index, number of coups, and GDP per capita in that order, to this prediction function.&lt;/p&gt;

&lt;div class=&quot;language-python highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&lt;span class=&quot;c1&quot;&gt;# example prediction
&lt;/span&gt;&lt;span class=&quot;n&quot;&gt;clf&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;predict&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;([[&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;0.1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;4569875&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;64.5&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;mf&quot;&gt;956.32&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;array([1])&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This predicts a coup in this fictitious country. Not surprising considering its abysmal democracy index, history of a coup and the low GDP per capita.&lt;/p&gt;

&lt;p&gt;I will try this data on a linear regressor and a neural net to see how it plays out.&lt;/p&gt;

          </description>
          <pubDate>Mon, 18 Aug 2025 17:30:25 +0300</pubDate>
          <link>https://www.kibetkoech.com/writing/machine-learning-model-to-predict-coups/</link>
          <guid isPermaLink="true">https://www.kibetkoech.com/writing/machine-learning-model-to-predict-coups/</guid>
          
          <category>machine-learning</category>
          
          <category>politics</category>
          
          <category>development</category>
          
          <category>democracy</category>
          
          <category>economics</category>
          
          
          <category>coup</category>
          
          <category>instability</category>
          
          <category>politics</category>
          
          <category>development</category>
          
          <category>democracy</category>
          
          <category>machine_learning</category>
          
          <category>economics</category>
          
        </item>
      
    
      
        <item>
          
            <title>Quotes In PHP</title>
          
          <author> (Kibet Koech)</author>
          <description>
            &lt;p&gt;Every day you learn something new in PHP. For example, did you know the difference between the single quote &lt;strong&gt;‘&lt;/strong&gt; and the double quote &lt;strong&gt;“&lt;/strong&gt;?&lt;/p&gt;

&lt;p&gt;When you use single quotes, the string will be taken exactly as it is but if you use double quotes, the string will be evaluated e.g.,&lt;/p&gt;

&lt;div class=&quot;language-php highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;
&lt;span class=&quot;nv&quot;&gt;$value&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;100&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;The value is $value&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// The value is $value` &lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s2&quot;&gt;&quot;The value is &lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$value&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// The value is 100. The &lt;/span&gt;
                  &lt;span class=&quot;c1&quot;&gt;// {} are optional but nice to have &lt;/span&gt;
                  &lt;span class=&quot;c1&quot;&gt;// for readability&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This nuance is especially important when writing SQL statements that have variables (a bad habit, by the way, you should be using &lt;a href=&quot;https://www.kibetkoech.com/php/sql/security/webdev/SQL-injection&quot;&gt;prepared statements&lt;/a&gt;). So be careful and always wrap your SQL statements in double quotes when you are passing variables, e.g.,,&lt;/p&gt;

&lt;div class=&quot;language-php highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;
&lt;span class=&quot;nv&quot;&gt;$sql&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$connection&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;query&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&quot;SELECT * FROM users 
WHERE email=&apos;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$email&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&apos;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// will pass actual &lt;/span&gt;
                          &lt;span class=&quot;c1&quot;&gt;// variable held by $email&lt;/span&gt;

&lt;span class=&quot;nv&quot;&gt;$sql&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$connection&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;query&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;SELECT * FROM users 
WHERE email=$email&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt; &lt;span class=&quot;c1&quot;&gt;// will pass $email which &lt;/span&gt;
                      &lt;span class=&quot;c1&quot;&gt;// will return an error when you &lt;/span&gt;
                      &lt;span class=&quot;c1&quot;&gt;// need to parse the query result&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

          </description>
          <pubDate>Sun, 23 Feb 2025 17:58:25 +0300</pubDate>
          <link>https://www.kibetkoech.com/writing/quotes-in-php/</link>
          <guid isPermaLink="true">https://www.kibetkoech.com/writing/quotes-in-php/</guid>
          
          <category>php</category>
          
          <category>sql</category>
          
          <category>web-development</category>
          
          
          <category>php</category>
          
          <category>sql</category>
          
          <category>quotes</category>
          
          <category>webdev</category>
          
        </item>
      
    
      
        <item>
          
            <title>SQL Injection</title>
          
          <author> (Kibet Koech)</author>
          <description>
            &lt;p&gt;SQL injection is when a malicious user surreptitiously introduces malicious SQL statements into your code and can potentially destroy your application or commandeer it for their own nefarious purposes. These malicious statements are usually ingested from user input fields e.g. email address, name and other fields where user input is allowed. No developer wants this so let’s see how we can defend against this.&lt;/p&gt;

&lt;p&gt;We’ll build a simple system to demonstrate this and then learn how to mitigate it. I created a simple database named ‘sql_injection’ with two tables ‘users’ and ‘posts’. The &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;users&lt;/code&gt; table has an ID field and an email field and I inserted the email ‘me@me.com’. Populate your database with a few emails of your choice.&lt;br /&gt;
Our system will have an email field where a user can enter an email address and the system will determine if the email exists or not and display a helpful message to the user.&lt;/p&gt;

&lt;p&gt;Here is our HTML form:&lt;/p&gt;

&lt;div class=&quot;language-html highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;
&lt;span class=&quot;cp&quot;&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;html&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;lang=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;en&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;h2&amp;gt;&lt;/span&gt;SQL Injection Demo&lt;span class=&quot;nt&quot;&gt;&amp;lt;/h2&amp;gt;&lt;/span&gt;

&lt;span class=&quot;nt&quot;&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
   &lt;span class=&quot;nt&quot;&gt;&amp;lt;form&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;action=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;method=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;post&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;input&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;type=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;text&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;email&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&amp;lt;br&amp;gt;&lt;/span&gt;
    &lt;span class=&quot;nt&quot;&gt;&amp;lt;input&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;type=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;submit&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;submit&quot;&lt;/span&gt; 
            &lt;span class=&quot;na&quot;&gt;value=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Check Email&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
   &lt;span class=&quot;nt&quot;&gt;&amp;lt;/form&amp;gt;&lt;/span&gt;

&lt;span class=&quot;nt&quot;&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;

&lt;span class=&quot;nt&quot;&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;This is the browser output:&lt;/p&gt;

&lt;figure&gt;
  &lt;img alt=&quot;sql injection demo&quot; src=&quot;/images/Picture1.png&quot; /&gt;
  &lt;figcaption&gt;
   Form output
  &lt;/figcaption&gt;
&lt;/figure&gt;

&lt;p&gt;Now we add PHP code to read the database and echo an appropriate output.&lt;/p&gt;

&lt;div class=&quot;language-php highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;
&lt;span class=&quot;cp&quot;&gt;&amp;lt;?php&lt;/span&gt;  
&lt;span class=&quot;c1&quot;&gt;// create a PDO connection&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$host&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;localhost&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$username&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;root&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$password&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
&lt;span class=&quot;nv&quot;&gt;$dbname&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;sql_injection&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;

&lt;span class=&quot;nv&quot;&gt;$connection&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;new&lt;/span&gt; &lt;span class=&quot;nc&quot;&gt;PDO&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;mysql:host=&apos;&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$host&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;;
              dbname=&apos;&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$dbname&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$username&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$password&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;isset&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$_POST&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;email&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]))&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
   &lt;span class=&quot;nv&quot;&gt;$email&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$_POST&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;email&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;];&lt;/span&gt;
   &lt;span class=&quot;nv&quot;&gt;$sql&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$connection&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;query&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
        &lt;span class=&quot;s2&quot;&gt;&quot;SELECT * FROM users WHERE email=&apos;&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$email&lt;/span&gt;&lt;span class=&quot;si&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;s2&quot;&gt;&apos;&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;

   &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$sql&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;rowCount&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
       &lt;span class=&quot;k&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;Your email exists: &apos;&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$email&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
   &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
       &lt;span class=&quot;k&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;This email does not exist.&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
   &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;  
&lt;span class=&quot;cp&quot;&gt;?&amp;gt;&lt;/span&gt;

&lt;span class=&quot;cp&quot;&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;html&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;lang=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;en&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
&lt;span class=&quot;nt&quot;&gt;&amp;lt;h2&amp;gt;&lt;/span&gt;SQL Injection Demo&lt;span class=&quot;nt&quot;&gt;&amp;lt;/h2&amp;gt;&lt;/span&gt;

&lt;span class=&quot;nt&quot;&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
  &lt;span class=&quot;nt&quot;&gt;&amp;lt;form&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;action=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;method=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;post&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;
   &lt;span class=&quot;nt&quot;&gt;&amp;lt;input&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;type=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;text&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;email&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&amp;lt;br&amp;gt;&lt;/span&gt;
   &lt;span class=&quot;nt&quot;&gt;&amp;lt;input&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;type=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;submit&quot;&lt;/span&gt; &lt;span class=&quot;na&quot;&gt;name=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;submit&quot;&lt;/span&gt;
                 &lt;span class=&quot;na&quot;&gt;value=&lt;/span&gt;&lt;span class=&quot;s&quot;&gt;&quot;Check Email&quot;&lt;/span&gt;&lt;span class=&quot;nt&quot;&gt;&amp;gt;&lt;/span&gt;

  &lt;span class=&quot;nt&quot;&gt;&amp;lt;/form&amp;gt;&lt;/span&gt;

&lt;span class=&quot;nt&quot;&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;

&lt;span class=&quot;nt&quot;&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;Now if we enter the valid email address into the browser we get the following correct response:&lt;/p&gt;

&lt;figure&gt;
  &lt;img alt=&quot;sql injection demo&quot; src=&quot;/images/Picture2.png&quot; /&gt;
  &lt;figcaption&gt;
   Correct email output
  &lt;/figcaption&gt;
&lt;/figure&gt;

&lt;p&gt;If we enter the wrong email address this is the response we get:&lt;/p&gt;

&lt;figure&gt;
  &lt;img alt=&quot;sql injection demo&quot; src=&quot;/images/Picture3.png&quot; /&gt;
  &lt;figcaption&gt;
   Incorrect email output
  &lt;/figcaption&gt;
&lt;/figure&gt;

&lt;p&gt;Now let’s have a bit of fun with some SQL injection, but first, here is what my database looks like:&lt;/p&gt;

&lt;figure&gt;
  &lt;img alt=&quot;sql injection demo&quot; src=&quot;/images/Picture4.png&quot; /&gt;
  &lt;figcaption&gt;
   My database
  &lt;/figcaption&gt;
&lt;/figure&gt;

&lt;p&gt;We will perform a simple injection to delete the posts table from the database using the following string in the input text field: &lt;strong&gt;‘;DROP TABLE posts;–‘&lt;/strong&gt; rather than inputting a legitimate email address.&lt;/p&gt;

&lt;figure&gt;
  &lt;img alt=&quot;sql injection demo&quot; src=&quot;/images/Picture5.png&quot; /&gt;
  &lt;figcaption&gt;
   Injection
  &lt;/figcaption&gt;
&lt;/figure&gt;

&lt;p&gt;This will effectively make our SQL query look like this:&lt;br /&gt;
&lt;strong&gt;SELECT * FROM users WHERE email=’;DROP TABLE posts;–’&lt;/strong&gt;&lt;br /&gt;
When we click the button and this query runs it will delete our ‘posts’ table!&lt;/p&gt;

&lt;figure&gt;
  &lt;img alt=&quot;sql injection demo&quot; src=&quot;/images/Picture6.png&quot; /&gt;
  &lt;figcaption&gt;
   Injection in the database
  &lt;/figcaption&gt;
&lt;/figure&gt;

&lt;p&gt;Let’s examine the injected statement in some detail:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;The semicolon (;) symbol usually serves as an indicator of the end of the SQL statement. It is unnecessary, but if you have multiple statements that you want to execute in one query, then you will need to use it and that is why we added it to the beginning and end of our injected payload.&lt;/li&gt;
  &lt;li&gt;The double hyphen (–) is a SQL symbol for an inline comment i.e. anything after this symbol is treated as a comment and thus ignored. We added it to our payload to ignore whatever comes after.&lt;/li&gt;
  &lt;li&gt;As for getting the table name correct, this is where an attacker needs a bit of luck, they can keep guessing table names until they get it right. If this was a blog website, there’s a good chance we have a table named posts, right?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Do you see how simple yet powerful this attack is? A competent attacker will not just delete a table, they will gain root access to your database and application and can cause some serious damage.&lt;/p&gt;

&lt;p&gt;We all know and love our mysql_query() function, she’s a simple girl but remember, she has a thing for hackers and she will invite them in any time. Be wary of her shy smiles and simple execution methods.&lt;/p&gt;

&lt;p&gt;We mitigate against this kind of attack by using prepared statements. I cannot stress this enough, if you are going to be using some variable in a SQL statement you MUST use prepared statements. I will use PDO prepared statements but you should know you can also use MySQL prepared statements. Here is the modified code:&lt;/p&gt;

&lt;div class=&quot;language-php highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;
&lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;k&quot;&gt;isset&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$_POST&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;email&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;]))&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
   &lt;span class=&quot;nv&quot;&gt;$email&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$_POST&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;&apos;email&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;];&lt;/span&gt;
   &lt;span class=&quot;nv&quot;&gt;$sql&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$connection&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;prepare&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;
    &lt;span class=&quot;s2&quot;&gt;&quot;SELECT * FROM users WHERE email=?&quot;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;
   &lt;span class=&quot;nv&quot;&gt;$sql&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;bindParam&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;mi&quot;&gt;1&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;nv&quot;&gt;$email&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;);&lt;/span&gt;  
   &lt;span class=&quot;nv&quot;&gt;$sql&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;execute&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;();&lt;/span&gt;

   &lt;span class=&quot;k&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$sql&lt;/span&gt;&lt;span class=&quot;o&quot;&gt;-&amp;gt;&lt;/span&gt;&lt;span class=&quot;nf&quot;&gt;rowCount&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;()&lt;/span&gt; &lt;span class=&quot;o&quot;&gt;&amp;gt;&lt;/span&gt; &lt;span class=&quot;mi&quot;&gt;0&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
       &lt;span class=&quot;k&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;Your email exists: &apos;&lt;/span&gt;&lt;span class=&quot;mf&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;nv&quot;&gt;$email&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
   &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; &lt;span class=&quot;k&quot;&gt;else&lt;/span&gt; &lt;span class=&quot;p&quot;&gt;{&lt;/span&gt;
       &lt;span class=&quot;k&quot;&gt;echo&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;&apos;This email does not exist.&apos;&lt;/span&gt;&lt;span class=&quot;p&quot;&gt;;&lt;/span&gt;
   &lt;span class=&quot;p&quot;&gt;}&lt;/span&gt; 
&lt;span class=&quot;p&quot;&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;/div&gt;

&lt;p&gt;We use a placeholder (&lt;strong&gt;?&lt;/strong&gt;) in place of the actual variable in the SQL statement, prepare the statement, bind the actual parameter, and finally execute it. This allows us to mitigate against SQL injection attacks.&lt;/p&gt;

          </description>
          <pubDate>Thu, 20 Feb 2025 17:30:25 +0300</pubDate>
          <link>https://www.kibetkoech.com/writing/sql-injection/</link>
          <guid isPermaLink="true">https://www.kibetkoech.com/writing/sql-injection/</guid>
          
          <category>php</category>
          
          <category>sql</category>
          
          <category>security</category>
          
          <category>web-development</category>
          
          
          <category>php</category>
          
          <category>sql</category>
          
          <category>security</category>
          
          <category>webdev</category>
          
        </item>
      
    
      
        <item>
          
            <title>Should AI Make Moral Decisions?</title>
          
          <author> (Kibet Koech)</author>
          <description>
            &lt;p&gt;Many years ago when I was in Class 6, our town’s first major supermarket opened. It was on my way home from school and it had everything in the world, or so I thought. I would wander in there any chance I got and would turn my friends at school green with envy with tales of my ‘adventures’ there. One day my classmate, Mike, gave me 50 shillings and asked me to buy him a bottle of glue from the supermarket. As usual, I passed through the supermarket but I forgot all about the glue while admiring the toys.&lt;/p&gt;

&lt;p&gt;The next day I apologised to Mike and assured him that I would get it to him the next day. That evening I went straight home to get the money from the shorts I had on the previous day only to find my mother breathing fire and pacing about the house. As soon as she saw me she demanded to know when I had become a thief. I was puzzled for a moment and Mom, deciding that I was attempting to stall then lie, followed up the question with a couple of vicious slaps to my person. She had a mean backhand that would extract instant confessions from me. I fell back still baffled with what was going on. She stood over me and waved a 50 shilling note in my face and demanded again when I had become a thief. Then I understood it all in a flash. Since I had forgotten the note in yesterday’s shorts she must’ve found them when doing the laundry and instantly concluded that I had stolen it. I started explaining to her that my friend Mike had asked me to buy him glue but before I could finish, another slap cut me off. By this time my brother and aunt came into the room wondering what was going on. Mom shut the door and proceeded to give me the whipping of my life! I begged and pleaded with her but she did not for a second believe my story and instead declared that she would not raise a thief. After her fury abated, I was soaked in tears and stinging all over from the beating.&lt;/p&gt;

&lt;p&gt;The next day at school I still did not have any glue for Mike and he was beginning to get impatient and a little suspicious. I was between a rock and the deep blue sea. I had to resolve this problem quickly to avoid it escalating into a school issue. That evening, I did not waste time after school, I went straight home, opened Mom’s purse, and took Ksh. 50 and went to the supermarket. I got the glue but I also had a startling realisation; the Ksh. 50 note was wrapped around a Ksh. 200 note! Now I had a proper moral dilemma, what do I do with this extra money? I decided to spend it. I bought some sweets, oranges and my very first comic book, ‘The X-Men’.&lt;/p&gt;

&lt;p&gt;I delivered the glue to Mike the next day, and my mother never found out that I had stolen 200 shillings from her. As far as I was concerned, this was compensation for the unfair thrashing I had received the previous day. Young as I was, I understood the principle of double jeopardy.&lt;/p&gt;

&lt;h2 id=&quot;analysis&quot;&gt;Analysis&lt;/h2&gt;

&lt;p&gt;We judge the morality of a decision according to 3 main elements:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Moral object&lt;/li&gt;
  &lt;li&gt;Intention&lt;/li&gt;
  &lt;li&gt;Circumstances&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When I ‘stole’ back the Ksh. 50, the moral objective of the decision wasn’t sound; I was stealing so right off the bat this was immoral. Secondly, when I discovered that I had taken more than was due I should have at least returned the Ksh. 200 but did I? No, I decided that I was owed damages and gladly spent my ‘compensation’. Besides, movies have taught me that criminals get caught when they return to the scene of the crime. I should have been a lawyer.&lt;/p&gt;

&lt;p&gt;I intended to ‘steal’ back the Ksh. 50 to get Mike’s glue while avoiding an uncomfortable encounter with Mom. My intentions were good, but we all know that the road to hell is paved with good intentions. For example, King Saul spared King Agag (1 Samuel 15) and the best of the Amalekite sheep and cattle so that he could later sacrifice them to God despite being under direct orders to destroy them all. God rejected his sacrifice because of the blatant disobedience. His intention was good but the moral object, disobedience, wasn’t.&lt;/p&gt;

&lt;p&gt;The circumstances surrounding my moral dilemma were strange. My mother’s reading of the situation was wrong and unforeseeable. Talking to her yielded nothing but I needed to make amends without causing further trouble. Later in life when I recalled this incident to Mom I understood her position. Back then my father had just passed on leaving her as the sole breadwinner of the family. Then came the infamous Structural Adjustment Program (SAP) by the IMF. It came to our lives in the form of retrenchment for Mum at the worst possible time. They say when it rains, it pours. Mom was under tremendous pressure and my young mind sensed that presenting my case would only yield more whipping.&lt;/p&gt;

&lt;p&gt;Was my decision moral? At the time and for a long time afterwards, it seemed so to me. I was only getting back what was mine, and the extra money was just compensation. However, using the three elements of morality, it wasn’t a moral decision because it failed the test of morality. I stole the 250 shillings, and nothing else makes it okay. Maybe I should have waited for Mom to calm down and then spoken to her, but hindsight is 20/20.&lt;/p&gt;

&lt;p&gt;In 1945, right after the fall of Germany, the US turned its full attention to Japan, a relentless and unyielding enemy who never surrendered and fought for every inch of ground to the last man. The path to victory for the Americans would be paved with the blood of millions of soldiers. It is with this information that President Truman decided to drop 2 atomic bombs on the Japanese. The bombs instantly killed more than 200,000 people and the radiation after-effects are still being felt to date.&lt;/p&gt;

&lt;p&gt;The highest good is existence and life. President Truman decided that losing 1 million soldiers was worse than killing the 200,000 Japanese. He intended to preserve as much life as he could. The moral object was to win the war in the Pacific as quickly as possible and with as little death as possible. However, the bomb was also dropped as a demonstration of the might of the USA which isn’t moral. The circumstances surrounding the decision were that the world had been embroiled in a devastating war for about 5 years and it needed to end quickly for it threatened to consume the world. For these reasons, I think this was a moral decision by President Truman. I have also come to realise that &lt;strong&gt;&lt;em&gt;the greater the scope of a leader, the more moral they have to be but paradoxically, the less likely that it is that the application of ideals will result in an optimal solution.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Fyodor Dostoevsky, the towering Russian writer, addressed the issue of morality in his book Crime and Punishment. The main character, Rodion Raskolnikov, a destitute university dropout, decides to murder a despicable pawnbroker who thrives on the affliction and poverty of the downtrodden. He rationalises that by killing her and taking her wealth, he will free himself from poverty and become magnanimous with the old woman’s money in service to humanity.&lt;/p&gt;

&lt;p&gt;As he is planning the practical aspects of this murder, his mind also seeks to justify the act. He decides that the good which will come from using her money justifies her murder. Once he kills her, however, his soul rebels. He is plagued with guilt, confusion and disgust and his previous intellectual justifications crumble as he confronts the consequences of the murder. His intentions are noble, to help his fellow men. His circumstances were dire, he was poor, bankrupt and out of school for lack of money and he had cut himself off from society and thus had no one to anchor him to reality. His moral object, however, to kill the old pawnbroker was morally objectionable and turned the whole thing sour. He ended up confessing his crime and taking his punishment to pacify his spirit.&lt;/p&gt;

&lt;p&gt;Thanos is a Titan in the Marvel Cinematic Universe. He is intelligent, strong-willed and capable. His mission in life is to bring about balance in the universe because he theorised that the problems prevalent in the universe, poverty and want, disease and crime all stemmed from overpopulation which placed a strain on the universe. So he went about killing half the population of any planet he visited. He wreaked untold havoc wherever he went all in the name of making the world a better place. Later, he discovered that the quickest path to this goal was to acquire the five infinity stones and thus have the power to instantly and indiscriminately kill half of the universe with just the snap of his fingers! Thanos was such a capable character that he succeeded in doing this. I remember feeling numb and confused as I left the theatre when I watched the movie. I was confused because at some level I understood his logic and agreed with him but my conscience kept bothering me that something was wrong with the decision. He intended to have a peaceful and just universe teeming with life but his moral object was to kill half the universe! This was a completely immoral decision and I suspect that this movie was deeper than most people suspect.&lt;/p&gt;

&lt;h2 id=&quot;reflection&quot;&gt;Reflection&lt;/h2&gt;

&lt;p&gt;Making a moral decision can be both quite simple or extremely difficult depending on the moral object, intention and the circumstances surrounding the decision. For example, what was I supposed to do about Mike’s Ksh. 50? Telling him that my mother took it would only result in a confrontation with Mike or a teacher at school and a long drawn-out investigation which would probably lead to more whipping for me. It certainly was easier to steal it back and that is how moral decisions generally present themselves, they are not easy, they require some moral fibre and the willingness to be misunderstood and even punished for making them.&lt;br /&gt;
Secondly, a moral decision requires alignment of all three elements. It has to be morally objective, have good intentions and suit the circumstances. Applying only logic and rhetoric to make a moral decision will result in lopsided decisions like Thanos’ decision to kill half the universe. A strong moral grounding, and a high moral quotient, are much more important than all the justifications one can come up with.&lt;br /&gt;
It is difficult enough for human beings to make moral decisions and we have the advantage of emotional depth as well as natural language to elucidate our thoughts and feelings. Codifying morality into artificial intelligence will be quite a feat but for now, I do not think we should let AI make any moral decisions, especially ones that have severe consequences.&lt;/p&gt;

          </description>
          <pubDate>Thu, 20 Feb 2025 09:06:37 +0300</pubDate>
          <link>https://www.kibetkoech.com/writing/should-ai-make-moral-decisions/</link>
          <guid isPermaLink="true">https://www.kibetkoech.com/writing/should-ai-make-moral-decisions/</guid>
          
          <category>ai</category>
          
          <category>psychology</category>
          
          <category>morality</category>
          
          <category>ethics</category>
          
          
          <category>ai</category>
          
          <category>psychology</category>
          
          <category>morality</category>
          
          <category>childhood</category>
          
        </item>
      
    
      
        <item>
          
            <title>The Kenyan Economy - A 10,000-Foot Overview</title>
          
          <author> (Kibet Koech)</author>
          <description>
            &lt;p&gt;Recently, I have become interested in how economies function and develop. To better understand this, I decided to take a closer look at Kenya’s economy, particularly regarding international trade. I discovered a useful visualisation website called &lt;a href=&quot;https://oec.world/en&quot;&gt;the Observatory of Economic Complexity&lt;/a&gt;. Looking at Kenya’s 2022 data, our figures are as follows:&lt;/p&gt;

&lt;h2 id=&quot;exports&quot;&gt;Exports&lt;/h2&gt;

&lt;figure&gt;
  &lt;img alt=&quot;Kenyan exports, 2022. Source OEC&quot; src=&quot;/images/Exports-2022---Click-to-Select-a-Product.png&quot; /&gt;
  &lt;figcaption&gt;
   Kenyan exports, 2022. Source OEC
  &lt;/figcaption&gt;
&lt;/figure&gt;

&lt;p&gt;As you can see, most of our exports are agricultural commodities subsequently processed in other countries. The refined petroleum and palm oil we export are just passing through the country to our landlocked neighbours.&lt;/p&gt;

&lt;p&gt;We have also been exporting titanium ore, again a raw material for many &lt;a href=&quot;https://en.wikipedia.org/wiki/Titanium_dioxide#Applications&quot;&gt;manufactured goods&lt;/a&gt; like paint pigment, food additives, sunscreen etc. In fact, did you know that 80% of our annual mineral revenue comes from this one mineral mined in Kwale? Unfortunately, we have mined it clean and Base Titanium, the mining company, is winding up operations (&lt;a href=&quot;https://african.business/2023/11/resources/what-next-for-kenyas-extractives-sector-after-base-titanium-exit&quot;&gt;link&lt;/a&gt;). So in one fell stroke, we will lose about $290 million from mineral exports. This is the curse of dependence on commodities.&lt;/p&gt;

&lt;h3 id=&quot;where-does-kenya-export&quot;&gt;Where Does Kenya Export?&lt;/h3&gt;

&lt;figure&gt;
  &lt;img alt=&quot;Kenyan export destination, 2022. Source OEC&quot; src=&quot;/images/Destinations-2022---Click-to-Select-a-Country.png&quot; /&gt;
  &lt;figcaption&gt;
   Kenyan export destination, 2022. Source OEC
  &lt;/figcaption&gt;
&lt;/figure&gt;

&lt;p&gt;The USA is our biggest customer, marginally edging out Uganda. Guess what we chiefly export to the USA? Clothes. 57% of our exports to the USA are clothes! We sell them new, high-quality clothes while we import second-hand clothes from them. Ironic, right? I wonder where we get the yarn, other materials, and clothing designs. Is it exclusively our local cotton and wool? Exclusively imported, or a mix of both?&lt;/p&gt;

&lt;figure&gt;
  &lt;img alt=&quot;Kenya exports to the USA, 2022. Source OEC&quot; src=&quot;/images/Exports-to-United-States-2022.png&quot; /&gt;
  &lt;figcaption&gt;
   Kenya exports to the USA, 2022. Source OEC
  &lt;/figcaption&gt;
&lt;/figure&gt;

&lt;p&gt;Since tea is our biggest export and the Middle East and Arab countries are our biggest customers, it should be of great interest what happens there. What do we as a nation know about Pakistan? We sell them about half of our tea, $534M worth. Has a sitting Pakistani head of state ever made an official visit to Kenya or vice versa? Remember &lt;a href=&quot;https://www.bbc.com/news/world-africa-63426794&quot;&gt;Arshad Sharif&lt;/a&gt;? The Pakistani journalist killed by Kenyan police in 2022? Did we take that killing seriously or did we take the Pakistanis round and round in circles hoping the heat would die down?&lt;/p&gt;

&lt;p&gt;Do we realize that stability in the Middle East means that they will have more money to spend on tea? In 2022, we exported well over $50 million worth of goat and sheep meat to the Middle East, and we have immense potential for much more. Why do we not take a keener interest in their affairs and our relationship with them? We focus so much on the West, but really, the African, Asian, and Middle Eastern countries are our best customers.&lt;/p&gt;

&lt;p&gt;How about our neighbours? East Africa and the rest of Africa take up 40% of our exports! Their prosperity is our prosperity. We should be driving the integration of East and Central Africa to stimulate trade and the movement of people. But what do we do? Our president, Dr. Ruto, in his most recent &lt;a href=&quot;https://www.standardmedia.co.ke/health/national/article/2001487655/kenyas-year-of-diplomatic-gaffes-loud-criticism-and-clarifications&quot;&gt;international relations blunder&lt;/a&gt;, angered the Congolese by calling the French president to help resolve the M23 issue in Eastern Congo, a move the locals didn’t take too kindly and they reacted by &lt;a href=&quot;https://www.kenyans.co.ke/news/108445-govt-vows-action-after-protestors-attack-kenyan-embassy-employees-drc&quot;&gt;trashing our high commission in Kinshasa&lt;/a&gt;. I wonder how far this will set back our relations given how emotive the M23 issue is in the DRC.&lt;/p&gt;

&lt;h2 id=&quot;imports&quot;&gt;Imports&lt;/h2&gt;

&lt;figure&gt;
  &lt;img alt=&quot;Kenya imports, 2022. Source OEC&quot; src=&quot;/images/Imports-2022---Click-to-Select-a-Product (2).png&quot; /&gt;
  &lt;figcaption&gt;
   Kenyan imports, 2022. Source OEC
  &lt;/figcaption&gt;
&lt;/figure&gt;

&lt;h3 id=&quot;our-suppliers&quot;&gt;Our Suppliers&lt;/h3&gt;

&lt;figure&gt;
  &lt;img alt=&quot;Kenya imports source countries, 2022. Source OEC&quot; src=&quot;/images/Origins-2022---Click-to-Select-a-Country.png&quot; /&gt;
  &lt;figcaption&gt;
   Kenyan imports, 2022. Source OEC
  &lt;/figcaption&gt;
&lt;/figure&gt;

&lt;p&gt;Kenya chiefly imports finished products except for palm oil which we import from the Southeast Asian countries of Indonesia and Malaysia. But did you know that the palm tree is native to Africa? This plant has made billionaires in Asia, South America and Europe. Why is the palm oil business lucrative? Palm oil is an important ingredient in many finished products, from cooking oils to soap and biofuels. We should be cultivating this crop and exporting palm oil ourselves. Thankfully, we have realised this and &lt;a href=&quot;https://www.youtube.com/watch?v=d-O7xe7s0bc&amp;amp;ab_channel=CitizenTVKenya&quot;&gt;Bidco&lt;/a&gt;, put up a plant in Uganda and they are planning to do the same in Kenya after their success in Uganda.&lt;/p&gt;

&lt;p&gt;I wonder why we import so much wheat, $576M worth of wheat in fact and we have thousands of &lt;a href=&quot;https://www.businessdailyafrica.com/bd/economy/israeli-investors-eye-kenya-idle-land-for-wheat-farming-4742366&quot;&gt;hectares&lt;/a&gt; of idle land.&lt;/p&gt;

&lt;p&gt;As for cars, we let our only homegrown car manufacturer, Mobius Motors &lt;a href=&quot;https://www.businessdailyafrica.com/bd/corporate/companies/mobius-shuts-down-4715626&quot;&gt;die&lt;/a&gt; rather than prop it up and boost our manufacturing sector. I wonder what would have happened to the company had the government ordered 111 &lt;a href=&quot;https://www.businessdailyafrica.com/bd/corporate/companies/dci-to-lease-sh510m-volkswagen-tiguan-vehicles-4001340&quot;&gt;police cars&lt;/a&gt; from Mobius rather than VW.&lt;/p&gt;

&lt;p&gt;We also imported $135.1 million worth of milk and concentrated milk. We are not taking our dairy industry seriously, probably because there is everything for the people to gain and nothing for the politicians to grab. Kenya’s annual milk &lt;a href=&quot;https://www.ilri.org/news/dairy-farmer-extension-services-model-successful-research-trial-kenyas-dairy-sector&quot;&gt;demand&lt;/a&gt; is about 8 billion litres, compared to local production of 4.6 billion litres largely fuelled by small-scale farmers. The demand exists, but the sector has been neglected, and it is largely a &lt;a href=&quot;https://nation.africa/kenya/business/why-dairy-farming-is-a-loss-making-venture-4430722&quot;&gt;loss-&lt;/a&gt;making venture for small-scale farmers. What if we upgraded our dairy industry and superseded our current demand? We could then diversify into making ghee, butter and cheese thus eliminating the need for margarine and palm oil. This one move could reduce our import bill, and increase local production and exports while improving our health as a nation. Imagine that.&lt;/p&gt;

&lt;p&gt;Our economy is relatively unsophisticated. We grow things, harvest them, and then sell them. There is little value addition or processing, which denies us much-needed revenue and development.&lt;/p&gt;

&lt;p&gt;Why do we supply substandard seeds and fertilizers to maize farmers and expect them to feed the nation? Why do we not have a vibrant irrigation culture in the country? We set up the &lt;a href=&quot;https://nation.africa/kenya/news/how-crooked-profiteers-took-galana-kulalu-project-down-the-drain--4079252&quot;&gt;Galana Kulalu irrigation&lt;/a&gt; project back in 2014 then proceeded to bungle the project in the most incompetent fashion possible. And now we want to &lt;a href=&quot;https://www.businessdailyafrica.com/bd/corporate/companies/selu-to-invest-sh13bn-in-galana-kulalu-project--4499674&quot;&gt;resuscitate&lt;/a&gt; this monster. We have the land, water and expertise but not the political will.&lt;/p&gt;

&lt;p&gt;Why do we think animal husbandry is building slaughterhouses everywhere? County governments are falling over themselves to build abattoirs. What value do slaughterhouses add to meat? Why do we not invest in extension services, water harvesting, pasture management, and fattening centres/feedlots? Why does our government think that buildings, railways, and such infrastructure equate to economic development? &lt;br /&gt;
This foolish policy of &lt;em&gt;‘if we build they will come’&lt;/em&gt; is just plain stupid trickle-down economics that does not work! Cue Konza City, a laughable attempt to recreate Silicon Valley in Kenya by building skyscrapers and airports rather than building local human capital and internet infrastructure. Silicon Valley was built around Stanford University on a foundation of cutting-edge research and application.&lt;/p&gt;

&lt;p&gt;Our government also focuses intensely on &lt;a href=&quot;https://www.theelephant.info/analysis/2018/08/16/invisible-citizens-branding-kenya-for-foreign-investors-and-tourists/&quot;&gt;pleasing foreign investors&lt;/a&gt; and tourists rather than empowering locals who will propel the economy upwards from the ground up. How many wealthy countries became so through foreign investors? Some countries did start this way but eventually, the locals absorbed whatever knowledge they imported from foreigners and then applied it in their way until eventually, they were able to create and innovate on their own. How much do foreign investors bring in to warrant such attention? If the same laser focus was turned on agriculture, value addition, local innovations, manufacturing, the service economy and most importantly, the citizens themselves, it would have a lasting multiplier effect on the economy.&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;We shall never get wealthy exporting raw materials.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;According to the statistics on &lt;a href=&quot;https://www.gapminder.org/upgrader/q9/&quot;&gt;Gapminder&lt;/a&gt;, in the last two centuries, the share of income from agriculture, forestry and fishing has been dropping steadily and it is now at 5% of global income. No country has become rich by relying on these traditional industries for their income, instead, manufacturing, processing raw materials, complex services and natural resources like oil are the main propellers to wealth. Now, this does not mean that you reduce agricultural output, no, it means you drive up other sectors exponentially such that agriculture even though it is growing, is dwarfed by these more complex industries.&lt;/p&gt;

&lt;p&gt;In many low and mid-income countries, a substantial percentage of tax revenue is collected from import taxes and the small pool of formal employees since the majority of the economy is informal and thus difficult to tax. The best way out of this is to focus on developing the informal sector into a large formal sector so that the tax burden is more evenly spread out rather than shouldered by just a few. Failure to recognise and remedy this leads to higher and higher taxation on fewer and fewer citizens and businesses as the government struggles to raise revenue to run the country. Taxes and interest rates inevitably rise and a money-hungry, inefficient government sucks cash and private debt from the economy leading to depleted savings, lower money velocity, lower investment and ironically, lower income to tax! New bills to increase tax or devise new taxes will come up in a bid to raise the tax revenue but this is a reinforcing loop that will drive an economy to the ground if not checked early enough. Sound familiar?&lt;/p&gt;

          </description>
          <pubDate>Wed, 12 Feb 2025 07:09:37 +0300</pubDate>
          <link>https://www.kibetkoech.com/writing/the-kenyan-economy-overview/</link>
          <guid isPermaLink="true">https://www.kibetkoech.com/writing/the-kenyan-economy-overview/</guid>
          
          <category>development</category>
          
          <category>economy</category>
          
          <category>kenya</category>
          
          <category>trade</category>
          
          
          <category>development</category>
          
          <category>economy</category>
          
          <category>kenya</category>
          
        </item>
      
    
      
        <item>
          
            <title>How To Develop Kenya II</title>
          
          <author> (Kibet Koech)</author>
          <description>
            &lt;p&gt;I am beginning to suspect that our failure to launch is not a technical problem, it is political.
A bitter pill that we should all swallow is that &lt;strong&gt;Politicians do not care about you&lt;/strong&gt;. They never have and never will. It took the Europeans well over 2 centuries to wrestle power away from their elites and distribute it amongst the entire populace and thus set themselves on the path to prosperity. So getting rid of politics and politicians seems like a viable shortcut. However, the only alternative to politics is war and however bad our politics might be, it is infinitely preferable to war. You just have to look at our next-door neighbours, Somalia, Sudan and Ethiopia to see this.&lt;/p&gt;

&lt;p&gt;Our current political system is set up such that it attracts the worst of us. I, therefore, propose that we reconcile these opposing desires by intertwining public interest with that of politicians. Get their skin in the game because over time they have managed to insulate themselves from the drudgery and struggles of the average Kenyan. How should we do this?&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;All politicians and public servants should receive their medical insurance only from SHIF/SHA. No private insurance. They should also be restricted to public hospitals unless it is an emergency. This will ensure that our public hospitals are well equipped and well stocked with drugs and the staff will never go on strike.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Everyone who receives a paycheck from the exchequer along with their children and spouses should only attend public school. If they want to attend a private school, they can resign. Again we will see an almost magical improvement in the service delivery of public schools as well as the motivation of teachers. As for elected officials, their children must attend schools within their constituency.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;No car grants and soft mortgages from the treasury for any politician or civil servant. They can join SACCOs and line up at the bank like the rest of us. Suddenly, the CRB will begin to function as it was intended, a pricer of risk and loans. Greedy banks will be reined in and the insane import taxation on vehicles and overpriced real estate will suddenly be uncomfortable for legislators.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Pensions for MPs will be after 20 years of continuous service. This will be provided strictly through NSSF, not a private pension fund. Suddenly, NSSF will no longer be broke and pensions will be processed immediately.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;The salaries of politicians should be pegged to the GDP per capita or a multiple of the minimum wage/average wage in Kenya as reported by independent institutions like the World Bank, just like CEOs get a performance bonus. Our politicians will be forced to make prudent financial decisions. Using a multiple of, say, 10, if we use the GDP per capita &lt;a href=&quot;https://tradingeconomics.com/kenya/gdp-per-capita&quot;&gt;here&lt;/a&gt;, this works out to roughly 196,000 per month. Using the average monthly &lt;a href=&quot;https://www.businessdailyafrica.com/bd/economy/kenyans-average-income-of-sh20-123-hits-six-year-high--4043204&quot;&gt;income&lt;/a&gt; it works out to about 201,230 shillings per month. For governors and MCAs, we can use numbers from their respective counties.&lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Fuel allowances should be the current AA rate, not set by parliament. This is chiefly for humility’s sake, just to make sure that they stay in touch with the prices that affect our everyday lives.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;End per diems for elected officials. Their travel and accommodation logistics can be arranged and paid for by parliament or the county assembly. If they spend on food, they must claim the expenses via receipts just like the rest of us.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Campaign finances. There should be a hard ceiling on how much can be raised and spent on campaigns. Get volunteers who believe in your cause to campaign for you. Also, campaign finance should be audited and made public and any violation should attract punitive measures like loss of a seat and disbarment from participation in elective politics or holding any public office.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Every year, a list of companies owned by elected and top officials, their spouses, siblings, and children over 25 years old to be published along with their audited accounts. And no, they cannot do business with the government. This will force them to expand the private sector to get any business.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;AHP should be ring-fenced and used to develop or improve infrastructure to support housing development, such as access to water, inlet roads, sewerage, and last-mile power. &lt;em&gt;(I have a problem with this, though. I will be paying KPLC for power every month; why should I finance their capital outlay?)&lt;/em&gt;. The government has no business building houses; if it can’t house police officers, then how can we expect it to build houses for us?&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Information. National budgets are grand and easily escape the scrutiny of Wanjiku. Budget allocations and expenditures for public institutions/centres, such as local clinics, schools, etc., should be posted publicly on the institution’s notice boards, websites, and at the local administrative offices (chief, DO, etc.).&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;All government contracts and agreements must be made public before assent and must require parliamentary approval otherwise they are illegal, will not be honoured and the signees will be held personally liable. I’m thinking of SGR, Adani and other such contracts.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Half of all government vehicles must be locally manufactured.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;CDF must go.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;County governments will be financed at a multiple of their revenue. For example, if a county raises 200 million a year, then it gets a 4 multiple to 1 billion. This nonsense of giving counties 17 billion instead of their own 100 million that they then proceed to loot and mismanage has got to end.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Senators, MPs, governors, MCAs and CSs, Supreme Court judges and their spouses’ tax returns will be made public.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Protective detail will only be for the president, deputy president, speakers of parliament, CJ and DCJ. The rest can tough it out with us. I bet police service delivery will improve greatly.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;EACC and IPOA should be given teeth - prosecutorial powers.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;We must develop an overarching vision that will be executed in phases by the various governments that come into power to ensure continuity. Vision 2030 started well but we seem to have abandoned it.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;The rules and laws of demonstrations should apply to political rallies.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Anyone with an active criminal court case should not be allowed to run for any public office or be appointed to any public office - this may be prone to abuse but I think the benefits outweigh the risks.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Civic education. This should take place in schools. Every child should be educated on our entire constitution and its history.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Any law, rule, regulation or policy that seeks to control the media, social media or free speech should be okayed by the executive (cabinet), ⅔ majority (of the total, not of the quorum) in parliament and the assemblies of all counties before it is accepted.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;Agriculture should be a compulsory subject in every school in Kenya, even those working on international curriculums.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;These measures seem punitive and invasive because they are. The intention is twofold:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;Sieve out the bad apples who cannot take the scrutiny. Caesar’s wife should be beyond suspicion.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;If some manage to squeeze through, make sure that life will be unpleasant for them.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;


          </description>
          <pubDate>Mon, 03 Feb 2025 10:53:37 +0300</pubDate>
          <link>https://www.kibetkoech.com/writing/how-to-develop-kenya-ii/</link>
          <guid isPermaLink="true">https://www.kibetkoech.com/writing/how-to-develop-kenya-ii/</guid>
          
          <category>development</category>
          
          <category>economy</category>
          
          <category>corruption</category>
          
          <category>governance</category>
          
          
          <category>development</category>
          
          <category>economy</category>
          
          <category>corruption</category>
          
        </item>
      
    
      
        <item>
          
            <title>How I Got Splunk Certified</title>
          
          <author> (Kibet Koech)</author>
          <description>
            &lt;h2 id=&quot;this-post-first-appeared-on-an-earlier-version-of-this-blog-which-unfortunately-went-down-with-all-my-data&quot;&gt;This post first appeared on an earlier version of this blog which unfortunately went down with all my data.&lt;/h2&gt;
&lt;p&gt;Splunk is a useful tool that can help an organisation make sense of their machine data. In the modern company setting, most of the data generated is machine data originating from various sources like web servers, IoT devices, network devices, email servers, machine logs etc.&lt;/p&gt;

&lt;p&gt;Hidden amongst this pile of gobbledygook are golden insights into your customers, markets, operations and the power to make sound decisions and take over the world! Muhahahahaha!
Lots of companies have no idea what to do with all the data they collect so they just archive it and kick it down the road hoping for the best. Splunk seeks to help companies with this problem by taking their machine data, indexing it and making it easy to search through this seemingly incomprehensible pile and come up with useful information.
I recently came to understand this and thus decided to study Splunk further. Now, they do have a certification program that goes all the way from the fundamentals to Splunk architect. I will focus on the &lt;a href=&quot;https://www.splunk.com/en_us/training/certification-track/splunk-core-certified-user.html&quot;&gt;Splunk Core Certified User&lt;/a&gt; as it’s the basic entry-level certification (not to mention the only one I have tackled…)&lt;/p&gt;

&lt;p&gt;To earn this certification you have to head over to the &lt;a href=&quot;https://www.splunk.com/&quot;&gt;Splunk&lt;/a&gt; website, register as a student and enrol for either the free self-paced Splunk Fundamentals 1 course or the instructor-led course. Both will have you install the &lt;a href=&quot;https://www.splunk.com/en_us/download.html&quot;&gt;free Splunk&lt;/a&gt; edition but remember, the course will only be accessible for 30 days so you need to be sure that you will complete it in time.
The fundamentals course includes the following topics:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Introduction to Splunk’s interface&lt;/li&gt;
  &lt;li&gt;Basic searching&lt;/li&gt;
  &lt;li&gt;Using fields in searches&lt;/li&gt;
  &lt;li&gt;Search fundamentals&lt;/li&gt;
  &lt;li&gt;Transforming commands&lt;/li&gt;
  &lt;li&gt;Creating reports and dashboards&lt;/li&gt;
  &lt;li&gt;Datasets&lt;/li&gt;
  &lt;li&gt;The Common Information Model (CIM)&lt;/li&gt;
  &lt;li&gt;Creating and using lookups&lt;/li&gt;
  &lt;li&gt;Scheduled Reports&lt;/li&gt;
  &lt;li&gt;Alerts&lt;/li&gt;
  &lt;li&gt;Using Pivot&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The course objectives are:&lt;/p&gt;

&lt;h3 id=&quot;module-1--introduction&quot;&gt;Module 1 – Introduction&lt;/h3&gt;
&lt;ul&gt;
  &lt;li&gt;Overview of Buttercup Games Inc. (Love these guys!)
    &lt;h3 id=&quot;module-2--what-is-splunk&quot;&gt;Module 2 – What is Splunk?&lt;/h3&gt;
  &lt;/li&gt;
  &lt;li&gt;Splunk components&lt;/li&gt;
  &lt;li&gt;Installing Splunk&lt;/li&gt;
  &lt;li&gt;Getting data into Splunk
    &lt;h3 id=&quot;module-3--introduction-to-splunks-user-interface&quot;&gt;Module 3 – Introduction to Splunk’s User Interface&lt;/h3&gt;
  &lt;/li&gt;
  &lt;li&gt;Understand the uses of Splunk&lt;/li&gt;
  &lt;li&gt;Define Splunk Apps&lt;/li&gt;
  &lt;li&gt;Customizing your user settings&lt;/li&gt;
  &lt;li&gt;Learn basic navigation in Splunk
    &lt;h3 id=&quot;module-4--basic-searching&quot;&gt;Module 4 – Basic Searching&lt;/h3&gt;
  &lt;/li&gt;
  &lt;li&gt;Run basic searches&lt;/li&gt;
  &lt;li&gt;Use autocomplete to help build a search&lt;/li&gt;
  &lt;li&gt;Set the time range of a search&lt;/li&gt;
  &lt;li&gt;Identify the contents of search results&lt;/li&gt;
  &lt;li&gt;Refine searches&lt;/li&gt;
  &lt;li&gt;Use the timeline&lt;/li&gt;
  &lt;li&gt;Work with events&lt;/li&gt;
  &lt;li&gt;Control a search job&lt;/li&gt;
  &lt;li&gt;Save search results
    &lt;h3 id=&quot;module-5--using-fields-in-searches&quot;&gt;Module 5 – Using Fields in Searches&lt;/h3&gt;
  &lt;/li&gt;
  &lt;li&gt;Understand fields&lt;/li&gt;
  &lt;li&gt;Use fields in searches&lt;/li&gt;
  &lt;li&gt;Use the fields sidebar
    &lt;h3 id=&quot;module-6--search-language-fundamentals&quot;&gt;Module 6 – Search Language Fundamentals&lt;/h3&gt;
  &lt;/li&gt;
  &lt;li&gt;Review basic search commands and general search practices&lt;/li&gt;
  &lt;li&gt;Examine the search pipeline&lt;/li&gt;
  &lt;li&gt;Specify indexes in searches&lt;/li&gt;
  &lt;li&gt;Use autocomplete and syntax highlighting&lt;/li&gt;
  &lt;li&gt;Use SPL search commands to perform searches:
    &lt;h3 id=&quot;module-7--using-basic-transforming-commands&quot;&gt;Module 7 – Using Basic Transforming Commands&lt;/h3&gt;
  &lt;/li&gt;
  &lt;li&gt;The top command&lt;/li&gt;
  &lt;li&gt;The rare command&lt;/li&gt;
  &lt;li&gt;The stats command
    &lt;h3 id=&quot;module-8--creating-reports-and-dashboards&quot;&gt;Module 8 – Creating Reports and Dashboards&lt;/h3&gt;
  &lt;/li&gt;
  &lt;li&gt;Save a search as a report&lt;/li&gt;
  &lt;li&gt;Edit reports&lt;/li&gt;
  &lt;li&gt;Create reports that include visualizations such as charts and tables&lt;/li&gt;
  &lt;li&gt;Create a dashboard&lt;/li&gt;
  &lt;li&gt;Add a report to a dashboard&lt;/li&gt;
  &lt;li&gt;Edit a dashboard
    &lt;h3 id=&quot;module-9--datasets-and-the-common-information-model&quot;&gt;Module 9 – Datasets and the Common Information Model&lt;/h3&gt;
  &lt;/li&gt;
  &lt;li&gt;Naming conventions&lt;/li&gt;
  &lt;li&gt;What are datasets?&lt;/li&gt;
  &lt;li&gt;What is the Common Information Model (CIM)?
    &lt;h3 id=&quot;module-10--creating-and-using-lookups&quot;&gt;Module 10 – Creating and Using Lookups&lt;/h3&gt;
  &lt;/li&gt;
  &lt;li&gt;Describe lookups&lt;/li&gt;
  &lt;li&gt;Create a lookup file and create a lookup definition&lt;/li&gt;
  &lt;li&gt;Configure an automatic lookup
    &lt;h3 id=&quot;module-11--creating-scheduled-reports-and-alerts&quot;&gt;Module 11 – Creating Scheduled Reports and Alerts&lt;/h3&gt;
  &lt;/li&gt;
  &lt;li&gt;Describe scheduled reports&lt;/li&gt;
  &lt;li&gt;Configure scheduled reports&lt;/li&gt;
  &lt;li&gt;Describe alerts&lt;/li&gt;
  &lt;li&gt;Create alerts&lt;/li&gt;
  &lt;li&gt;View fired alerts
    &lt;h3 id=&quot;module-12---using-pivot&quot;&gt;Module 12 - Using Pivot&lt;/h3&gt;
  &lt;/li&gt;
  &lt;li&gt;Describe Pivot&lt;/li&gt;
  &lt;li&gt;Understand the relationship between data models and pivot&lt;/li&gt;
  &lt;li&gt;Select a data model object&lt;/li&gt;
  &lt;li&gt;Create a pivot report&lt;/li&gt;
  &lt;li&gt;Create an instant pivot from a search&lt;/li&gt;
  &lt;li&gt;Add a pivot report to a dashboard&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I studied for the Core User Certification by going through the course videos and quizzes once and then doing the final quiz. The module quizzes don’t count towards your grade but they are important in preparing you. The final quiz is important though, you have to pass it so that you can register for the actual certification exam. It has 39 questions and the pass mark is 75%. If you fail you can retake it in 5 days. 
I passed the final quiz (92%) but I wasn’t ready for the real thing yet so I rewatched the videos while going through the PDF notes they provided and redoing the labs and this helped a lot, I began to truly grasp the content and I was now more confident. I retook the final quiz and got a 97% but I was still not ready. I then registered for another free course: &lt;a href=&quot;https://www.splunk.com/en_us/training/free-courses/splunk-infastructure-overview.html&quot;&gt;Splunk Infrastructure Overview&lt;/a&gt;. This course will give you a high-level overview of Splunk’s Enterprise infrastructure from a single instance deployment to a distributed environment. 
After completing this course I again reviewed the Splunk Fundamentals 1 PDF notes and labs and I now felt ready for the certification test.
To register for the test you can follow Splunk’s instructions here. Please be careful while registering, I suggest reading through the instructions at least once before beginning the process so that you don’t make avoidable mistakes. Once you register on Pearson VUE you can pay, revise for your test and go crush it!&lt;/p&gt;


          </description>
          <pubDate>Wed, 06 Nov 2024 10:53:37 +0300</pubDate>
          <link>https://www.kibetkoech.com/writing/how-i-got-splunk-certified/</link>
          <guid isPermaLink="true">https://www.kibetkoech.com/writing/how-i-got-splunk-certified/</guid>
          
          <category>splunk</category>
          
          <category>certification</category>
          
          <category>data-tools</category>
          
          
          <category>splunk</category>
          
          <category>certification</category>
          
        </item>
      
    
      
        <item>
          
            <title>A Letter from The Devil</title>
          
          <author> (Kibet Koech)</author>
          <description>
            &lt;h2 id=&quot;this-post-first-appeared-on-my-first-wordpress-blog-here&quot;&gt;This post first appeared on my first WordPress blog &lt;a href=&quot;https://atonui.wordpress.com/2012/10/&quot;&gt;here&lt;/a&gt;.&lt;/h2&gt;
&lt;p&gt;Dear earthlings,&lt;/p&gt;

&lt;p&gt;How are things up there? Still sinning I hope…eh?  Anyway it has now reached a point in this good vs. evil war and I think am getting pretty good at beating you wretched beings. You know Eve wagered me I wouldn’t have a billion of her offspring by now but guess what…my gatekeeper, Legion (yeah, yeah, the pig guy), called and we just hit and surpassed the target in the last hour! Ha! Ha! Ha! I never thought I’d ever say this but we are running out of torture space and it’s getting a little crowded here but no worries, the more the merrier. I must be doing a pretty good job then, and the competition seems to be slipping up eh… anybody care to answer that? Pope… Michael… anyone? I thought so.&lt;/p&gt;

&lt;p&gt;But don’t think I haven’t any problems. Sanitation issues, congestion, slum development, demon resources (can you believe they have a union…?! I mean who would they complain to… God? For some reason I don’t think He’d be too interested), energy (my furnaces don’t run on water you know, and even if they did there’s only two bottles of Dasani in my safe. I’ll tell you about them later). I’ve tried getting you to go green but you people seem hell-bent (nice one eh…?) on depleting my oil reserves and not just that, this morning I had to fire two demons (literally). They wanted air-conditioning…?! Can you believe that?! The nerve on those two! The last time something like this happened, I got kicked out of heaven (yeah it exists and it’s very beautiful up there. Oh the memories…) and my buddy Mike took over the military. Anyway what I’m saying is I can feel a rebellion precipitating and who better to handle it than the king of mutiny himself? Heads will roll (once again, literally) and I will restore sanity in this place.&lt;/p&gt;

&lt;p&gt;My latest intelligence report says that Hollywood is putting doomsday at twelve o’clock on December 21, 2012. You know, I don’t think you can get any dumber than that. I’ve been around longer than any of you and I’ll tell you this: alcoholic’s prayer: Lord give me the strength to change the things I can, the serenity to accept those I can’t and the wisdom to know the difference (I bet you didn’t think I knew that…?).&lt;/p&gt;

&lt;p&gt;Judgment day is coming all right, that’s a definite, but only one guy knows when and He’s not letting on. Personally I think that’s selfish but who am I to judge, right? Damn, am on fire tonight! Ha! Ha! Ha! There I go again. I’m loving this. But don’t get me wrong, I love Hollywood, they’ve single-handedly got me more souls than I would care to count, maybe the Pharisees (imbeciles, made me look like a fool on Calvary) could learn a thing or two from them. Hollywood’s smart, dedicated, aggressive, creative and very suggestible. A nudge here, a wink there and presto! Gay is good! Even priests are falling for it. Moses (very angry guy, didn’t see Canaan and all…) warned you and what do you do? You spit right in his face! Do you know how long he took on those stone tablets with just a mallet and chisel? He almost lost a thumb (yeah it was me). He must be seething like a rabid wolf right now. I hope they have anger management classes up there. Kudos movie industry, our alliance is working out pretty well.&lt;/p&gt;

&lt;p&gt;The only beef I have with Hollywood is their portrayal of me. The horns, carnivorous teeth, pointed tail, clawed feet and the three-pronged fork don’t really work for me. I’ve been getting bad press for thousands of years and you’d think I’d be used to it by now but my self-esteem is closely tied with my physical appeal and am nothing near that ghastly image. I am very handsome you know, Delilah says I look like Joseph, and we all know how he drove Potiphar’s missus bananas, my bad. But I did it just for fun. Those days were very boring, after the floods and the stalling of project Babel there wasn’t much a guy could do here. Wait, why am I apologizing for doing my job? I really have to stop that, my PR guy says this is a sign of weakness.&lt;/p&gt;

&lt;p&gt;About a week ago I met with Cain. Can you believe the guy still treads the earth! I know am supposed to be cold-hearted and all but this guy just got it real bad. I remember that beautiful early morning when he woke up an hour early (he wasn’t the early bird type) so he could give back his ten percent then God tells him he couldn’t care less about the wheat and nduma. Now that got Cain seething with rage and enter Lucifer. I have this neat trick where I help to redirect the anger to someone and next thing I knew the grim reaper handled his first job and Abel could take his stuffed lamb straight to the angels for all I care. Ever since, Cain hasn’t been very friendly, I wonder why…?&lt;/p&gt;

&lt;p&gt;Now politicians, what can I say? A masterpiece, absolutely wonderful. A crowning jewel of my very evil genius. Outsourcing some of their services is reaping me huge dividends. Now I can even afford to pull out half of my demon squad around elections and watch my very own Frankenstein monster at its best. Jews, Rwandans and Kenyans can confirm this.&lt;/p&gt;

&lt;p&gt;I remember when Je… no, the son of Man triumphantly entered Jerusalem on Palm Sunday. Everyone was out there singing, shouting and waving just about anything they could get their hands on. The guy was sitting up there on his donkey looking all royal and feeling good about himself but I had a plan, big plan. Oh I always have a plan and this one was particularly special.&lt;/p&gt;

&lt;p&gt;So I got a few of the Sadducees and Pharisees together, discreetly of course and suggested a little divide and rule and they took it. I love this method. Just get a few jingoistic, narrow-minded ‘leaders’ together, wind them up with a little tension and let them go. Boy, are they super effective. In under a week, everyone in the capital city was baying for Jesus’ blood. One week! You have got to respect that. Of course he did help a little, trashing the market and all; such things don’t help sway public opinion your way you know.&lt;/p&gt;

&lt;p&gt;Well that’s it for now, I have to leave; it’s Friday night and people throw themselves at me on this night.&lt;/p&gt;

&lt;p&gt;Yours hatefully,&lt;/p&gt;

&lt;p&gt;Lucifer B. Satan&lt;/p&gt;


          </description>
          <pubDate>Wed, 06 Nov 2024 10:53:37 +0300</pubDate>
          <link>https://www.kibetkoech.com/writing/a-letter-from-the-devil/</link>
          <guid isPermaLink="true">https://www.kibetkoech.com/writing/a-letter-from-the-devil/</guid>
          
          <category>satire</category>
          
          <category>faith</category>
          
          <category>morality</category>
          
          
          <category>satan</category>
          
          <category>sin</category>
          
          <category>evil</category>
          
        </item>
      
    
      
        <item>
          
            <title>How Do Countries Develop?</title>
          
          <author> (Kibet Koech)</author>
          <description>
            &lt;h4 id=&quot;what-is-the-role-of-energy-and-scientific-advancement-in-the-socioeconomic-development-of-nations&quot;&gt;&lt;em&gt;What is the role of energy and scientific advancement in the socioeconomic development of nations?&lt;/em&gt;&lt;/h4&gt;

&lt;p&gt;How do countries develop? What is development? Owen Barder&lt;sup id=&quot;fnref:1&quot;&gt;&lt;a href=&quot;#fn:1&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot; role=&quot;doc-noteref&quot;&gt;1&lt;/a&gt;&lt;/sup&gt; argues that development is an emergent property of the socioeconomic system. He further expounds this idea by noting that development is not the sum of the well-being of people in the economy and it cannot be brought about simply by making enough people in the economy better off. Development, he argues, is instead a system-wide manifestation of the way people, firms, technologies and institutions interact with each other within the economic, social and political system. Specifically, development is the capacity of those systems to provide self-organising complexity.  Self-organising complexity in an adaptive system cannot be deliberately designed; it arises from a process of continuous adaptation and evolution.&lt;/p&gt;

&lt;p&gt;This is a complex topic to tackle so I have narrowed down my question to just how important energy is to the development of a nation, specifically, electricity and the role of scientific advancement. This is because electrical consumption is a measure of not just the ability to utilise electricity but a measure of just how good a country’s infrastructure is because electricity is complex to generate, transmit and use and like all other forms of energy it must be reliable and cheap. Attention to scientific advancements is also important as new and more complex goods and services are developed through research and the application of newly discovered or acquired knowledge. A nation that pays attention to and deliberately funds research and development will tend to have a more advanced and complex economy.&lt;/p&gt;

&lt;p&gt;Therefore, I will be using the GDP per capita, electricity consumption per capita, economic complexity index, and the number of scientific papers published per nation to investigate my hypothesis.&lt;/p&gt;

&lt;p&gt;Developing nations have been struggling to move to middle-income and finally high-income status. Loans, grants and donations have been poured into trying to alleviate poverty and improve the lot of these nations but sadly not much happens. Exactly what does it take to transform a struggling economy into a robust and complex one? Is it just money that is required? In this investigation, we will discover that the process of development is much more subtle than government-initiated economic projects and rather it is a complex function of the interactions between multiple systems in an organic manner that leads to a prosperous, complex and robust economy of a nation.&lt;/p&gt;

&lt;h3 id=&quot;data-sources&quot;&gt;Data Sources&lt;/h3&gt;
&lt;p&gt;Data was acquired and assembled from multiple online sources listed below:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Electricity consumption per capita (kWh) and GDP per capita ($) from the World Bank data repository&lt;sup id=&quot;fnref:2&quot;&gt;&lt;a href=&quot;#fn:2&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot; role=&quot;doc-noteref&quot;&gt;2&lt;/a&gt;&lt;/sup&gt;.&lt;/li&gt;
  &lt;li&gt;List of oil-producing countries from Wikipedia, scraped using R&lt;sup id=&quot;fnref:3&quot;&gt;&lt;a href=&quot;#fn:3&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot; role=&quot;doc-noteref&quot;&gt;3&lt;/a&gt;&lt;/sup&gt;.&lt;/li&gt;
  &lt;li&gt;Economic Complexity Index, Harvard University, (The Atlas of Economic Complexity by @HarvardGrwthLab, n.d.)&lt;sup id=&quot;fnref:4&quot;&gt;&lt;a href=&quot;#fn:4&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot; role=&quot;doc-noteref&quot;&gt;4&lt;/a&gt;&lt;/sup&gt;.&lt;/li&gt;
  &lt;li&gt;Democracy Index from Economist Intelligence Unit, 2023&lt;sup id=&quot;fnref:5&quot;&gt;&lt;a href=&quot;#fn:5&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot; role=&quot;doc-noteref&quot;&gt;5&lt;/a&gt;&lt;/sup&gt;.&lt;/li&gt;
  &lt;li&gt;Gini Coefficient by Country 2023, n.d&lt;sup id=&quot;fnref:6&quot;&gt;&lt;a href=&quot;#fn:6&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot; role=&quot;doc-noteref&quot;&gt;6&lt;/a&gt;&lt;/sup&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;results-and-discussion&quot;&gt;Results and Discussion&lt;/h3&gt;
&lt;p&gt;&lt;a href=&quot;https://app.powerbi.com/groups/me/reports/4612f545-418e-4f89-8f22-4b4e964cc05b/ReportSectione390957330933048a7a1&quot;&gt;Here&lt;/a&gt; is the Power BI dashboard.&lt;/p&gt;

&lt;h4 id=&quot;1-average-electricity-consumption-per-capita-vs-average-gdp-per-capita&quot;&gt;1. Average Electricity Consumption per Capita vs Average GDP per Capita&lt;/h4&gt;

&lt;figure&gt;
  &lt;img alt=&quot;Average Electricity Consumption per Capita vs Average GDP per Capita&quot; src=&quot;/images/elec_vs_gdp.JPG&quot; /&gt;
  &lt;figcaption&gt;
   Average Electricity Consumption per Capita vs Average GDP per Capita
  &lt;/figcaption&gt;
&lt;/figure&gt;

&lt;!-- | ![image](/images/elec_vs_gdp.JPG){:height=&quot;550%&quot; width=&quot;150%&quot;} |
|:--:|
| *Average Electricity Consumption per Capita vs Average GDP per Capita* | --&gt;

&lt;p&gt;The chart above clearly shows a strong positive correlation between GDP per capita and electricity consumption per capita. In other words, the more electricity citizens use, the more productive they are.&lt;/p&gt;

&lt;h4 id=&quot;2-electricity-consumption-per-capita-vs-gdp-per-capita-for-selected-countries&quot;&gt;2. Electricity consumption per capita vs GDP per Capita for selected countries&lt;/h4&gt;

&lt;figure&gt;
  &lt;img alt=&quot;Electricity consumption per capita vs GDP per Capita for selected countries&quot; src=&quot;/images/elec_vs_gdp_select.JPG&quot; /&gt;
  &lt;figcaption&gt;
   Electricity consumption per capita vs GDP per Capita for selected countries
  &lt;/figcaption&gt;
&lt;/figure&gt;

&lt;p&gt;This next chart examines the relationship between electricity consumption and GDP per capita between selected countries. 
Three clear categories emerge.&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Developing Economies&lt;/strong&gt;: Represented by Kenya. These economies are struggling to improve their GDP per capita and their electricity consumption is also lagging. These nations have not made much progress in the last 30 years.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Rapidly Developing Economies&lt;/strong&gt;: These are represented by China and Brazil. These countries are rapidly increasing their economic output, and their electricity consumption is matching this output. They are well on their way to becoming developed economies.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;&lt;strong&gt;Mature Economies&lt;/strong&gt;: Represented by Germany, USA and Luxembourg. These nations have high economic outputs and electrical consumption per capita however something interesting is observed here. At some point, these countries seem to be increasing their economic output while maintaining or even decreasing their electricity consumption! This is because as economies become mature they improve their efficiency and effectiveness such that they can produce more with less energy. This is the ultimate goal of every economy.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;h4 id=&quot;3-gdp-per-capita-vs-economic-complexity-index&quot;&gt;3. GDP per Capita vs Economic Complexity Index&lt;/h4&gt;

&lt;figure&gt;
  &lt;img alt=&quot;GDP per Capita vs Economic Complexity Index&quot; src=&quot;/images/gdp_vs_eci.JPG&quot; /&gt;
  &lt;figcaption&gt;
   GDP per Capita vs Economic Complexity Index
  &lt;/figcaption&gt;
&lt;/figure&gt;

&lt;p&gt;From the above chart, there is another strong positive correlation between GDP per capita and economic complexity. There are some exceptions like Qatar, the UAE, Kuwait, etc. These can be explained by the presence of oil deposits that these countries export thus they do not need to have complex economies to have a high GDP per capita. However, their goal should be to invest their income in creating a sufficiently advanced and complex economy to buffer themselves against upsets in their major export. Suppose a new source of energy is discovered or invented that will replace oil. Or perhaps their deposits run out? What then? 
To flourish a nation needs to generate wealth consistently, and the way to create more is through innovation. Innovation is essential to African stability and growth in the upcoming decades. Currently, much of that wealth creation is the creation of microenterprises, small businesses that only employ one or two people&lt;sup id=&quot;fnref:7&quot;&gt;&lt;a href=&quot;#fn:7&quot; class=&quot;footnote&quot; rel=&quot;footnote&quot; role=&quot;doc-noteref&quot;&gt;7&lt;/a&gt;&lt;/sup&gt;.&lt;/p&gt;

&lt;h4 id=&quot;4-number-of-scientific-publications-per-country&quot;&gt;4. Number of Scientific Publications per Country&lt;/h4&gt;

&lt;figure&gt;
  &lt;img alt=&quot;Number of Scientific Publications per Country&quot; src=&quot;/images/publications_per_country.JPG&quot; /&gt;
  &lt;figcaption&gt;
   Number of Scientific Publications per Country
  &lt;/figcaption&gt;
&lt;/figure&gt;

&lt;p&gt;This chart shows the number of scientific publications per country (for the selected countries) per year from 2000 to 2018. The notable development here is the meteoric rise of scientific publications in China, which is in tandem with its economic growth. India and Brazil, other rapidly developing nations, are also following the Chinese path of investing in research and development as their engine for economic growth.&lt;/p&gt;

&lt;h4 id=&quot;5-electricity-consumption-per-capita-vs-economic-complexity-index&quot;&gt;5. Electricity Consumption per Capita vs Economic Complexity Index&lt;/h4&gt;

&lt;figure&gt;
  &lt;img alt=&quot;Electricity Consumption per Capita vs Economic Complexity Index&quot; src=&quot;/images/elec_vs_eci.JPG&quot; /&gt;
  &lt;figcaption&gt;
   Electricity Consumption per Capita vs Economic Complexity Index
  &lt;/figcaption&gt;
&lt;/figure&gt;

&lt;p&gt;Here we see a strong positive correlation between electricity consumption per capita and the Economic Complexity Index. The more complex goods and services an economy can produce and export the higher its electricity consumption i.e. one man in an advanced automated factory can produce more and higher quality products than several workers labouring in the sun in a developing economy. Here again, we see that the more mature economies can increase their economic complexity without necessarily increasing their electricity consumption because they are now becoming more efficient and effective. As for the still developing nations, until they become mature economies, it seems the best way to develop is to increase their electricity consumption.&lt;/p&gt;

&lt;h4 id=&quot;6-scientific-papers-published-vs-economic-complexity-index&quot;&gt;6. Scientific Papers Published vs. Economic Complexity Index&lt;/h4&gt;

&lt;figure&gt;
  &lt;img alt=&quot;Scientific Papers Published vs. Economic Complexity Index&quot; src=&quot;/images/papers_vs_eci.JPG&quot; /&gt;
  &lt;figcaption&gt;
   Scientific Papers Published vs. Economic Complexity Index
  &lt;/figcaption&gt;
&lt;/figure&gt;

&lt;p&gt;From this chart, we can conclude that one of the best ways to create a complex economy is to invest in research and development. China, which has invested heavily in research and development for the past two decades has seen a corresponding rise in the complexity of the goods and services it produces and exports. Japan, Germany, the UK, etc. also demonstrate highly complex economies in tandem with their high GDP per capita.&lt;/p&gt;

&lt;h4 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h4&gt;

&lt;p&gt;From this investigation, we can conclude the following:&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;
    &lt;p&gt;To move from developing to rapidly developing and finally to a mature developed economy, a nation must lay the necessary groundwork in terms of access to cheap and reliable energy for its citizens. There is no substitute for this step. Every nation first has to harness energy to multiply the productivity of its workers to develop. We have seen how China and other rapidly developing nations are doing this and we have seen how Kenya has remained stagnant because of not taking this step.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;For long-term economic gains, a nation must invest in high-quality education, research and the development of new products/ideas from the research. This is a precursor to developing a complex economy and there is no escaping this. No amount of external loans or grants will ever replace this. A nation has to develop and deploy intellectual property to develop complexity in the economy. The Americans, for example, applied physics to the development of the atomic bomb and from this, they won the Second World War, catapulted themselves into a superpower and developed several other technologies from this research like nuclear weapons. Their military also developed the internet, and now the USA is reaping huge dividends from the internet.&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Nations also have to intentionally set the stage for organic economic complexity i.e. systems that work, and the freedom to work and be creative. Something simple like the physical addressing system in the Western world enabled the establishment of efficient and effective delivery systems like Amazon. Their political system of democracy and freedom for all also encourages their populace to be daring and entrepreneurial in their pursuits and also attracts immigrants from all over the world who go to these countries and add value to their economies. Contrast this with China which has a capitalistic economic system but a socialist political system. China is certainly making rapid development progress but how sustainable is it? Does it attract the best and brightest from other cultures?&lt;/p&gt;
  &lt;/li&gt;
  &lt;li&gt;
    &lt;p&gt;Finally, there has been a lot of talk and action in the climate change area. Mature economies have become more conscious of their energy footprints and are taking steps towards becoming more energy efficient and that is why we see them increasing their GDP per capita without a corresponding increase in electricity consumption. As for developing nations, this may be difficult as the data suggests that first, you have to multiply your worker productivity by consuming more energy per capita until your economy stabilizes then you can begin taking steps towards efficiency. It is like teaching a baby to first walk in halting unsteady steps before they can properly walk and then they can learn to run fast and efficiently. From this, I would like to caution developing countries to be careful when adopting green energy policies copied from developed nations since they are not operating in the same economic environment as the mature economies. The most important thing for developing nations is first to multiply worker productivity then, economic complexity and finally efficiency.&lt;/p&gt;
  &lt;/li&gt;
&lt;/ol&gt;

&lt;div class=&quot;footnotes&quot; role=&quot;doc-endnotes&quot;&gt;
  &lt;ol&gt;
    &lt;li id=&quot;fn:1&quot;&gt;
      &lt;p&gt;https://www.cgdev.org/blog/what-development &lt;a href=&quot;#fnref:1&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:2&quot;&gt;
      &lt;p&gt;https://data.worldbank.org/ &lt;a href=&quot;#fnref:2&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:3&quot;&gt;
      &lt;p&gt;https://en.wikipedia.org/wiki/List_of_countries_by_oil_production &lt;a href=&quot;#fnref:3&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:4&quot;&gt;
      &lt;p&gt;https://atlas.cid.harvard.edu/rankings &lt;a href=&quot;#fnref:4&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:5&quot;&gt;
      &lt;p&gt;https://www.eiu.com/n/campaigns/democracy-index-2022/ &lt;a href=&quot;#fnref:5&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:6&quot;&gt;
      &lt;p&gt;https://worldpopulationreview.com/country-rankings/gini-coefficient-by-country &lt;a href=&quot;#fnref:6&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
    &lt;li id=&quot;fn:7&quot;&gt;
      &lt;p&gt;Makhtar Diop, World Bank’s Vice President for Africa. (2017, December 1). Innovation in Africa. World Bank. https://www.worldbank.org/en/news/speech/2017/11/30/innovation-in-africa &lt;a href=&quot;#fnref:7&quot; class=&quot;reversefootnote&quot; role=&quot;doc-backlink&quot;&gt;&amp;#8617;&lt;/a&gt;&lt;/p&gt;
    &lt;/li&gt;
  &lt;/ol&gt;
&lt;/div&gt;

          </description>
          <pubDate>Wed, 06 Nov 2024 10:53:37 +0300</pubDate>
          <link>https://www.kibetkoech.com/writing/how-do-countries-develop/</link>
          <guid isPermaLink="true">https://www.kibetkoech.com/writing/how-do-countries-develop/</guid>
          
          <category>development</category>
          
          <category>economy</category>
          
          <category>politics</category>
          
          
          <category>development</category>
          
          <category>economy</category>
          
          <category>politics</category>
          
        </item>
      
    
      
        <item>
          
            <title>Back In High School</title>
          
          <author> (Kibet Koech)</author>
          <description>
            &lt;h2 id=&quot;this-post-first-appeared-on-my-first-wordpress-blog-here&quot;&gt;This post first appeared on my first WordPress blog &lt;a href=&quot;https://atonui.wordpress.com/2012/10/15/back-in-high-school/&quot;&gt;here&lt;/a&gt;.&lt;/h2&gt;
&lt;p&gt;Back in high school, young, naïve and hot-blooded when we thought we would conquer the world – before reality caught up with us that is, I had my first teacher crush. Many more would follow later in life but then they would have rosier endings than this one.&lt;/p&gt;

&lt;p&gt;She was straight out of college. Young, ambitious and eager to make an impression and boy did she make one. Unfortunately for her, it was to the wrong crowd – the boys and male staff of Kazimoto Secondary School.&lt;/p&gt;

&lt;p&gt;She was introduced to us one bitterly cold Monday morning. The assembly was as usual, a boring mind-numbing routine. The master on duty was a certain King’ori esquire, whose receding hairline, double chin and protruding belly, ‘inexplicably’ reminded me of those purebred Friesian cows that were always on exhibition at the agricultural show..&lt;/p&gt;

&lt;p&gt;“Good morning school?” he croaked, his watery eyes or rather eyeballs, for they seemed to have popped an inch from their blubber lined sockets, probably to make room for more fat roving around.&lt;/p&gt;

&lt;p&gt;‘Good morning sir” came the weak reply from the still green first formers or as they were more popularly referred to ‘monos’. They’d soon learn to ignore the pleasantries.&lt;/p&gt;

&lt;p&gt;“This morning I noticed som…”&lt;/p&gt;

&lt;p&gt;I lost him in a chuckle as someone made a face that implied he ate just as much, if not more than the said cow whose image his presence inspired.&lt;/p&gt;

&lt;p&gt;“…the staffroom will be…” he suddenly cut off mid-sentence as his eyes wandered in my direction.&lt;/p&gt;

&lt;p&gt;“Mwibani!” he barked with a twisted look that elicited more snickering than it scared.&lt;/p&gt;

&lt;p&gt;“Come forward and kneel down!” commanded a slit where his mouth was supposed to be. The rolls of fat had long since invaded and occupied mouth territory.&lt;/p&gt;

&lt;p&gt;My light moment fast came to a stop and I quickly marched forward in obedience. My knobby knees touched down next to the now seething King’ori. I couldn’t help but notice that at this range he now resembled the lovely Mukami, our school cow, which despite frequent bouts of mastitis still provided milk for our very thin tea. Little wonder I’d been having periodic episodes of flatulence. I was carrying on with this train of thought, completely at ease with my kneeling position, when Mr. Fanyakazi, the principal, stepped up.&lt;/p&gt;

&lt;p&gt;“Good morning school?” he boomed in a crisp clear voice.&lt;/p&gt;

&lt;p&gt;“Good morning sir” Mr. King’ori along with every student replied. No one in their right minds dared cross Mr. Fanyakazi. A man famed for his efficiency with words and preferred the talking done with his hands. Rumor had it that he was an ex Air Force officer with a judo black belt. But then again, the rumormongers swore Mr. King’ori was once a long-distance athlete. Quite a laughable idea I might add.&lt;/p&gt;

&lt;p&gt;“This morning I would like to introduce a new member of staff. Ms Madiba, please step forward”.&lt;/p&gt;

&lt;p&gt;There was an involuntary gasp as she stepped forward and settled next to me. She was a sight to behold! She was tall; light skinned and smelled of freshly picked roses. Behind her half-moon glasses were brown almond-shaped eyes that held you captive when you looked into them. They communicated trust with an element of laughter and I wanted to stare into them forever. Her grape-sized nose was just perfect and it gave way to luscious full lips that made one think of flowers and kisses and more flowers. She had a cute dimple on her left cheek that dipped ever so slightly as she smiled at the school. It was a beautiful, honest smile that boasted two rows of perfectly white teeth and lit up the gathering and I could almost swear the temperature went up 10 degrees. It was at this precise moment that Mr. King’ori, I suspect, and I fell hopelessly in love. Her breasts were firm and healthy – good for breastfeeding and a host of other things that only a randy teenager could think of. She wore one of those knee-length, body-hugging pencil skirts that ladies fancied in those days and it would later become her trademark. The red skirt with frilly edges merged perfectly into her ridiculously long and expertly shaped legs that disappeared into white pumps with inch-high heels.&lt;/p&gt;

&lt;p&gt;“Hello everyone” she chirped in that melodious voice that sounded like the choir of angels that sang to the shepherds and I had no doubt she was one of them, the angels that is.&lt;/p&gt;

&lt;p&gt;“Good… goo…Hel…” The assembly stuttered, unsure of how to respond to the informal greeting from this stunning lady who was somehow supposed to be their teacher.&lt;/p&gt;

&lt;p&gt;“Ms Madiba here will be joining the English department and am sure you will fully cooperate with her as she adjusts to the school” continued Mr. Fanyakazi, completely oblivious of the effect she was having on the boys. “Mr. King’ori, would you please assist her after this”.&lt;/p&gt;

&lt;p&gt;At the sound of those words, Mr. King’ori could barely contain himself. He shifted about his place and shuffled his feet uncomfortably. I shifted nervously away from him as I watched his eyes and waited for the pop that would announce their escape from their suffocating prison and ricochet of the ground towards Ms. Madiba. It didn’t come, obviously, and I somewhat relaxed my position.&lt;/p&gt;

&lt;p&gt;Mr. Fanyakazi rumbled on. Something about the library, or was it about the laboratories? Once or twice he glared in my direction as he mentioned the word discipline. I didn’t care anyway, I was in love, or so I thought at the time.&lt;/p&gt;

&lt;p&gt;Mr. Fanyakazi let us go. Mr. King’ori, a stupid grin plastered on his fleshy face, completely forgot about my misdemeanor as he gaily skipped towards her, fat rippling beneath his yellow polyester shirt and threatening to take out a button if stretched any further. I couldn’t help myself. I stuck a foot in his path and caught his left leg. His hundred-ton body turned, the fat momentarily delayed the fall and then he came crashing down like a meteorite. His hands were flailing about his side like a spider or in this case, a toad doing the breakdance and not making a very good job of it. I scrambled to my feet and moved away to watch my handiwork. He landed on his bottom exactly where I had been a second ago and yelped in pain, more from his wounded pride I supposed. He rolled on his back and tried to get up but only managed to look like a beetle trapped on its back by its smooth shell. I could barely stifle a laugh and had to look away as the other teachers rushed to his side and amid his outburst of obscenities, help him up.&lt;/p&gt;

&lt;p&gt;“You little nincompoop!” He shouted at me, his face all red and puffy. The other teachers struggled to restrain the raging bull and one of his buttons made good its threat. It flew right off and exposed a forest of mangy chest hair. That did it! I couldn’t hold myself any longer. I howled in laughter at Mr. King’ori’s tough luck. First impressions tend to last especially those that involved dirty chest hair and pretty damsels. Mr. Fanyakazi suddenly appeared behind me and hoisted me by my very short and not so clean khaki shorts.&lt;/p&gt;

&lt;p&gt;“My office this instant!” he ordered. As I was being led away, I could swear I saw Ms. Madiba wink at me, quite a morning this was turning out to be.&lt;/p&gt;

&lt;p&gt;Retribution came. In fact it came hard and fast, six times on my bottom, delivered by the school’s chief executive himself. Now Mr. Fanyakazi, through years of practice and refinement, preferred the soft spot midway between the thigh and bottom. This coupled with the fact that he looked like he could lift a heifer without breaking a sweat meant that I wouldn’t sit straight for a whole week. After leaving his office, let’s just say that I didn’t trip Mr. King’ori anymore.&lt;/p&gt;

&lt;p&gt;Back in class, noisy as usual, I padded my seat with a pullover ‘borrowed’ from an unwilling ‘mono’ and carefully settled my violated bottom down. As I busied myself trading insults with Matusi (the name says it all), in walked my new found love. The class immediately froze all attention focused on her.&lt;/p&gt;

&lt;p&gt;“Good morning class?” she greeted us as her eyes swept the class and settled on me. A bewitching smile slowly formed on her lovely face. Matusi noticed it and suddenly had a very nasty cough.&lt;/p&gt;

&lt;p&gt;“Good morning madam” the class replied.&lt;/p&gt;

&lt;p&gt;“I’d like us to start with introductions. Full name everyone and let’s begin with the first column.”&lt;/p&gt;

&lt;p&gt;How one could be so beautiful, I kept wondering to myself. The boys began introducing themselves. Ms. Madiba chose to sit down through the exercise. The short skirt crawled an inch up her thigh but further progress was quickly rebuffed by her hand. Now she had our absolute undivided attention. The class leaned forward, forty pairs of eyes itching to catch a glimpse of the glorious flesh. Matusi’s incessant coughing suddenly stopped. Then the skirt, as if urged on by the on looking perverts, seemed to take on a mind of its own and clawed its way up, determined to give the people what they wanted. The class held its breath and inwardly cheered on the sleek red cloth. Amazingly enough, Ms. Madiba remained oblivious of the drama playing out before her. Either she was one cool customer or she was deeply engrossed in Konyagiragi trying to spell his ridiculous name. Poor boy caught between an introduction and a powerful Neanderthal urge to steal a glance the lady’s legs.&lt;/p&gt;

&lt;p&gt;Now ladies, before you start rolling your eyes and begin the male bashing, look at it this way. Imagine confining a thousand or so androgen pumped adolescents for close to two months and denying them even a fleeting glance at anything feminine, except for Mukami. Then throw in a woman of goddess like beauty among them, much like throwing a cat among the pigeons or in this case, a pigeon among the much starved cats. Something is bound to happen; tempers would flare and the male ego would be on the line.&lt;/p&gt;

&lt;p&gt;The bell rang to signal the end of the first period. Ms. Madiba rose slowly and collected her things. The forty pairs of lustful eyes followed her every movement with intense concentration as if trying to sear her image onto their memories, probably for future processing with their wild imaginations.&lt;/p&gt;

&lt;p&gt;We had math next. A subject I was not particularly fond of and I preferred to while away my time by doodling on my book as Mr. Rutto droned on about vectors. Matusi’s nasty cough returned and would not leave until Mr. Rutto let him out to see the nurse.&lt;/p&gt;

&lt;p&gt;The day dragged on and by lunchtime everyone had heard about my little encounter and they could not help but stare at me in awe. Anyone who laughed at Mr. King’ori and survived the principal’s thrashing was a hero around here. If only they knew the pain my poor backside was nursing. Tough day it was.&lt;/p&gt;


          </description>
          <pubDate>Wed, 06 Nov 2024 10:53:37 +0300</pubDate>
          <link>https://www.kibetkoech.com/writing/back-in-high-school/</link>
          <guid isPermaLink="true">https://www.kibetkoech.com/writing/back-in-high-school/</guid>
          
          <category>high-school</category>
          
          <category>mischief</category>
          
          
          <category>high</category>
          
          <category>school</category>
          
          <category>mischief</category>
          
        </item>
      
    
      
        <item>
          
            <title>Back Tweak</title>
          
          <author> (Kibet Koech)</author>
          <description>
            &lt;h2 id=&quot;this-post-first-appeared-on-an-earlier-version-of-this-blog-which-unfortunately-went-down-with-all-my-data&quot;&gt;This post first appeared on an earlier version of this blog which unfortunately went down with all my data.&lt;/h2&gt;
&lt;p&gt;Earlier this year, on the ides of March, as I was pulling my first rep on the deadlift, I felt a pop in my lower back then a sharp jolt of pain radiating from there. My first thought was ‘Oh snap! There goes all my progress!’ (Expression has been translated from a popular non-PG phrase).&lt;/p&gt;

&lt;p&gt;I had recently watched a &lt;a href=&quot;https://youtu.be/riq-DfDDimc?si=J7NlKaNTR4h8Q9vo&quot;&gt;video&lt;/a&gt; on back pain from one of my favourite YouTuber’s, Allan Thrall, so I immediately followed his advice.
I set down the bar and started stretching my back; child’s pose, cat-cow and toe touches. I then did a couple of painful air squats then stopped the workout.
As soon as I got home I repeated the stretches and air squats; they were incredibly difficult. Walking was difficult, tying my shoelaces was excruciating, and twisting in my seat to get a pen was agonising. However, I did not despair. I knew that my back wasn’t that seriously hurt and the pain was just my brain trying its best to protect a pulled muscle so I ignored the pain as much as I could.&lt;/p&gt;

&lt;p&gt;All day long I kept getting up and stretching my back as well as doing air squats and toe touches. If I needed to pick something up, I forced myself to bend over and do it rather than compensate with my knees. In the afternoon I went to see a chiropractor and he made some adjustments. At night I slept on the floor and on my side rather than my stomach as is my norm.&lt;/p&gt;

&lt;p&gt;The next day my lower back still felt the need to test my resolve but I kept at it. I went to work as usual and did not complain about my back. I kept up with the stretching, squats and toe touches and had a second session with the chiropractor. By evening the tightness was beginning to melt away. I slept on the floor again.&lt;/p&gt;

&lt;p&gt;On Friday morning I was back at the gym. I did my chin-ups properly with no issues then squats with the empty bar and progressed to 10 reps of 60 kg with just some soreness. I also did 60kg deadlifts, bench presses, overhead presses and dumbbell rows. I did all my compound lifts with sub-maximal weights to test my back and they all felt fine! As a precaution, I did them all with a belt. As I went about my day I kept up with the stretches and movements.&lt;/p&gt;

&lt;p&gt;Monday morning I was in the gym and had resumed my program with no pain or soreness at all!
In conclusion, when you injure your lower back it probably won’t be a slipped disc or something serious like that. It’s most likely just a pulled muscle that feels painful and scary but if you face it head-on and don’t let it have a say, it will shrink and go away.&lt;/p&gt;

&lt;p&gt;Remember, this is not medical advice, just my experience with a back tweak.&lt;/p&gt;


          </description>
          <pubDate>Wed, 06 Nov 2024 10:53:37 +0300</pubDate>
          <link>https://www.kibetkoech.com/writing/back-tweak/</link>
          <guid isPermaLink="true">https://www.kibetkoech.com/writing/back-tweak/</guid>
          
          <category>gym</category>
          
          <category>injury</category>
          
          <category>back</category>
          
          <category>recovery</category>
          
          
          <category>gym</category>
          
          <category>injury</category>
          
          <category>back</category>
          
          <category>recovery</category>
          
        </item>
      
    
      
        <item>
          
            <title>Learning How to Learn</title>
          
          <author> (Kibet Koech)</author>
          <description>
            &lt;h2 id=&quot;the-following-is-an-essay-i-wrote-after-taking-the-course-learning-how-to-learn-on-coursera-as-taught-by-barbara-oakley-and-terrence-sejnowski-on-coursera&quot;&gt;The following is an essay I wrote after taking the course &lt;a href=&quot;https://www.coursera.org/learn/learning-how-to-learn&quot;&gt;Learning How to Learn on Coursera&lt;/a&gt; as taught by Barbara Oakley and Terrence Sejnowski on Coursera.&lt;/h2&gt;
&lt;p&gt;I have always been curious and keen to learn new things that interest me. Sometimes, I learn a lot, especially when I implement some kind of routine or system to help me study, but other times, it can be tough to nail down some material. After taking this course, I have come to a better understanding of how our brains learn, the mistakes I made when I failed, and the habits that helped me succeed when I did.&lt;/p&gt;

&lt;p&gt;One of the most memorable things I ever did was in my final year of high school. I formulated and implemented a near-perfect plan to study for my final year examinations and it had all the salient features that Dr. Oakley preaches in her course.&lt;/p&gt;

&lt;p&gt;First I looked up the high school curriculum and figured out what I needed to learn, then drew up a timetable with 30-minute chunks of serious concentration and five-minute breaks. I also scheduled time to work specifically on assignments, organised a serious study group that met after classes, tested myself endlessly with past papers and made participation in sports a priority. This was the most productive year of my secondary education, I learned 4 years’ worth of material in 9 different subjects in under 9 months! After taking this course, I realised I inadvertently stumbled upon a sure-fire way to study. Over time I seemed to forget this method, especially because learning as an adult now involves navigating ‘life’ and a host of other adult stuff, which is why I took this course.&lt;/p&gt;

&lt;h3 id=&quot;brain-modes&quot;&gt;Brain Modes&lt;/h3&gt;
&lt;p&gt;Your brain has two major modes of processing and understanding concepts and ideas:&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;The focused mode&lt;/li&gt;
  &lt;li&gt;The diffused mode&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The &lt;strong&gt;focused mode&lt;/strong&gt; is when you concentrate on learning something or are trying to solve a problem. You knit your eyebrows and stare intently at what you’re focusing on and after a while, you can hear the gears turning in your head as the solution takes shape. This mode helps us to form and deepen neural patterns for novel ideas or problem-resolution methods.&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;diffuse mode&lt;/strong&gt; is when you’re relaxed or doing something boring or routine like taking a bath and suddenly, eureka! Your brain unwittingly makes a connection seemingly from thin air and now you completely understand an idea or hit upon a novel solution to that pesky problem of how to tell gold apart from other metals.&lt;/p&gt;

&lt;p&gt;As you can tell by now both methods feed into each other and both must be engaged to fully tap into that supercomputer you lug around in your head all day. And here lies an important fact, allowing yourself to be comfortable with boredom is good. We all love our smartphones but they can actually be a hindrance when every time you are feeling bored or disconnected you whip it out and proceed to scroll through a dozen apps all to stave off boredom. Be bored, your subconscious speaks to you in these times and it does have some valuable insights to share if you just listen.&lt;/p&gt;

&lt;p&gt;It is important however to note that the diffuse mode will only work once it’s been served with sufficient material from the focused mode so it’s best to bash away at your problem and when you realize that no solution is forthcoming go take a walk or a bath or better yet, take a nap and before you know it, your mind will surprise you.&lt;/p&gt;

&lt;h3 id=&quot;pomodoro&quot;&gt;Pomodoro&lt;/h3&gt;
&lt;p&gt;This technique helps one to build a habit of focus and helps thwart procrastination by making one focus on the journey rather than the destination. It simply means that you eliminate all distractions for 25 minutes and concentrate on what you want to learn then take a five-minute break then repeat. After about 4 Pomodoro sessions you can take a longer 25-minute break before getting back to the material. Elite pomodorians can do several hours of focus without much effort and this is the holy grail of productivity since it will put you in a state of deep work (Cal Newport, &lt;em&gt;Deep Work&lt;/em&gt;) where you are immersed in the material for several hours and your output is phenomenal. If you learn nothing else from this course, learn this, it will vastly improve your studies and work life. You can buy an actual Pomodoro or like everything these days, there’s an app for that.&lt;/p&gt;

&lt;h3 id=&quot;chunking&quot;&gt;Chunking&lt;/h3&gt;
&lt;p&gt;Remember learning how to ride a bike? You had to remember to pedal, lean to one side while cornering, balance while pedalling, watch out for traffic and listen to the ‘helpful’ advice shouted by your friends. It was horrible; your senses were overloaded with all this information and more often than not you went back home with scraped knees and a wounded pride. But after a while, you got the hang of pedalling and before long you were whizzing down the street without thinking. This is because you learn all the basic moves you need to ride a bike by training your mind to form solid neural patterns that work in concert. This is a chunk. A solid compact, neural pathway of an idea or movement that you have locked down and you don’t have to think about retrieving it, your brain just knows what to do. Developing mastery in a specific field or topic means creating as many chunks on it as possible and what’s more, once you have the basic chunks down you can combine them with other chunks even from different fields and come up with novel ideas or concepts i.e. chunking enhances creativity.&lt;/p&gt;

&lt;p&gt;So how do we build chunks? Usually, we do so in the focused mode by practice and repetition until those neurons are purring. So, get rid of distractions, tune into the focused mode and try to understand the material you intend to chunk. Switching between the focused and diffuse modes will be of great help here and the Pomodoro technique can help you here. Try and grasp the gist of the central idea and link it with something else you know. Once you think you have understood something, test yourself to confirm. You should also see where the chunk fits in the grand scheme of things when to use it and when not to and how it relates with other chunks. Such depth in learning is useful to help you create bigger chunks and with time you will be a master.&lt;/p&gt;

&lt;h3 id=&quot;spaced-repetition&quot;&gt;Spaced Repetition&lt;/h3&gt;
&lt;p&gt;This is similar to what powerlifters do. They have a target weight to lift, and they know how much they can lift right now so they make a plan and add a little weight to the bar every day as a result, they add a little muscle every day and after a year it’s like magic! You study a little every day and go over the material later. Later can be hours, days or weeks depending on how well you’ve mastered it. You can revise using flashcards, recall or testing so that you can transfer the material from your short-term (working memory) into your long-term memory.
My people say that you cannot fatten a bull on the market day. Similarly, you cannot learn all your material on the test day just as you cannot build an impressive physique in one day of lifting heavy weights.&lt;/p&gt;

&lt;h3 id=&quot;sleep&quot;&gt;Sleep&lt;/h3&gt;
&lt;p&gt;Clears toxins from your brain helps consolidate long-term memories and activates the subconscious mind that works to form connections from all the material we learned while in a focused state. So make sure you catch your eight hours every day especially if you have a test the next day or have been hacking away at a problem for a while without making progress, chances are a good night’s sleep will help your brain work through the problem.&lt;/p&gt;

&lt;h3 id=&quot;habitszombies&quot;&gt;Habits/Zombies&lt;/h3&gt;
&lt;p&gt;Habits make a man. It is important to understand that success or learning does not come from some magic sauce, willpower or herculean effort or luck (well sometimes it does). It is by the daily habits we build and adhere to. If you build habits that inch you closer to your goal every day then a year of compounding those habits produces exponential results. Similarly, destructive habits like procrastination will compound and doom you to anxiety and failure.
To study well you need to harness the power of habits. Build tiny everyday habits that draw you closer to mastery of your study material daily and you need not rely on willpower or luck, you will be confident in yourself. To do this you need to understand how habits work.&lt;/p&gt;

&lt;p&gt;Habits are patterns of behaviour that are so ingrained in us that we don’t even realize that we’re doing them. Case in point: your phone rings while you are reading, your automatic response will be to pick it up because you have built a habit of responding once your phone wails for attention like a spoiled toddler. Dr. Oakley likens habits to zombies since just like zombies hungry for brains, you don’t have to think, you just act. This is a powerful element of our psychology, one that you can harness to help you study better. Make it a habit to study in the same place at the same time and with bursts of concentration and rewards and soon enough the zombies will be working for you. All you have to do is cue them and off they go. Wonderful, isn’t it? Cue-belief-behaviour-response.&lt;/p&gt;

&lt;h3 id=&quot;testing-and-illusions-of-competence&quot;&gt;Testing and illusions of competence&lt;/h3&gt;
&lt;p&gt;Merely rereading your material and going over the easy stuff can trick you into thinking you know your stuff when you really don’t. Deliberate practice can help you overcome illusions of competence by making you test yourself and then practise what you failed, not just the easy stuff. Consistently working on the things you find difficult is a habit that will lead you to mastery over time (&lt;em&gt;Outliers&lt;/em&gt;, Malcolm Gladwell). Remember, boiling seas make great sailors.&lt;/p&gt;


          </description>
          <pubDate>Tue, 05 Nov 2024 10:53:37 +0300</pubDate>
          <link>https://www.kibetkoech.com/writing/learning-how-to-learn/</link>
          <guid isPermaLink="true">https://www.kibetkoech.com/writing/learning-how-to-learn/</guid>
          
          <category>learning</category>
          
          <category>self-improvement</category>
          
          
          <category>learning</category>
          
          <category>self-improvement</category>
          
        </item>
      
    
      
        <item>
          
            <title>How To Develop Kenya - a concerned citizen’s approach</title>
          
          <author> (Kibet Koech)</author>
          <description>
            &lt;h2 id=&quot;this-post-first-appeared-on-an-earlier-version-of-this-blog-which-unfortunately-went-down-with-all-my-data&quot;&gt;This post first appeared on an earlier version of this blog which unfortunately went down with all my data.&lt;/h2&gt;
&lt;p&gt;Development can be loosely defined as the process that advances the population’s quality of life in a useful way. This broad definition includes economic development, human development, social development, and environmental sustenance.&lt;/p&gt;

&lt;p&gt;A while back economic development was the only dimension of development but as it turns out economic development does not necessarily improve the quality of life of a population.
Development is a complex concept with multiple facets that must be carefully considered and balanced over time to achieve the desired results.
Successive Kenyan governments have attempted to develop the country but one regime stands out, the Kibaki regime of 2003 - 2013. Other governments have had misplaced priorities, simplistic interpretations of development, have sought to politicise it, had little to no interest in actually doing the work or are just outright incompetent and corrupt like the current Jubilee government.&lt;/p&gt;

&lt;p&gt;The UNDP developed the &lt;a href=&quot;http://hdr.undp.org/en/content/human-development-index-hdi&quot;&gt;Human Development Index&lt;/a&gt; (HDI) about 3 decades ago centred on people and their capabilities as the chief criteria for assessing a country’s development rather than just economic growth. The 3 elements of the HDI are:&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;A long and healthy life&lt;/li&gt;
  &lt;li&gt;Being knowledgeable&lt;/li&gt;
  &lt;li&gt;Having a decent standard of living&lt;/li&gt;
&lt;/ol&gt;

&lt;h3 id=&quot;healthcare&quot;&gt;Healthcare&lt;/h3&gt;
&lt;p&gt;Specifically, basic high-quality universal healthcare. Every Kenyan should be able to walk into a health centre in their neighbourhood and be accorded free, high-quality, dignified basic health services. &lt;strong&gt;EVERY KENYAN&lt;/strong&gt;. This is just the first step in ensuring a healthy population that can engage in nation-building. A citizenry who is assured of such a service is more likely to be patriotic and think in terms of advancing themselves and the nation rather than worry about survival. This service ought to be exceptional and staffed by competent and motivated medics such that no private facility can compete. Mental health must be pushed into the mainstream. Advanced medical services like medical imaging, specialized surgical procedures etc. ought to be available in every sub-county in this nation. People should not have to travel hundreds of kilometres from Mandera to Nairobi to get life-saving chemotherapy.&lt;/p&gt;

&lt;p&gt;The selection, training, remuneration and welfare of healthcare workers should be a national priority as they will help give us a long, healthy and productive life.
Referral and research hospitals and institutions should be staffed with top-notch doctors, scientists and administrators and should be sufficiently encouraged to develop drugs, medical procedures and policies that will keep Kenyans healthy and kill medical tourism that is expensive and available only to the wealthy. Logistical and procurement institutions like KEMSA should be tightly monitored and continually pushed to deliver life-saving drugs, equipment and materials everywhere it is needed.
Finally, we can measure all this by using such indicators as life expectancy, infant mortality rate, number of functioning clinics, number of healthcare workers, number of patients treated, sick leave days taken etc.&lt;/p&gt;

&lt;p&gt;In my opinion, there are four key elements that successive Kenyan governments must prioritize over a long period of time to get things right. I am by no means suggesting that this will be a simple task to undertake but I do believe that 80% of our results will come from these four areas.&lt;/p&gt;

&lt;h3 id=&quot;education&quot;&gt;Education&lt;/h3&gt;
&lt;p&gt;Free high-quality education to tertiary education for every Kenyan. Most of us confuse schooling with learning. Schooling is mostly about confining students in classrooms and drilling them with information over and over again. Schooling discourages creativity and innovation, is rigid and goes against human instinct.&lt;/p&gt;

&lt;p&gt;When I talk about education my core focus is the development of the following core skills; independent thought, creativity, autodidactism, research, personal financial management and critical thinking. In addition, I think learners ought to interact and learn in their natural environment as much as possible i.e. they can visit a local river while learning about geographical features and have their class there. We also need to learn and appreciate our indigenous languages as they will help shape our identity. These competencies should be baked into the curriculum and learners ought to be exposed to them as frequently as possible as these are the critical skills for the holistic development of a person.&lt;/p&gt;

&lt;p&gt;Teachers just like medical professionals ought to be selected, trained, compensated and motivated as much as possible by both the government and society. We should strive for low teacher-to-student ratios that bring out the best in both parties. Schools with adequate facilities (classrooms, desks, books, water etc) should be a national priority. Every child should be able to walk a reasonable distance to the nearest school and expect to receive a world-class education to enable them to develop the very best versions of themselves.&lt;/p&gt;

&lt;p&gt;Co-curricular activities like sports, debates, and interest clubs should be funded and encouraged.&lt;/p&gt;

&lt;h3 id=&quot;agriculture&quot;&gt;Agriculture&lt;/h3&gt;
&lt;p&gt;In 2019, about half of Kenya’s exports were agricultural; tea, coffee, flowers, fruits, nuts, etc. formed the bulk of these exports. Kenya is a nation of farmers and that is where our economic focus ought to be. The government ought to encourage farmers by expanding current markets, seeking out new ones, providing high-quality farm inputs (fertilizer, seeds etc), building quality access roads, carrying out in-depth, cutting-edge research, and seeking to add value to raw products as much as possible to improve returns to the farmer and the country.&lt;/p&gt;

&lt;p&gt;Pumping money into irrigation projects, forestry and animal husbandry will reap greater rewards than borrowing billions to build railways to nowhere and roads from airports to affluent suburbs.&lt;/p&gt;

&lt;p&gt;Investing in agriculture makes sense since we already have a good farming foundation, excellent soils and climate, tons of unexplored potential in irrigation, value addition as well as branding and marketing, it gives excellent returns for the capital invested and we are not yet food-sufficient. Laser focus in this area will kick out poverty in most of the population and start many on the journey to upward social mobility.&lt;/p&gt;

&lt;h3 id=&quot;slay-mega-corruption&quot;&gt;Slay Mega Corruption&lt;/h3&gt;
&lt;p&gt;Corruption is difficult to eliminate as it is human nature to want to do things the easy way. However, we can crush the mega corruption that has ravaged this country in the last decade or so. Politicians borrowing money for dead-on-arrival grand projects so that they can pick up obscene kickbacks and buy massive fuel guzzlers to intimidate ‘wananchi’ should be done away with. These men and women hurt the economy more than we can tell and ruthlessly crushing such people is the best way to deal with their callousness. 
The EACC should be outfitted with massive fangs and a venom sac to boot, then set loose amongst mega looters. Retrieval of stolen funds and repossession of assets and material resulting from the proceeds of corruption will certainly help repress this vice.&lt;/p&gt;


          </description>
          <pubDate>Tue, 05 Nov 2024 10:53:37 +0300</pubDate>
          <link>https://www.kibetkoech.com/writing/how-to-develop-kenya/</link>
          <guid isPermaLink="true">https://www.kibetkoech.com/writing/how-to-develop-kenya/</guid>
          
          <category>development</category>
          
          <category>economy</category>
          
          <category>corruption</category>
          
          
          <category>development</category>
          
          <category>economy</category>
          
          <category>corruption</category>
          
        </item>
      
    
  </channel>
</rss>
