<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Wawira on Medium]]></title>
        <description><![CDATA[Stories by Wawira on Medium]]></description>
        <link>https://medium.com/@lindajoywawira?source=rss-aebb221c1154------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*hRqevbQ3-dNMERYTjPov-A.jpeg</url>
            <title>Stories by Wawira on Medium</title>
            <link>https://medium.com/@lindajoywawira?source=rss-aebb221c1154------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 15:20:47 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@lindajoywawira/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How To Approach A Machine Learning Project(Part 2)]]></title>
            <link>https://lindajoywawira.medium.com/how-to-approach-a-machine-learning-project-part-2-f083eea6ce36?source=rss-aebb221c1154------2</link>
            <guid isPermaLink="false">https://medium.com/p/f083eea6ce36</guid>
            <dc:creator><![CDATA[Wawira]]></dc:creator>
            <pubDate>Mon, 05 Apr 2021 04:46:54 GMT</pubDate>
            <atom:updated>2021-04-05T04:46:54.688Z</atom:updated>
            <content:encoded><![CDATA[<h4>This is the second part of the series, focusing on data preprocessing and visualization.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*X73P0M2j4_bWfpKq2MviIA.gif" /></figure><p>In this tutorial, we focus on Data Preparation that entails cleaning data, feature engineering and selecting data that will be used for analysis .</p><p>Feature Engineering refers to the process of extracting and transforming variables that will be used for analysis.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*aD1TwpNln-Zo4_VgUalwDA.gif" /></figure><p>We need to check on all our files provided- The training file, the testing file and the submission file. In most cases, the training set and the test set have the same format. It is important to check on the submission file to understand how the final results should be presented.</p><p>The training set:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1021/1*W0q2xjldc50QjEp8B4HvOA.png" /></figure><p>The test set:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/996/1*wug_NWfoDALB8DN9rFy6iQ.png" /></figure><p>The submission file:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/996/1*SGXVjwuKW6qKE3GyaoW_7w.png" /></figure><p>It is true to say that our data has many features which can be unhealthy for machine learning. Many features may cause<strong><em> overfitting</em></strong>.</p><p>The submission file has fewer features — this gives a hint on which columns to focus on when it comes to feature engineering.</p><p>In data preparation,its a good practice to combine the train set and test set: especially when dealing with categorical variables,it helps maintain consistency between them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/962/1*CdTeO-tPtoESiulUviKsvg.png" /></figure><p>Its worth noting that after concatenation of the dataset will still maintain the same number of columns.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5ig29U1shB059BvIR4YehQ.png" /></figure><p>The describe() function gives a summary of all numerical variables in the dataset.</p><p>Next, we get the age of the customers and visualize it on a graph.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f5eCwM_WwVQ0jOFjYjVF-A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/676/1*CeobXJo997y8aQUYFdGwfw.png" /><figcaption>Age distribution</figcaption></figure><p>Its true to say that most of the customers are between 30–40 years.</p><p>The biggest problem with our data is that it has too many features which can cause the curse of dimensionality<strong>. </strong>It is hard to visualize and analyze data with too many dimensions.</p><p>The best way to solve this is by using the <strong><em>Pandas.melt()</em></strong> function. This function is used to format a wide to long dataset.</p><p>Add the products to a multidimensional array:</p><pre>products=full_df[[&#39;P5DA&#39;,&#39;RIBP&#39;,&#39;8NN1&#39;,&#39;7POT&#39;,&#39;66FJ&#39;,&#39;GYSR&#39;,&#39;SOP4&#39;,<br>&#39;RVSZ&#39;,&#39;PYUQ&#39;,&#39;LJR9&#39;,&#39;N2MW&#39;,&#39;AHXO&#39;,&#39;BSTQ&#39;,&#39;FM3X&#39;,&#39;K6QO&#39;,&#39;QBOL&#39;,&#39;JWFN&#39;,&#39;JZ9D&#39;,&#39;J9JW&#39;,&#39;GHYX&#39;,&#39;ECY3&#39;]]</pre><p>Apply the Pandas.melt function:</p><pre>final_df=full_df.melt(id_vars=full_df.columns[:8],value_vars=products,var_name=&#39;PCODE&#39;,value_name=&#39;Label&#39;)</pre><ul><li>id_vars are the columns that are used as identifier variables.</li><li>value_vars are the columns to unpivot.</li><li>var_name is the name to use for the ‘value’ column.</li></ul><p>Next, we add the column <em>combiner </em>which has a constant value of “X”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/879/1*rJ0SA7Zid3v5TczNCOntLg.png" /></figure><p>We need to concatenate the two columns in our dataset as per the submission file:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FLmgrsXFaaoj4swxeO_Zow.png" /></figure><p>The label columns consists of 2 values — 0 and 1.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1019/1*wKrsdsfMhpNiHD2DdAbZhQ.png" /></figure><p>Next, Our dataset has too many categorical features that need to label encoded.</p><p>Label encoding is the art of converting the labels into numeric form so that it can be easily read by a machine. The columns we should pay attention to are :<em>branch_code,occupation_code,occupation_category_code,PCODE,sex and marital_status.</em></p><pre>label_object = {}<br>categorical_columns = [&#39;branch_code&#39;,&#39;occupation_code&#39;,&#39;occupation_category_code&#39;,&#39;PCODE&#39;,&#39;sex&#39;,&#39;marital_status&#39;]<br>for col in categorical_columns:<br>    labelencoder = LabelEncoder()<br>    labelencoder.fit(final_df[col])<br>    final_df[col] = labelencoder.fit_transform(final_df[col])<br>    label_object[col] = labelencoder</pre><p>From this we get a fully encoded dataset!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/1*AEqtKTUMxox4FeqlgMOnAw.png" /></figure><p><strong>Side Note: After this tutorial series we will focus on creating visualizations with seaborn.</strong></p><p>The next Part of this series we will focus on modelling and deployment.</p><p><strong><em>Important Resources…</em></strong></p><ol><li><a href="https://www.journaldev.com/33398/pandas-melt-unmelt-pivot-function#:~:text=Pandas%20melt()%20function%20is,two%20columns%20%E2%80%93%20variable%20and%20value.">Pandas.melt() Function</a></li><li><a href="https://zindi.africa/hackathons/the-zimnat-insurance-assurance-challenge">Zimnant Competition</a></li><li><a href="https://builtin.com/data-science/recommender-systems">Recommender Systems</a></li></ol><p><em>Special thanks to Nairobi Women in Machine Learning &amp; Data Science and AI Kenya.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f083eea6ce36" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How To Approach A Machine Learning Project(Part 1)]]></title>
            <link>https://lindajoywawira.medium.com/how-to-approach-a-machine-learning-project-part-1-594b6fc06466?source=rss-aebb221c1154------2</link>
            <guid isPermaLink="false">https://medium.com/p/594b6fc06466</guid>
            <dc:creator><![CDATA[Wawira]]></dc:creator>
            <pubDate>Tue, 16 Feb 2021 07:54:55 GMT</pubDate>
            <atom:updated>2021-02-16T07:54:55.096Z</atom:updated>
            <content:encoded><![CDATA[<h4>A complete guide to approaching typical Machine Learning projects.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*9o6yfqw-xegEmN6HMdBwnA.jpeg" /></figure><h3>Introduction</h3><p><em>This tutorial series covers the following:</em></p><ol><li>Basic Data Science Concepts.</li></ol><p>2. Introduction to the CRISP-DM Methodology (each step explained).</p><p>3. Solving the Machine Learning Problem using the CRISP-DM.</p><p>In this guide, we will use the Zimnant insurance competition on <a href="https://zindi.africa/?gclid=Cj0KCQiAvP6ABhCjARIsAH37rbSct8FO3bWbNgm-LCnejuYzBMECqjJiiu72Ds3R_LbRPZddlABNMW8aAsfHEALw_wcB">Zindi</a> to explain some Data science concepts.</p><h4>The Challenge</h4><p><em>‘For insurance markets to work well, insurance companies need to be able to pool and spread risk across a broad customer base. This works best where the population to be insured is diverse and large. In Africa, formal insurance against risk has been hampered by lack of private sector companies offering insurance, with no way to diversify and pool risk across populations.</em></p><p><em>Understanding the varied insurance needs of a population, and matching them to appropriate products offered by insurance companies, makes insurance more effective and makes insurance companies more successful.</em></p><p><em>At the heart of this, </em><strong><em>understanding the consumer of insurance products helps insurance companies refine, diversify, and market their product offerings</em></strong><em>. Increased data collection and improved data science tools offer the chance to greatly improve this understanding.</em></p><p><em>In this competition, you will leverage data and ML methods to improve market outcomes for insurance provider Zimnat, by matching consumer needs with product offerings in the Zimbabwean insurance market’</em></p><h4>Type Of Problem</h4><p>The dataset focuses on building a predictive model that will meet the individual needs of all customers and ensure their personal preferences are prioritized.</p><p>Its true to say that we are building a recommendation engine a subclass of information filtering that seeks to predict the “Rating” or “Preference” a user would give to an item.</p><p>Content-Based filtering will be used in this competition.The system finds the similarity between products based on its context or description. The user’s previous history is taken into account to find similar products the user may like. Personal information is also taken into account in this scenario.</p><h4>CRISP-DM Methodology</h4><p>The CRISP-DM is a structured approach to solving any machine learning project with different tasks namely:</p><ol><li>Business Understanding — Part 1</li><li>Data Understanding — Part 1</li><li>Data Preparation — Part 2</li><li>Modelling — Part 2</li><li>Deployment — Part 3</li></ol><p>More information on this can be found <a href="https://www.sv-europe.com/crisp-dm-methodology/">here</a></p><h4>Business Understanding</h4><p>Here the business objective is set, converted into a data mining problem and designed to achieve its objectives.</p><p>The business problem is:<em>How can we make services reliable, increase customer traffic,how can we deal with the supply and demand of different products and reduce company losses?</em></p><p>Getting to know the business problem will give you a clear guideline on what to significantly solve.</p><p>Understand the Business Problem . This will help in building a model that is significant to the business.</p><p>It’s worth noting that machine learning can’t solve all business problems;defining a business problem will tell whether machine learning is a necessity or a non-necessity.</p><h4>Convert It To a Data Problem</h4><p>Building a good recommender system for Zimnant can be one of the ways that can improve the business. Customers are likely to get hooked to sites that provide personalized views and prioritizing items that are likely to be of interest to the user. A good example being Netflix.</p><p>This brings us to the analysis question:<em> Can we predict products that a customer is likely to use with both the external and internal factors?</em></p><h4>Data Understanding</h4><p>In this stage, will focus mainly on the data. Here we check on the data’s quality and completeness,exploration of variables and their relationship and get a brief description of the data.</p><p>The importance of this stage is:</p><ul><li>Identify data quality problems.</li><li>Helps you get familiar with data;Understanding the variables and their relationship.</li><li>Helps in transforming the variables into their correct formats.</li></ul><p>Data understanding has the following steps:</p><ol><li>Set up Your work environment.</li><li>Describe and Explore Data.</li></ol><h4>Set Up Your Work Environment.</h4><p>Import necessary Libraries and import the required datasets.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fW469RqlEB32OWCNOXN5sA.png" /></figure><p>Next, we read all the CSV files …</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/956/1*DTLKn4huWAy4xeXENy6mJA.png" /></figure><p>The shape function in the Pandas library outputs the number of rows and columns respectively.</p><p>The training dataset is larger in most cases because the model will learn more and improve on prediction accuracy if the data is randomized well.</p><p>However, other Data Scientists prefer when the test set is larger to reduce the problem of overfitting.</p><p>The sample file simply gives a format on how the final output should be after the model has been deployed.</p><h4>Exploratory Data Analysis</h4><p>Next we check on the different columns in the data….</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JY3F2ME4BwMxlQNG-FWCdw.png" /></figure><p>Assess the different columns and try to understand each variable as per the real world scenario:</p><ol><li>ID is unlikely to affect the kind of product a user is likely to use.</li><li>join_date — Join date can affect a customer’s product preference based on the popularity and novelty of the product.</li><li>Sex is likely to affect what products an individual is likely to use,say,women are likely to buy more beauty products as compared to men.</li><li>Marital Status-This can affect the products a user is likely to use.</li><li>Birth Year — Age can affect the products a user is likely to use.</li><li>Branch code is likely not to affect the recommendations of a user.</li><li>Occupation code ,Occupation Category code- Can also affect which products a customer can afford.</li><li>The other columns are just codes for the different products that the insurance company offers.</li></ol><p>Coming up with your hypothesis helps in the think through process,gives you a clearer picture on which columns you should focus on.</p><p>Next,use the pandas.describe() function to view statistical details of the numeric variables.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G_Fn49dLf51cgPH5uWFKhw.png" /></figure><p>You can also use the pandas.info() function to print a concise information about the dataframe.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/563/1*U_5rkU1PlninHlqNcoSd6g.png" /></figure><p>With this its easy to identify the columns with null values and columns that need to be transformed.</p><p>In this step, It is also important to identify the categorical and numerical variables.</p><p>If you dealing with categorical data:</p><ul><li>Identify the different classes</li><li>import the value_counts() function to get the counts of all unique values</li></ul><p>Its true to say that our data is long which can be a problem when it comes to modelling.</p><p>Data understanding is a step that gives a blueprint on what to work on in Data Preparation.</p><p>The next Part of this series we will focus on Data Preparation and modelling.</p><p><strong><em>Important Resources…</em></strong></p><ol><li><a href="https://www.sv-europe.com/crisp-dm-methodology/">CRISP-DM <em>Methodology</em></a></li><li><a href="https://zindi.africa/hackathons/the-zimnat-insurance-assurance-challenge">Zimnant Competition</a></li><li><a href="https://builtin.com/data-science/recommender-systems">Recommender Systems</a></li><li><a href="https://www.dataquest.io/blog/data-science-glossary/">Data Science Jargon</a></li></ol><p><em>Special thanks to Nairobi Women in Machine Learning &amp; Data Science and AI Kenya.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=594b6fc06466" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>