<?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 Kenechi Ojukwu on Medium]]></title>
        <description><![CDATA[Stories by Kenechi Ojukwu on Medium]]></description>
        <link>https://medium.com/@kenechiojukwu?source=rss-4d22af97a0f8------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*GPU32yt1uCsPXcBSTLfESw.jpeg</url>
            <title>Stories by Kenechi Ojukwu on Medium</title>
            <link>https://medium.com/@kenechiojukwu?source=rss-4d22af97a0f8------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 17:06:14 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kenechiojukwu/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[SecureX — Surveillance, Security, and Safety.]]></title>
            <link>https://kenechiojukwu.medium.com/securex-surveillance-security-and-safety-8be90ac5c292?source=rss-4d22af97a0f8------2</link>
            <guid isPermaLink="false">https://medium.com/p/8be90ac5c292</guid>
            <dc:creator><![CDATA[Kenechi Ojukwu]]></dc:creator>
            <pubDate>Wed, 31 Dec 2025 14:01:55 GMT</pubDate>
            <atom:updated>2025-12-31T14:01:55.363Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IcpKHRoEUBlLAbkOJHb_2A.png" /></figure><h3><strong>PROLOGUE:</strong></h3><p><strong>X </strong>marks the spot, and in this article, <strong>X</strong> is Nigeria.</p><h3>INTRODUCTION:</h3><p>Secure Nigeria is an intelligent software application created to protect Nigerians, starting with security awareness as they go about their daily activities using live information. The application combines intelligent learning algorithms, map technologies, social media platforms, and more to offer real-time information about the users&#39; surroundings and potential threats in areas along their route.</p><h3>AIM:</h3><p>The sole purpose of Secure Nigeria is to protect the Nigerian citizens through <strong>“informative-foresight”</strong>. The platform provides a channel for collecting, analyzing, and presenting negative events occurring en route to the registered users’ specified destination(s), possibly before departure or during transit. Additional features that provide low to mid-level evacuation assistance in the event of being caught in a crisis are in development.</p><h3><strong>RESEARCH</strong>:</h3><p>To understand the entirety of this project, it will be broken down into three major components;</p><ul><li>Nigeria.</li><li>Informative Foresight.</li><li>Intelligent Software System.</li></ul><p><strong><em>Nigeria</em></strong>:</p><p>Starting with the first component of this project, it is essential to have a realistic understanding of Nigeria in the areas of <em>security and safety</em>, as well as the <em>country’s technological capabilities</em> and <em>economic strength</em>.</p><p>- <strong>S</strong>ecurity &amp; <strong>S</strong>afety:<br>Nigeria emerges as one of the top countries in the world, characterized by a high crime rate and a low safety index. This ranges from organized crime acknowledged on a global scale, terrorism, to theft and harassment occurring in local neighborhoods [1][2][3][4]. With the steady decline in safety and increase in crime rate, we give a brief but essential overview of the current capability of Nigeria’s security infrastructure available to everyday people.</p><p>The <strong>Nigeria Police Force</strong> (N.P.F) is known to be the closest security agency to its people. The primary responsibilities of the N.P.F are the maintenance of law and order, and the provision of security in the form of protection of lives and properties within the jurisdiction of the country. It is said that the best days of the N.P.F. were in the early 1970s and 1980s, when prestige and honor were abundant. Sadly, due to a plethora of issues — such as being poorly funded and armed, poor training, understaffing, and lack of security-specific technology — the N.P.F has undergone a continual degradation in capability and professionalism, to the point where its existence poses a threat to the citizens it is sworn to protect [7][8][9].</p><p>- <strong>T</strong>echnological <strong>C</strong>apabilities:<br>Recently, technology on a global scale has seen a myriad of advancements in various digital sub-sectors such as artificial intelligence, data analytics, blockchain, Internet of Things, and more. Without doubt, it is evident to see its applications in various institutional sectors; in this case of interest, the security sector. Examples that accentuate these applications in this area include: utilization of Autonomous Drone Technology for deployable surveillance, Security cameras equipped with state-of-the-art face detection and recognition algorithms, data analysis and pattern recognition for criminal activities, and an interconnected network of surveillance devices capable of alerting security officials on criminal activities or possibly man-made disasters.</p><p>While these breathtaking technological innovations continue to advance on a global scale, adapting them to the country’s needs is no easy task. The lack of necessary and basic infrastructure needed to accommodate these new advancements poses to be the first and major wall in an onion of walls.</p><p>Following closely after inadequate architecture is inadequate funding; it is well known that these advancements do not come cheap, and streamlining them to country-specific use-cases comes with added cost. The list continues, but with the aforementioned, we get to have a clear sense of the primary factors that inhibit accommodating these advancements in the country, Nigeria. [10][11][12][13]</p><p>- <strong>E</strong>conomic <strong>S</strong>trength:<br>On the subject of the economic prowess of the country, there have been fluctuations, but overall, both growth rates and GDP per capita have declined between 2014 and 2024. The GDP per capita annual growth rate from 2014 to 2024 is -12.6%.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1019/1*Fi-fgDIQTe-ksiM3-0mZaQ.png" /><figcaption>GDP PER CAPITA (2014–2024) NIGERIA [23]</figcaption></figure><blockquote>What is GDP PER CAPITA? Well, GDP (Gross Domestic Product) is a method used to measure a country’s economic output for a specific period of time. It is the total of all the goods and services a country&#39;s economy produces over a specified period. “Per Capita” here translates to “Per Person”. Hence, GDP per Person is a way to infer, to some degree, the economic output an individual contributed to the specified year. In 2014, the GDP per captia was approximately $3,200, last year, 2024, the GDP per capita was approximately $800.</blockquote><p>From December 2014 to December 2024, the country has sluggishly but steadily reached an annual inflation rate of approximately 17% [20][21][22]. Due to the weak job creation capability and entrepreneurial prospects, 3.5 million Nigerians entering the job market every year will be left with nothing substantial to do. This places Nigeria 7th lowest in the world human capital index [5].</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j_5cy79Wr2H-u9U1XuRiuw.png" /><figcaption>CUMMULATIVE CPI LINE CHART (2014–2024) NIGERIA [24]</figcaption></figure><p>And the Full Consumer Price Index (CPI) table from 2014–2024.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/651/1*jNIdZX_F2UHlKeqfiQ2MlQ.png" /><figcaption>Consumer Price Index Table (2014–2024) [22]</figcaption></figure><blockquote>What is CPI, and what is it telling me? Consumer Price Index (C.P.I) is a measure used to track the change in price of a collection of goods and services over a period of time. It plays an essential role in tracking inflation and the standard of living in a community. A good rule of thumb to follow is; an increase in CPI is an indication of inflation and a decrease in CPI is an indication of deflation. However, a caveat exists, a 2–5% annual inflation rate is fine especially if it is backed by more stable jobs, good standard of living, etc. Annual Inflation rates &gt;15% are often a very bad sign, indicating either that the country population is growing faster than it can accommodate, or it has poor exchange rates and terrible standards of living.</blockquote><p>We can see how the steady decline in the economic strength has a direct relationship to the rise in the crime rate and the near absence of safety for its citizens.</p><p>Despite this understanding, we still recognize that safety and security are essential needs for everyone.</p><p>Now, we ask: how can we use this evolving technology to help people feel safe? How do we make any solution affordable? Where should we start?</p><p><strong>Informative Foresight</strong>:</p><p>The term “informative-foresight” consists of two separate words — “informative”, which can be described as providing useful and factual information [25], and the latter term “foresight”, best described as “the <a href="https://dictionary.cambridge.org/dictionary/english/ability">ability</a> to <a href="https://dictionary.cambridge.org/dictionary/english/judge">judge</a> <a href="https://dictionary.cambridge.org/dictionary/english/correctly">correctly</a> what is going to <a href="https://dictionary.cambridge.org/dictionary/english/happen">happen</a> in the <a href="https://dictionary.cambridge.org/dictionary/english/future">future</a> and <a href="https://dictionary.cambridge.org/dictionary/english/plan">plan</a> <a href="https://dictionary.cambridge.org/dictionary/english/your">your</a> <a href="https://dictionary.cambridge.org/dictionary/english/action">actions</a> <a href="https://dictionary.cambridge.org/dictionary/english/based">based</a> on this <a href="https://dictionary.cambridge.org/dictionary/english/knowledge">knowledge</a>”[6]. The combination of both words gives us a clear idea of what the definition should be. In this case study, informative foresight is being able to take the necessary actions with delicate information provided about areas that pertain to you in real time.</p><p><strong>Intelligent Early Warning Software System:</strong></p><p>The primary aim of this case study is to build an early surveillance, detection, and warning intelligent system capable of retrieving information about negative events happening in specified areas (specified by you) as soon as it becomes digitally available. Once this vital information is retrieved, it alerts registered users about the incident, providing the best course of action to take.</p><p>It should be noted that additional features will be included over time.</p><h3><em>Bringing The Three Components Together:</em></h3><p>Addressing each component allows us to understand them as a single unit. The goal of Secure Nigeria is to provide a thread that seamlessly binds these components together. For this case study, we understand the challenges in providing adequate security to the citizens of Nigeria. We see how the economic standing of the country affects every sector, which in turn affects the citizens in multidimensional ways. While it can be said that there are many challenges to solve, this project aims to start with the problem of security, or the lack thereof, for the everyday person.</p><p>Referencing the globally known protest that occurred in Nigeria in October 2020 as a starting point. We see the pivotal role social media — specifically X, formerly known as Twitter — played in that protest. With the right information, provided at the right time, people can be well informed and mobilized to or away from certain areas for security and safety reasons, respectively. We can see the feasibility of using information provided in real-time by on-site citizens to warn and protect others, thereby reducing or eliminating casualties.</p><p>A research study on utilizing Twitter data for COVID-19 surveillance underscores the positive feasibility of using the social platforms to predict COVID-19 outbreaks in advance in the US. The paper discusses training a multi-linear regression model with temporal information (time data) embedded in the curated data.</p><p>The curated data consist of a dependent variable Y, and three explanatory variables x1, x2, and x3. According to the paper, Y is the COVID-19 confirmed cases, x1 is the COVID-19 confirmed cases per state, x2 is the tweet counts per state per day, and x3 is the positive classified tweet counts per state per day. Feel free to refer to the <a href="https://pmc.ncbi.nlm.nih.gov/articles/PMC8920081/">paper</a> for a more in-depth view on the full formula.</p><p>It proceeds to train models on various day intervals, i.e, forecasting 1 day prior, 2 days, 3 days, etc. At the US level prediction, an R-squared correlation coefficient of 0.909 for 6 days prior was achieved on the validation data, where the paper indicates this to be an acceptable value. When the predicted number of COVID-19 cases exceeds the set threshold, a message is sent to all users [17].</p><blockquote>In linear Regression, R-squared correlation coefficient is a statistical measure that determines the proportion of variance in a dependent variable Y that is explained by the independent variables (x1,x2,…,xn) in a regression model. Hence, an 0.909 R-Squared Correlation Coefficient score means the indpendent variables were able to explain 90.9% of the dependent variable.</blockquote><p>Another paper aims to demonstrate the usefulness of social media, Twitter, as a real-time method for Ebola outbreak surveillance to —</p><blockquote>“monitor information spread, capture early epidemic detection, and examine content of public knowledge and attitude”[26].</blockquote><p>The paper introduces the terminology <em>“dissemination”,</em> which can be defined as the sum of the followers of users who posted or retweeted a tweet relating to Ebola. Although I have a few reservations about how dissemination is calculated, I believe it still highlights the rate of spread of information.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y8FrS5XVLyQ0jTb2FWMzFw.png" /></figure><p>The graph shows that as of Jul 24, after the first case was discovered in Lagos and the information made it to Twitter, 101 tweets (posts + retweets) were disseminated to about 1,196,793 people (total follower count of all the users that posted and retweeted Ebola-related tweets), and the values continue to increase as Health organizations release Ebola-related updates and information.</p><p>The paper also provides some insights into the various ways social media could be used as a real-time tool for awareness in other healthcare use cases. Aside from monitoring the rate of information spread on health-related issues for possible early outbreak detection, understanding the sentiments the people have around health-related issues provides the right organizational bodies with a better understanding of how to approach the people, how to quell their fears, what fears to quell, and how to provide the right information in areas or topics that seem to incite confusion.</p><p>In this digital age, social media is the fastest way to share information that has the potential to reach users on a global level, possibly invoking global attention and discussions[14][15]. With that being said, the current decline in Nigeria’s economic standing and multidimensional poverty has made it exponentially harder for the common man to afford basic amenities, like a smart mobile device, and also, to some degree, the adequate technical know-how to utilize the smart mobile device.</p><p>Taking apart this colossal problem one brick at a time, we start with a trickle-down approach, which slowly but gradually transitions into an economies-of-scale strategy. Some light will be shed on what I mean by this further in the article.</p><h3><strong>What services does SecureX (Nigeria) provide?</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/913/1*37RJlJQ3lw8TRbuTXmildg.png" /><figcaption>SecureX Landing Page</figcaption></figure><p><strong>Live Information</strong>: We start with awareness. We provide a web platform accessible to anyone. As mentioned earlier, the platform aims to act as an early warning surveillance system, utilizing information on social media as soon as it becomes available.</p><p>To prevent “negative information” overload (In this case, reported cases), we request that users specify areas they visit frequently, and through their preferred mode of contact (email or mobile number), we alert them as soon as information about their area of interest becomes available.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/514/1*oTCcFLLaaCsmAGF_a8sgQA.png" /></figure><p><strong>NOTE</strong>: We suggest the use of landmarks such as ‘yaba, Lagos, Nigeria’, ‘Ikeja, Lagos, Nigeria’, ‘Lekki, Lagos, Nigeria’, etc., when adding locations as opposed to the use of detailed addresses.</p><p>The alert information provided consists of the description of reported negative events (e.g., fire outbreak, collapsed tanker, robbery, etc.), the time it occurred or was reported, the category level of the event, and the possible precautions you can take to ensure your safety.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T9yM_gEGTKTYmHKzZRVd0g.png" /><figcaption>Saftey Measures.</figcaption></figure><blockquote>What does category-level mean ?</blockquote><p>Here, we group negative events into categories that attempt to portray the severity level of the threat. It aims to give the user a sense of how dangerous the reported negative event is.</p><p>An event of CATEGORY-3 indicates the event has or could potentially lead to the loss of lives in large numbers. Examples of such could be explosions, terrorism, large-scale fire outbreaks, etc.</p><p>The order of threat level is as follows:</p><blockquote>CATEGORY-3 &gt; CATEGORY-2 &gt; CATEGORY-1</blockquote><p>We have two other category levels;</p><p>CATEGORY-0: This category level indicates Bio-related events such as contagious flu outbreaks, COVID-19, Ebola, etc.</p><p>CATEGORY-4: This category level indicates Natural Disaster-related events, such as flooding, landslides, etc.</p><p>We assume that these two events would occur seldomly depending on your ‘X’ -country’s location on the globe, hence we emphasize more on the 3 other category levels that occur often.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ga1U6B5sbUpuNfFACTdgwA.png" /></figure><p><strong>Emergency Contacts</strong>:</p><p>We give paid users the avenue to add contacts who should receive their current location in cases where things could go haywire. We stream user location via map to a unique URL sent to the emergency contacts, or if preferred, we send location updates periodically via sms till the user turns it off, no internet connection, or the allocated time runs out.</p><p>In an urgent situation, the user is required to press and hold the distress button for a few seconds. Depending on the selected mode of distress alert action selected by the user, the emergency contacts would receive the message accordingly.</p><p><strong>Family and Friends</strong>:</p><p>The family and friends feature ties to the statement made earlier.</p><blockquote>we start with a trickle-down approach, which slowly but gradually transitions into an economies-of-scale strategy.</blockquote><p>Paid users are provided with slots to add family members or friends who should receive alerts on negative events that could happen en route to their own frequently visited areas. Two location slots are allowed for each family or friend added. Users under the Family and Friends slots, once capable or convinced about the platform’s capability, can then register to become actual users. It should be noted that Users who transition from Family and Friends to full users would be removed from the Family and Friends slot automatically.</p><p>As the paid user base grows, reducing subscription fees to more accessible rates could incentivize free-tier users to upgrade. This would increase adoption of the Family and Friends feature, extending safety coverage to more people.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/867/1*gCBobvv-s2h9m_Rugc0XVw.png" /></figure><blockquote>Why a web Platform ? Isn’t this best suited for a mobile app ?</blockquote><p>Simple Answer: Yes, it is.</p><p>Our goal is to minimize the requirements needed to use our service. To access the website, users only need two things: the web URL and an internet connection. A mobile app, on the other hand, requires you to have a mobile device, and in most cases, a “smart” one.</p><p>One of the attributes of the platform is easy accessibility. Nigeria has an estimated population of 235 million people, where 107 million users have access to the internet, with 38.7 million people having social media accounts as of January 2025 [18]. We also see that a large percentage of people do not have access to smart mobile devices, which could explain why the social media accounts are quite low despite having 107 million people who have access to the internet [19]. We assume here that having a good device enables you to have better, easier, and more frequent access to social media platforms.</p><p>It is safe to infer that a large percentage of the population with internet access may not necessarily have access to capable devices to utilize social media apps, but can still utilize the internet to some degree. We are aware that, aside from financial capability, technical literacy is also a contribution to the percentage.</p><p>With this being said, the proposed road map for SecureX includes the development of a mobile application.</p><p>As we begin with this set of features, improvements and additional features will be done in the foreseeable future of the application.</p><p>Link to Platform: <a href="http://www.tc-securex.com/">Secure X</a>.</p><p>Resources:</p><ol><li><a href="https://www.numbeo.com/crime/country_result.jsp?country=Nigeria">https://www.numbeo.com/crime/country_result.jsp?country=Nigeria</a></li><li><a href="https://nairametrics.com/2023/09/27/nigeria-ranks-sixth-in-the-world-second-in-africa-for-organized-crime-report/#:~:text=Home%20Business%20News-,Nigeria%20ranks%20sixth%20in%20the%20world%2C%20second,Africa%20for%20organized%20crime%20%E2%80%93%20Report&amp;text=Nigeria%20is%20ranked%20sixth%20in,corruption%2C%20and%20other%20criminal%20activities">https://nairametrics.com/2023/09/27/nigeria-ranks-sixth-in-the-world-second-in-africa-for-organized-crime-report/#:~:text=Home%20Business%20News-,Nigeria%20ranks%20sixth%20in%20the%20world%2C%20second,Africa%20for%20organized%20crime%20%E2%80%93%20Report&amp;text=Nigeria%20is%20ranked%20sixth%20in,corruption%2C%20and%20other%20criminal%20activities</a>.</li><li><a href="https://businessday.ng/news/article/768810-nigeria/">https://businessday.ng/news/article/768810-nigeria/</a></li><li><a href="https://businessday.ng/news/article/see-how-high-nigeria-ranks-on-2024-crime-index/">https://businessday.ng/news/article/see-how-high-nigeria-ranks-on-2024-crime-index/</a></li><li><a href="https://www.worldbank.org/en/country/nigeria/overview">https://www.worldbank.org/en/country/nigeria/overview</a></li><li><a href="https://dictionary.cambridge.org/dictionary/english/foresight">https://dictionary.cambridge.org/dictionary/english/foresight</a></li><li><a href="https://www.vanguardngr.com/2021/07/perspectives-on-the-nigeria-police-force/">https://www.vanguardngr.com/2021/07/perspectives-on-the-nigeria-police-force/</a></li><li><a href="https://leadership.ng/nigerian-police-before-you-are-slapped-further/">https://leadership.ng/nigerian-police-before-you-are-slapped-further/</a></li><li><a href="https://www.quora.com/What-is-fundamentally-wrong-with-the-Nigerian-Police-Force">https://www.quora.com/What-is-fundamentally-wrong-with-the-Nigerian-Police-Force</a></li><li><a href="https://businessday.ng/news/article/harnessing-advanced-technology-to-combat-nigerias-security-challenges/">https://businessday.ng/news/article/harnessing-advanced-technology-to-combat-nigerias-security-challenges/</a></li><li><a href="https://nannews.ng/2023/10/19/nse-seeks-adoption-of-emerging-technologies-to-address-security-problems/">https://nannews.ng/2023/10/19/nse-seeks-adoption-of-emerging-technologies-to-address-security-problems/</a></li><li><a href="https://www.linkedin.com/pulse/science-security-technology-its-adoption-nigeria-lanre-adeboye/">https://www.linkedin.com/pulse/science-security-technology-its-adoption-nigeria-lanre-adeboye/</a></li><li><a href="https://punchng.com/using-technology-to-safeguard-against-insecurity/">https://punchng.com/using-technology-to-safeguard-against-insecurity/</a></li><li><a href="https://ualr.edu/socialchange/2017/03/01/blog-riddle-social-media/">https://ualr.edu/socialchange/2017/03/01/blog-riddle-social-media/</a></li><li><a href="https://medium.com/@revofevghost/social-media-and-journalism-how-quickly-information-spreads-c70660af3d0b">https://medium.com/@revofevghost/social-media-and-journalism-how-quickly-information-spreads-c70660af3d0b</a></li><li><a href="https://preparecenter.org/topic/early-warning-systems/">https://preparecenter.org/topic/early-warning-systems/</a></li><li><a href="https://www.ncbi.nlm.nih.gov/pmc/articles/PMC8920081/">https://www.ncbi.nlm.nih.gov/pmc/articles/PMC8920081/</a></li><li><a href="https://datareportal.com/reports/digital-2025-nigeria">https://datareportal.com/reports/digital-2025-nigeria</a></li><li><a href="https://technologytimes.ng/survey-72-of-nigerian-adults-lack-smartphones/">https://technologytimes.ng/survey-72-of-nigerian-adults-lack-smartphones/</a></li><li><a href="https://www.macrotrends.net/global-metrics/countries/nga/nigeria/gdp-gross-domestic-product">https://www.macrotrends.net/global-metrics/countries/nga/nigeria/gdp-gross-domestic-product</a></li><li><a href="https://tradingeconomics.com/nigeria/gdp">https://tradingeconomics.com/nigeria/gdp</a></li><li><a href="https://ycharts.com/indicators/nigeria_consumer_price_index_wdi">https://ycharts.com/indicators/nigeria_consumer_price_index_wdi</a>?</li><li><a href="https://data.worldbank.org/indicator/NY.GDP.PCAP.CD?end=2024&amp;locations=NG&amp;start=2014">https://data.worldbank.org/indicator/NY.GDP.PCAP.CD?end=2024&amp;locations=NG&amp;start=2014</a></li><li><a href="https://data.worldbank.org/indicator/FP.CPI.TOTL?end=2024&amp;locations=NG&amp;start=2014">https://data.worldbank.org/indicator/FP.CPI.TOTL?end=2024&amp;locations=NG&amp;start=2014</a></li><li><a href="https://dictionary.cambridge.org/dictionary/english/informative">https://dictionary.cambridge.org/dictionary/english/informative</a></li><li><a href="https://www.researchgate.net/publication/277780151_What_Can_We_Learn_about_the_Ebola_Outbreak_from_Tweets">https://www.researchgate.net/publication/277780151_What_Can_We_Learn_about_the_Ebola_Outbreak_from_Tweets</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8be90ac5c292" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Model Compression & Optimization Techniques for Edge Devices; A brief overview.]]></title>
            <link>https://kenechiojukwu.medium.com/model-compression-optimization-techniques-for-edge-devices-a-brief-overview-6f27099e431e?source=rss-4d22af97a0f8------2</link>
            <guid isPermaLink="false">https://medium.com/p/6f27099e431e</guid>
            <category><![CDATA[applied-research]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[model-optimization]]></category>
            <category><![CDATA[model-compression]]></category>
            <category><![CDATA[neural-networks]]></category>
            <dc:creator><![CDATA[Kenechi Ojukwu]]></dc:creator>
            <pubDate>Thu, 18 May 2023 23:08:36 GMT</pubDate>
            <atom:updated>2023-05-19T01:01:27.311Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/749/1*VP6dmC_JuKRFKfoBjBQ7HA.jpeg" /></figure><p><strong>Introduction</strong>:</p><p>As I continue to navigate my way through the machine learning ecosystem, I get to understand the complexities involved in first, getting the trained models fit for production and second, making sure the data input and trained models in production are operating correctly, that is, making the right predictions and working inline with the business requirements.</p><blockquote>This article gives an overview on the “<em>getting your models fit for production</em>” phase.</blockquote><p>To make it clear, the term “for production” basically means making a product available to users, and in machine learning, <a href="https://www.redhat.com/en/topics/edge-computing/what-is-edge-machine-learning"><strong>Edge devices</strong></a> are devices with computing services physically closer to the user or source of data.</p><p>The phrase “<strong><em>fit for production</em></strong>” is used because in recent years, a lot of advancements have been made in the field of artificial intelligence especially in the area of deep learning, and sometimes these advancements are shared with the public in the form of “<strong><em>pre-trained models</em></strong>”. A lot, if not all of these pre-trained models are complex and large in size, in some cases the complexity and size increases when these pre-trained models are fine-tuned for specific use cases. Hence, giving rise to a lot of issues pre — production.</p><p>For a lot of use cases, after the first cycle of getting the model to perform accordingly is partially done (I use partially, because the whole workflow in machine learning is cyclic, hence re-iterations never actually stop), you meet a new set of criteria, the technical criteria. To list the major, we have</p><ol><li>Model size.</li><li>Inference speed.</li><li>Model performance (stay with me for now).</li></ol><p>Using a hypothetical example, assuming you are working on a software that alerts adults when certain objects such as blades, pencils, nylons, beads, etc. are around children (ages 1–5). Without going into so much technical detail, we understand that this software will have a machine learning component entailing an object detection model to detect the specified objects from a video feed.</p><p>Now, after identifying all the objects to detect, specifying the metrics for the model, and then engaging in some rigorous training and hyper parameter tuning. You get a good performing model, but the problem with this model is, it takes up to 10 seconds on a single inference and the size of the model is 600 MB.</p><p>From a</p><p><strong>business perspective,</strong> the cost of paying for cloud services will become a problem in the <strong>long run</strong>.</p><p><strong>technical perspective,</strong> the ML component is too slow and too large. Depending on the implementation of the software, no one wants to download an application that is too large, or interact with one that is too slow. Keep in mind we are just considering the ML component and haven’t taken into consideration other components of the software. In most conditions, software applications for user facing systems (edge devices) are optimized to operate under a second.</p><p><strong>practical perspective,</strong> It is dangerous. A lot can happen in 10 seconds, recall that an alert would still have to be sent to the monitoring adult.</p><p>These set of problems brings us to new trade offs: a trade off between model size, inference speed, and <strong>“maintaining”</strong> model performance. A lot more on these would be touched in later parts of this article, but ideally we strive for low inference (low latency), and a relatively small model size while still maintaining good performance.</p><blockquote><strong>This</strong> article will give an introduction to the <strong>major</strong> types of model compression and optimization techniques currently used.</blockquote><p><strong>Compression &amp; Optimization Techniques:</strong></p><p>Before I commence, it would be good to note that these methods can be combined with each other to achieve wonderful results, and of course, like everything to exist, there are pros and cons to each.</p><ol><li><strong>Quantization</strong>:</li></ol><p>To understand the concept of quantization, I would start with what <strong>“<em>numerical representation</em>” </strong>is in computers, and that would mean defining some terms:</p><ol><li><strong>Floating point numbers</strong>:<br> <br>These are positive or negative numbers with a decimal point. In technical terms, this is a significand scaled by an integer exponent of a fixed base.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/326/1*W-Os80TjhSfeTbqa9uRB5g.png" /></figure><p><strong>2. Single — precision floating point format</strong>:</p><p>This is a floating point numerical value, that occupies 32 bit worth of storage in a computer’s memory. The benefit of using this number format is, it gives numerical values more representation or in other words more precision compared to <a href="https://en.m.wikipedia.org/wiki/Fixed-point_arithmetic">fixed-points values</a> of the same 32 bit. This high precision in representation aids in giving overall accurate results.</p><p>To give more context to what this means;</p><blockquote>A positive or negative 32-bit Integer can accommodate a maximum of 2^(31−1) = 2,147,483,647 values (2.147×10^ 9), while a signed 32 bit of base2 floating point can accommodate a maximum of (2 − 2^(−23)) × 2^127 ≈ 3.4028235 × 10^38 values.</blockquote><p>Relating this to machine learning, in the area of deep learning specifically. When we take a detailed look at a neuron, we confirm that it consists of three major values; the weight <strong>W</strong>, bias <strong>b</strong>, and activation value <strong>a,</strong> where each value is represented as a 32 bit floating point.</p><p>In a practical use case, a learned neural network consists of more than just one layer of neurons, filters, convolutional layers etc.</p><p><strong>To</strong> get an <strong>Idea</strong> of the <strong>Math</strong>:</p><p>Using a hypothetical model that consists of 24 layers and 2056 neurons for each layer …</p><p>If a neuron consists of 3 values, 2,056 neurons would consist of 6,168 values, for technicality, these values are referred to as <strong>learned parameters</strong>. Across these 24 layers we would have 148,032 parameters in total. 148,032 parameters would approximately be a size of 592 KB, not large, yes, but using that same procedure for a standard pre-trained model such as the VGG16 model architecture that has about 138 million parameters. The approximate size is 530MB.</p><p>Ideally, it would have been great to use this model as is, but real life has other plans. With the definitions out of the way, we can now address the question of <strong><em>what is quantization</em>?</strong></p><blockquote><strong>Quantization</strong> is the act of mapping or converting a 32 bit floating point to an 8 bit integer in order to reduce the overall memory and computer processing requirements needed.</blockquote><p><strong>Other benefits</strong> to this method are, less power consumption, low storage, and reduced inference latency.</p><p>Remember we stated earlier that the more numerical representation we have, the higher the precision. But with quantization, we tend to truncate the precision, which leads to an overall reduction in accuracy. For a majority of cases, the difference in accuracy is negligible.</p><p>There are two ways quantization can be applied to a trained learning algorithm, these are;</p><ol><li><strong>Post-Training Quantization</strong></li><li><strong>Quantization-Aware Training (QAT)</strong></li></ol><p><strong>Post-Training Quantization</strong>:</p><p>Post-training quantization is the application of the quantization process as explained above, <strong>after</strong> the learning algorithm has been trained.</p><p>The major benefits<strong> </strong>to these are;</p><ol><li>the model size reduction and</li><li>computer processing requirement improvement, but</li></ol><p>The <strong>disadvantage </strong>to this is, a <strong>little drop in accuracy</strong>.</p><p><strong>Quantization-Aware Training(QAT)</strong>:</p><p>Similar to the method explained above, this process of quantization is done <strong>during</strong> the process of training. The logic is, during the models forward propagation, the parameters are represented in lower precision format (e.g. INT 8) but are left as is during backwards propagation.</p><p>The <strong>advantage</strong> to this method, is the model accustoms itself to the representation and henceforth works to reduce the quantization loss generated and added to the overall loss.</p><p><strong>Q.A.T</strong> allows the model to overcome the disadvantage of “Post-Training Quantization”.</p><p>Next on the list is <strong>Pruning</strong>.</p><p><strong>2. Pruning</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/305/1*60c5zANExMWhqmWxzbl0LQ.png" /><figcaption>Pruning</figcaption></figure><p>As mentioned earlier, a neural network consists of layers of neurons crafted to learn or extract valuable information from data points, but this situation is not always the case.</p><p>It has been noted that not all parameters contribute to the learning process of a model, and sometimes when they do contribute, it results to little or nothing in the overall performance. Similar to humans, over the years of growth, the brain undergoes a process called <a href="https://link.springer.com/referenceworkentry/10.1007/978-3-540-29678-2_5811#:~:text=Definition,the%20early%20phase%20of%20development."><strong>synapse elimination</strong></a>, whereby the <a href="https://pubmed.ncbi.nlm.nih.gov/15817378/#:~:text=Abstract,dendrite%2C%20called%20a%20dendritic%20spine.">synaptic contacts</a> (axons and dendrites), die due to not being useful.</p><p>It is from this process, the concept of pruning is birthed.</p><blockquote>In machine learning,<strong> pruning</strong> is the act of removing parameters or structures that contribute little to nothing in the performance of a learning algorithm. The process of pruning makes the <strong>model smaller, computationally cost efficient, and some times improves inference (low latency)</strong>.</blockquote><p>There are different ways pruning can be applied to a learning algorithm, these are:</p><ol><li>Structured and Unstructured Pruning</li><li>Iterative Pruning and fine-tuning</li></ol><p><strong>Structured and Unstructured Pruning</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/175/1*_2Wyxa2pgO2JW-KcU9iM9w.jpeg" /></figure><p><strong>Structured pruning</strong> entails removing neurons, layers or blocks of filters that do not contribute to the overall performance of the learning algorithm.</p><p>An example of one the types of structured pruning is called <strong>Neuron Pruning</strong>. Theoretically, the parameters of learning algorithms are represented as matrices and calculated using matrix multiplication, addition, etc. Here, the row of the weight matrix represents the connection between one layer to a single neuron in the next layer, while the column represents the weights of a neuron(if you need a refresher, you can watch this <a href="https://www.youtube.com/watch?v=aircAruvnKk&amp;list=PLZHQObOWTQDNU6R1_67000Dx_ZCJB-3pi">video</a>). Neuron Pruning involves setting all the values of the column in the weight matrix to zero, which in turn zeros out the overall output of the neuron.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/170/1*azhDF5O2dhVvPR2N-xokDQ.jpeg" /></figure><p><strong>Unstructured pruning</strong> is the process of removing the least performing connections in a learning algorithm. An example of this type of pruning method is <strong>Weight Pruning. </strong>In weight pruning, the least weight value parameters in the weight matrix are set to zero.</p><p><strong>Iterative pruning and fine-tuning</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/208/1*qZtGYPEmSohJNWpP1XMWeA.png" /><figcaption>Iterative Pruning</figcaption></figure><p>As the name suggests this method performs the process of pruning the learning algorithm, re-training it, then pruning it again. This process is repeated till the desired pruning level is achieved. This process exists as an alternative to the pruning process called <strong>one-shot pruning, </strong>to<strong> </strong>which the learning algorithm is pruned to the desired level in one go.</p><p><strong>3. Knowledge Distillation</strong>:</p><p>This compression technique consists of having two learning algorithms; the student learning algorithm (a small size model) and the teacher learning algorithm (the large size model). Here, the student model is trained using outputs from various intermediate layers of the teacher model as targets.</p><p>There are three categories of knowledge distillation techniques, namely;</p><ol><li>Response-based distillation (aka. Logits distillation).</li><li>Feature-based distillation.</li><li>Relation-based distillation.</li></ol><p><strong>Response-based distillation</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/285/1*pXRgrMjhqqfMJGZsLc8hIA.png" /><figcaption>Response Distillation</figcaption></figure><p>In this distillation technique, the student model is trained on the dataset with the teacher model’s <a href="https://datascience.stackexchange.com/questions/31041/what-does-logits-in-machine-learning-mean#:~:text=The%20term%20%22logit%22%20is%20used,numbers%20between%200%20and%201.">logits</a> as the target. Here, a distillation loss function is used, as it is designed to obtain the difference between the output logits of the teacher model and student model.</p><p><strong>Feature-based distillation</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/318/1*u-lqK6I1qfuVq-BVI28p0Q.png" /><figcaption>Feature Distillation</figcaption></figure><p>Neural network based architectures are known for creating <a href="https://www.baeldung.com/cs/dl-latent-space">latent feature spaces</a> across the network, in order to create a proper representation of the data.</p><blockquote>The goal in feature-base distillation is to make the student learn this feature representations from the teacher model. For example, if the <strong>layers</strong> with<strong> feature representations</strong> in both the student model and teacher model are represented as (<strong>L</strong>1s, <strong>L</strong>1t),(<strong>L</strong>2s, <strong>L</strong>2t), <strong>…</strong> ,(<strong>L</strong>ns, <strong>L</strong>nt) (Where <strong>n</strong> is the nth layer, and <strong>s </strong>and <strong>t</strong> signify <strong><em>student</em></strong> and <strong>teacher</strong> respectively), the feature based loss is calculated by finding the <a href="https://medium.com/mlearning-ai/is-l2-norm-euclidean-distance-a9c04be0b3ca#:~:text=For%20Vector%20Norms%2C%20when%20the%20distance%20calculating%20technique%20is%20Euclidean%20then%20it%20is%20called%20L2%2DNorm%20and%20when%20the%20technique%20is%20Manhattan%20then%20it%20is%20called%20L1%2DNorm.">distance</a> between the corresponding layers of the student model and teacher model.</blockquote><p><strong>Relation-based distillation:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/397/1*sP5VhOkG02I8WgADmXgNyg.png" /><figcaption>Relative Distillation</figcaption></figure><p>After going through this <a href="https://openaccess.thecvf.com/content_CVPR_2019/papers/Park_Relational_Knowledge_Distillation_CVPR_2019_paper.pdf">research paper</a>, unlike the feature based distillation technique that finds the distance between the corresponding layers of the teacher and student, the paper introduces a concept called “structural knowledge”, technically speaking, “relational potential Ψ” . This knowledge or potential is calculated by taking in all the representations from the individual layers of a model, and then producing an output, the <em>relation potential.</em> The designated loss function comes in by calculating the difference between the relational potential output of the teacher and the student model. In some sense, the relation potential output is like a generalization of what the layers learnt.</p><p>“Relational” is used because the relation potential is calculated in relation to the distinct batch of data samples. More information including the mathematical technicalities can be found in the <a href="https://openaccess.thecvf.com/content_CVPR_2019/papers/Park_Relational_Knowledge_Distillation_CVPR_2019_paper.pdf">research paper</a>.</p><blockquote>Note: It is also good to state that, it is not in all cases that the student model and the teacher model must be of the same architecture. Sometimes, depending on the use case, switching to a different architecture could improve the models latency as well as the size incredibly well.</blockquote><p>A popular model obtained from knowledge distillation is<a href="https://huggingface.co/docs/transformers/model_doc/distilbert"> DistillBert</a>. You can refer to this <a href="https://analyticsindiamag.com/a-beginners-guide-to-knowledge-distillation-in-deep-learning/">article</a> as it goes into the <strong>different modes</strong> of applying knowledge distillation.</p><p><strong>4. Matrix Decomposition</strong>:</p><p>As stated earlier, parameters in neural networks are represented as matrices, hence most calculations are done with matrices.</p><blockquote>Matrix decomposition in simple terms, is the method of using smaller matrices or vectors in place of large matrices, while still retaining as much information from the large matrix.</blockquote><p>An example of matrix decomposition is the <strong>weight matrix decomposition</strong>, this method replaces the original weight matrix of dimension (n X m) with the dot product of two smaller ones (n X c and c X m). The reduction in model size and runtime memory use is only valid when c &lt;&lt; n, m.</p><p>Although this technique <strong>reduces</strong> the <strong>overall size</strong>, <strong>computational requirements</strong>, and <strong>latency</strong>, it comes with a <strong>bit</strong> of <strong>reduction</strong> in <strong>accuracy</strong>. While implementing this <a href="https://aclanthology.org/2020.aacl-main.88/">paper</a>, I found using matrix decomposition on specific layers of a model and then using feature knowledge distillation technique to smoothen the effect of the decomposition (as stated in the paper) to be a very resourceful compression combination.</p><p><strong>Conclusion:</strong></p><p><strong>A</strong>fter reading this article, hopefully, you should have a good idea on the benefits of the techniques explained. I would still like to point out that there are other techniques, some of which are specific to transformer based architectures. Some of these techniques are:</p><ol><li>Dynamic Inference Acceleration.</li><li>Early exit ramps.</li><li>Parameter Sharing.</li></ol><p>etc.</p><p>For more information, refer to the third link in <strong>general section</strong> of the references.</p><p><strong>References</strong>:</p><p><strong>Quantization</strong>:</p><ol><li><a href="https://medium.com/@joel_34050/quantization-in-deep-learning-478417eab72b">https://medium.com/@joel_34050/quantization-in-deep-learning-478417eab72b</a></li><li><a href="https://www.allaboutcircuits.com/technical-articles/neural-network-quantization-what-is-it-and-how-does-it-relate-to-tiny-machine-learning/">https://www.allaboutcircuits.com/technical-articles/neural-network-quantization-what-is-it-and-how-does-it-relate-to-tiny-machine-learning/</a></li><li><a href="https://iq.opengenus.org/basics-of-quantization-in-ml/#:~:text=Quantization%20in%20Machine%20Learning%20(ML)%20is%20the%20process%20of%20converting,to%20higher%20precision%20in%20FP32.">https://iq.opengenus.org/basics-of-quantization-in-ml/</a></li><li><a href="https://pytorch.org/blog/introduction-to-quantization-on-pytorch/">https://pytorch.org/blog/introduction-to-quantization-on-pytorch/</a></li></ol><p><strong>Pruning</strong>:</p><ol><li><a href="https://analyticsindiamag.com/a-beginners-guide-to-neural-network-pruning/">https://analyticsindiamag.com/a-beginners-guide-to-neural-network-pruning/</a></li><li><a href="https://medium.com/@souvik.paul01/pruning-in-deep-learning-models-1067a19acd89#:~:text=Pruning%20in%20deep%20learning%20basically%20used%20so%20that%20we%20can,values%20of%20the%20weight%20tensors">https://medium.com/@souvik.paul01/pruning-in-deep-learning-models-1067a19acd89</a></li><li><a href="https://towardsdatascience.com/pruning-deep-neural-network-56cae1ec5505">https://towardsdatascience.com/pruning-deep-neural-network-56cae1ec5505</a></li><li><a href="https://pytorch.org/tutorials/intermediate/pruning_tutorial.html">https://pytorch.org/tutorials/intermediate/pruning_tutorial.html</a></li></ol><p><strong>Knowledge Distillation</strong>:</p><ol><li><a href="https://neptune.ai/blog/knowledge-distillation">https://neptune.ai/blog/knowledge-distillation</a></li><li><a href="https://analyticsindiamag.com/a-beginners-guide-to-knowledge-distillation-in-deep-learning/">https://analyticsindiamag.com/a-beginners-guide-to-knowledge-distillation-in-deep-learning/</a></li><li><a href="https://openaccess.thecvf.com/content_CVPR_2019/papers/Park_Relational_Knowledge_Distillation_CVPR_2019_paper.pdf">https://openaccess.thecvf.com/content_CVPR_2019/papers/Park_Relational_Knowledge_Distillation_CVPR_2019_paper.pdf</a></li><li><a href="https://github.com/haitongli/knowledge-distillation-pytorch/tree/9937528f0be0efa979c745174fbcbe9621cea8b7">https://github.com/haitongli/knowledge-distillation-pytorch/tree/9937528f0be0efa979c745174fbcbe9621cea8b7</a></li></ol><p><strong>Matrix Decomposition</strong>:</p><ol><li><a href="https://aclanthology.org/2020.aacl-main.88/">https://aclanthology.org/2020.aacl-main.88/</a></li><li><a href="https://medium.com/mlearning-ai/matrix-decomposition-and-algorithms-675339d8f48a">https://medium.com/mlearning-ai/matrix-decomposition-and-algorithms-675339d8f48a</a></li><li><a href="https://github.com/kene111/matrix-decomposition/blob/main/matrix_decomposition.py">https://github.com/kene111/matrix-decomposition/blob/main/matrix_decomposition.py</a></li></ol><p><strong>General</strong>:</p><ol><li><a href="https://en.m.wikipedia.org/wiki/Single-precision_floating-point_format#:~:text=Single%2Dprecision%20floating%2Dpoint%20format%20">https://en.m.wikipedia.org/wiki/Single-precision_floating-point_format</a></li><li><a href="https://math.stackexchange.com/questions/3228877/what-exactly-is-significand">https://math.stackexchange.com/questions/3228877/what-exactly-is-significand</a></li><li><a href="https://aclanthology.org/2021.tacl-1.63/">https://aclanthology.org/2021.tacl-1.63/</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6f27099e431e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[L1, L2, and L0.5 Regularization Techniques.]]></title>
            <link>https://medium.com/analytics-vidhya/l1-l2-and-l0-5-regularization-techniques-a2e55dceb503?source=rss-4d22af97a0f8------2</link>
            <guid isPermaLink="false">https://medium.com/p/a2e55dceb503</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[regularization]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Kenechi Ojukwu]]></dc:creator>
            <pubDate>Mon, 10 May 2021 18:00:21 GMT</pubDate>
            <atom:updated>2024-02-02T11:20:26.224Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*fXukzfZ5XLX1bEJsDYZj8g.jpeg" /></figure><p>In this article, I aim to give a little introduction to L1, L2, and L0.5 <a href="https://www.analyticsvidhya.com/blog/2021/05/complete-guide-to-regularization-techniques-in-machine-learning/?utm_source=medium&amp;utm_medium=medium&amp;utm_campaign=backlinking">regularization</a> techniques, these techniques are also known as the Lasso, Ridge, and Elastic Net regression techniques respectively. Links referenced are provided at the end of this article. Before we start, we would need to answer two questions.</p><ol><li>What is Regularization ?</li><li>Why is it needed ?</li></ol><p>Starting with the first question and describing it plainly, regularization is the act of shrinking coefficients to zero and in this case coefficients are the weights that are learned during model training. With this definition it can be said that the higher the weights or coefficient values obtained during training, the complex our machine learning model becomes, and this complexity introduces a problem. What this problem is, is answered by the second question.</p><p>Why is it needed? Simply put, regularization is used in solving the over-fitting problem that occurs when training a machine learning model. An example of such is, getting high training accuracy but when used on a “similar” but different dataset, you observe an incredibly low accuracy. By “similar” I mean a dataset that provides information closely related to the previous dataset used for training. Now, to define over-fitting, this is a situation that occurs when a machine learning model tries to capture all the information in a dataset but in turn also captures the noise in the dataset. Noise in this sense are data points that do not provide any form of information but are found in the dataset due to random “occurrences”.</p><p>Now that we understand that regularization is used to prevent over-fitting of models on a particular dataset in order for them to perform well across other <a href="https://www.analyticsvidhya.com/blog/2021/05/complete-guide-to-regularization-techniques-in-machine-learning/?utm_source=medium&amp;utm_medium=medium&amp;utm_campaign=backlinking">datasets</a>, we can take off.</p><p><strong>L1 Regularization ( Lasso Regression)</strong>:</p><p>The L1 regularization technique is a technique that reduces over-fitting by shrinking coefficients (weights) to zero, indirectly this act performs feature selection for the model. Feature selection on the other hand is the act of selecting specific features in a dataset one feels will give a machine learning model valuable information in order to perform well.</p><p>Although the idea of feature selection is a great one because in large datasets, some features do not contribute to the learning of the model and hence they should be removed, but L1 regularization does this feature selection in order to leave only variables that will minimize the prediction error. The minor disadvantage to this, is, this mode of feature selection I believe introduces bias because not many factors are considered before eliminating a variable and from a human perspective that might not be valid act.</p><p>The equation that governs the L1 regularization technique is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/314/1*nuNRx1Wo7bpXA_5BLBjE9w.gif" /></figure><p>Now, when you bring in the L1 regularization equation together with the error function of the residual sum of squares, we have:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/401/1*-qWDHyGbXNnYaN_DIdDoIQ.gif" /></figure><p>In the first equation stated above, <strong>omega(</strong> <strong>ω) can be noted as the regularization term</strong>, <strong>Wi are the weights</strong>, and<strong> lambda (λ) the regularization parameter</strong>, in simple terms the regularization parameter controls how much we perform regularization on our model. The higher the value of the regularization term, the more coefficients are shrunk to zero and the more feature selection occurs.</p><p><strong>L2 Regularization (Ridge Regression)</strong>:</p><p>In L2 regularization, we shrink the coefficients (weights) towards zero without eliminating them. This type of regularization forces the model to rely on all the features made available to it while still preventing over-fitting.</p><p>The equation that governs the L2 regularization technique is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/289/1*CpXfpjWTA-FsSVOt9YKa7Q.gif" /></figure><p>When we include the error function of the residual sum of squares we have:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/376/1*JA2Htdlpqj8Qm85YILAzog.gif" /></figure><p>Unlike Lasso regression (L1), in ridge regression (L2) the higher the value of the regularization parameter the more the coefficients are shrunk towards zero but not to zero, hence no feature selection.</p><p><strong>L0.5 Regularization (Elastic Net Regression)</strong>:</p><p>L0.5 regularization technique is the combination of both the L1 and the L2 regularization techniques. This technique was created to over come the minor disadvantage of the lasso regression technique (L1) to a degree. Here, Elastic Net still performs feature selection but simultaneously it finds the optimal values of coefficients (weights) using the Ridge regression technique (L2).</p><p>The L0.5 Regularization technique is governed by the equation below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/593/1*R7vNQgDRKaiGRVObxXIggg.gif" /></figure><p>and when we add error function of the residual sum of squares, we have:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/662/1*8TmJ1634Sbx1860ncJTVaQ.gif" /></figure><p><strong>r as shown above is defined as the mix ratio</strong>, i.e. when we r=0 elastic net regression becomes equivalent to ridge regression, and when r = 1, elastic net regression is equivalent to lasso regression.</p><p>Now that we have gotten to the end of this brief introduction , It is also good to note that there are other forms of regularization techniques especially in deep learning, some of these techniques include dropout, early stopping, and data augmentation.</p><p>References:</p><ul><li><a href="https://becominghuman.ai/machine-learning-bias-vs-variance-641f924e6c57">Machine Learning: Bias VS. Variance</a></li><li><a href="https://towardsdatascience.com/regularization-in-machine-learning-76441ddcf99a">Regularization in Machine Learning</a></li><li><a href="https://towardsdatascience.com/regularization-in-deep-learning-l1-l2-and-dropout-377e75acc036">Regularization in Deep Learning — L1, L2, and Dropout</a></li><li><a href="https://medium.com/@ODSC/classic-regularization-techniques-in-neural-networks-68bccee03764">Classic Regularization Techniques in Neural Networks</a></li><li><a href="https://analyticsindiamag.com/types-of-regularization-techniques-to-avoid-overfitting-in-learning-models/">Types of Regularization Techniques To Avoid Overfitting</a></li></ul><p>In case you want to learn how to write out your own equations, this articles helps with that:</p><p><a href="https://satyaganesh987.medium.com/how-to-write-mathematics-on-medium-4a46226c7b1e">How To Write Mathematics on Medium?</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a2e55dceb503" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/l1-l2-and-l0-5-regularization-techniques-a2e55dceb503">L1, L2, and L0.5 Regularization Techniques.</a> was originally published in <a href="https://medium.com/analytics-vidhya">Analytics Vidhya</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Machine Learning Operations with Kubeflow]]></title>
            <link>https://medium.datadriveninvestor.com/machine-learning-operations-with-kubeflow-befcd0e903e8?source=rss-4d22af97a0f8------2</link>
            <guid isPermaLink="false">https://medium.com/p/befcd0e903e8</guid>
            <category><![CDATA[kubeflow]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[kubeflow-pipelines]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Kenechi Ojukwu]]></dc:creator>
            <pubDate>Sun, 10 Jan 2021 23:56:59 GMT</pubDate>
            <atom:updated>2021-01-16T16:17:51.689Z</atom:updated>
            <content:encoded><![CDATA[<h3>Building Machine Learning pipelines with Kubeflow</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*dM3U1aD61K_cF5YV4RmxBQ.jpeg" /></figure><p><strong>Brief introduction:</strong></p><p>Machine Learning operations(MLOps) is a field created from applying DevOps principles to machine learning. A question that might arise is, why do we need to apply DevOps principles to machine learning? Well, to answer that, we need to understand the workflow involved in machine learning. To build a machine learning model to solve a real world problem, we need to extract data, preprocess the data, transform the data, perform data analysis, model selection, metric selection, model training, model testing, hyper parameter tuning, model validation, and then model deployment. Handling these task manually can prove to be daunting and could create issues if changes are to be made frequently. Implementing MLOps means that you apply automation and monitoring of all steps in the construction of a machine learning model/system, including integration, testing, releasing, deployment and infrastructure management. More information can found <a href="https://cloud.google.com/solutions/machine-learning/mlops-continuous-delivery-and-automation-pipelines-in-machine-learning">here</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*gawVWJKspgorhaPw.jpeg" /><figcaption>Kubeflow Homepage</figcaption></figure><p><strong>Kubeflow:</strong></p><p><a href="https://www.kubeflow.org/">“Kubeflow</a> is an open-source platform, built on Kubernetes, that aims to simplify the development and deployment of machine learning systems. Described in the official documentation as <em>the ML toolkit for Kubernetes</em>, Kubeflow consists of several components that span the various steps of the machine learning development lifecycle. These components include notebook development environments, hyper parameter tuning, feature management, model serving, and, of course, machine learning pipelines.”</p><p><strong>Kubeflow Pipelines:</strong></p><p>Pipelines are used to automate and orchestrate the various steps in the workflow used in creating a machine learning model. Older approaches involve having the entire workflow for a model as a single script. Hence, each model to be tested will have its own script. Pipelines are made up of components, components are containers that houses each step in the workflow making it possible to use it in other pipelines if need be. It should be noted that these components act independently from other components, for example, everything needed for data preprocessing i.e. libraries and the code script can only be used in the preprocessing component, trying to access the libraries and script in the preprocessing component from another component is not possible. With this procedure, it is a lot easier to make use of a component from a pipeline in another pipeline if the methods are the same, making the component <strong>reusable. </strong>Hence, no need for multiple similar scripts for different models.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W-W5iQWwsb8E7xqmkjRSkQ.png" /><figcaption>Pipeline Graph on Kubeflow.</figcaption></figure><h4><em>There are two ways to creating a pipeline:</em></h4><p>Using light weight components.</p><p>Using reusable components.</p><p>For this article, I would focus on reusable components but speaking briefly, light weight components are used for fast and easy deployment, one of the set backs with light weight component is they aren’t reusable.</p><p><strong>Building a reusable pipeline with kubeflow:</strong></p><p>To access kubeflow, you need to deploy it to a cluster, I use the google cloud platform for deployment, other cloud services can be used such AWS, IBM, and even locally, your personal computer. I won’t be covering how to deploy kubeflow on clusters, but will provide a link at the end of this article.</p><p>Before deploying kubeflow, you need to make sure all your components are ready. Let’s go through the process.</p><p><a href="https://www.datadriveninvestor.com/2020/11/19/how-machine-learning-and-artificial-intelligence-changing-the-face-of-ecommerce/">How Machine Learning and Artificial Intelligence Changing the Face of eCommerce? | DataDrivenInvestor</a></p><p><strong>Data Preprocessing Component:</strong></p><p>For this example I will create a three component pipeline which includes a preprocess component, model training component, and model testing component. I will use a project I participated in on the subject of road safety, details, and code can be found on my git repo. Link to the repo is found at the end of this article.</p><p><em>The preprocessing script</em></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/912ffaa4b0068812db34e3110beecf33/href">https://medium.com/media/912ffaa4b0068812db34e3110beecf33/href</a></iframe><p>The task it create a model that can predict the accident severity based on certain features. In this script we are basically just cleaning up the data for model training. We would also create a Dockerfile, so we can build and push an image to Dockerhub.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8dcbcfe8c4db4f4cb97ef62e943012fa/href">https://medium.com/media/8dcbcfe8c4db4f4cb97ef62e943012fa/href</a></iframe><p>Don’t worry, if you do not understand what is going on, a link on how to build and push to dockerhub is provided at the end of this article. The article provided goes into great detail on what is happening above.</p><p>Your local directory should look like this:</p><pre>data_preprocess<br>   -preprocess.py<br>   -Dockerfile</pre><p>Now, all you have to do is change directory to the data_preprocess directory using your command prompt, build a docker image and deploy to dockerhub ( there are various ways to deploy to dockerhub, I do mine locally). A link on how to build and push to dockerhub is provided at the end of this article.</p><p>The same process would be done for the model training and testing. The only difference is that unlike the data preprocessing component, the model training and testing all receive inputs, to receive these inputs in the script we do this.</p><p>Model Training Component:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/42feadb31175a9ff862c92025b09cd1a/href">https://medium.com/media/42feadb31175a9ff862c92025b09cd1a/href</a></iframe><p>Here, we use argparse to handle the inputs. The same procedure would be used to build and push to Dockerhub using its own Dockerfile.</p><p>It should be noted that the outputs from the functions are serialized objects.</p><p>To know your build and push were successful, your dockerhub should have these:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2en4Do2f4WeDw6tkluEiEw.png" /></figure><p><strong>Creating The Pipeline:</strong></p><p>Once deployed to kubeflow, click on notebook servers, create a notebook and connect to the notebook. When connected to the notebook, the interface is the same with the jupyter notebook interface. You create a new .ipynb file and run the following:</p><pre>!python -m pip install --user --upgrade pip<br><em>!pip install kfp</em></pre><p>When the installations are complete, you comment out the lines of code above and you restart and clear the notebook.</p><p>Note: kfp is an sdk used in creating the components and the pipeline.</p><p>After all that has been done, the next thing is to import the necessary libraries and create the components.</p><pre><strong>import</strong> <strong>kfp</strong><br><strong>from</strong> <strong>kfp</strong> <strong>import</strong> dsl</pre><p>To create the components that access the docker images from dockerhub, we do this.</p><p>preprocess container</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/00498205f1fb683937238ba12c5456d4/href">https://medium.com/media/00498205f1fb683937238ba12c5456d4/href</a></iframe><p>training container</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f64fc59352fd6593d1ec8ce8b6b553d4/href">https://medium.com/media/f64fc59352fd6593d1ec8ce8b6b553d4/href</a></iframe><p>testing container</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c6d2ef60978ddbfb994fdc175fbbbc56/href">https://medium.com/media/c6d2ef60978ddbfb994fdc175fbbbc56/href</a></iframe><p>The image variable is the name of your docker image on dockerhub, that is how the dsl.ContainerOp function accesses your code. The arguments list are your input variables to your code script, and the file_outputs dictionary are the serialized objects or .txt files.</p><p>Now that all the containers have been created, we connect them to form a pipeline using the following:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dfe82e3a0ce186603f2e22ef0276cdd9/href">https://medium.com/media/dfe82e3a0ce186603f2e22ef0276cdd9/href</a></iframe><p>All is set, now we run the experiment using the following code.</p><pre>client = kfp.Client()<br>client.create_run_from_pipeline_func(road_safety_useable_pipeline, arguments={})</pre><p>Once done correctly, it displays two links, click the run details to show the run process of the pipeline, if successful(assuming there are no bugs or libraries you forgot to import) the finished work would look like the pipeline graph displayed at the beginning of this article.</p><p>With this, you should be able to create your own reusable pipeline.</p><p>Links:</p><ul><li><a href="https://github.com/kene111/Reusable_pipeline">kene111/Reusable_pipeline</a></li><li><a href="https://towardsdatascience.com/machine-learning-pipelines-with-kubeflow-4c59ad05522">Machine Learning Pipelines with Kubeflow</a></li><li><a href="https://medium.com/swlh/python-how-starting-with-docker-d2be73d9ae92">Python HOW: Starting with Docker</a></li><li><a href="https://cloud.google.com/solutions/machine-learning/mlops-continuous-delivery-and-automation-pipelines-in-machine-learning">MLOps: Continuous delivery and automation pipelines in machine learning</a></li></ul><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FXExIckMpTX8&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DXExIckMpTX8&amp;image=http%3A%2F%2Fi.ytimg.com%2Fvi%2FXExIckMpTX8%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/c4ad9b9346e502841c3c02d47f4a790c/href">https://medium.com/media/c4ad9b9346e502841c3c02d47f4a790c/href</a></iframe><p>Although the pipeline created in this video was done with light weight components, this tutorial shows how to deploy kubeflow on google clusters using the google cloud platform.</p><p><strong>Gain Access to Expert View — </strong><a href="https://datadriveninvestor.com/ddi-intel"><strong>Subscribe to DDI Intel</strong></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=befcd0e903e8" width="1" height="1" alt=""><hr><p><a href="https://medium.datadriveninvestor.com/machine-learning-operations-with-kubeflow-befcd0e903e8">Machine Learning Operations with Kubeflow</a> was originally published in <a href="https://medium.datadriveninvestor.com/">DataDrivenInvestor</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[In and Out of FaceNet]]></title>
            <link>https://medium.com/analytics-vidhya/in-and-out-of-facenet-41822ff6a87?source=rss-4d22af97a0f8------2</link>
            <guid isPermaLink="false">https://medium.com/p/41822ff6a87</guid>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[triplet-loss]]></category>
            <category><![CDATA[face-recognition]]></category>
            <category><![CDATA[face-net]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Kenechi Ojukwu]]></dc:creator>
            <pubDate>Sun, 10 Jan 2021 23:33:51 GMT</pubDate>
            <atom:updated>2021-01-13T16:41:55.689Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/474/1*3woF3lE0JpwCfn0Zt_uwsQ.png" /><figcaption>FaceNet Model</figcaption></figure><p>This article aims to give a brief introduction into the FaceNet face recognition model. Most of the terminologies and workings of the model will be explained in this article. If interested in more in-depth analysis, links to the materials referenced are provided in the link section.</p><p><strong>Aim:</strong></p><p>Well, the aim of facenet is quite easy to grasp, a model that can recognize and verify an individual using the face of that individual or even perform clustering i.e. finding common people based on their face.</p><p><strong>Method:</strong></p><p>Using deep convolutional neural networks to create Euclidean embeddings of face images in which the learned <a href="https://www.google.com/search?q=squared+l2+distance&amp;oq=squared+L2+distance&amp;aqs=chrome.0.35i39i457.980j0j7&amp;sourceid=chrome&amp;ie=UTF-8">squared L2 distance</a> in the embedding space tells how similar a face is from another. In simple terms, we wish to convert face images to n-dimensional vectors(embeddings) using a deep convolutional neural network, and when plotting these embeddings on an n-dimension space, we should be able to tell that because two n-dimensional vectors are very close, the face images of those embeddings with high probability belongs to the same person, and if further apart, the face images are of different people. With this achieved, face recognition becomes a classification problem and/or a clustering problem. It all depends on the task at hand.</p><p><strong>Deep convolutional neural network architecture:</strong></p><p>The deep convolutional network used in facenet is a combination of two architectures. The first architecture consist of a mixture of multiple “interleaved” layers of convolutions, non-linear activations, local response normalizations layers and max pooling layers. Several 1x1xd convolutions were added to tackle the problem of increasing feature maps as the image passes through the network, the 1x1xd solves this problem by decreasing the feature map (this is somewhat similar dimension reduction). “d” is the number filters used on the image. The second architecture is based on the inception model which is a network with a mixture of several convolutional and pooling layers all in parallel, and an output which is a concatenation of the response from all the parallel layers. The good thing about this as noted from the <a href="https://arxiv.org/abs/1503.03832">research paper</a> is that it reduces the parameters up to 20 times and also has the potential to reduce the FLOPS required for comparable performance.</p><p>FLOPS- FLOating Point operations per Second.</p><p>flops measure the computer performance, useful in the fields of scientific computations that require floating-point calculations.</p><p>The CNN model was trained using the stochastic gradient descent with standard backprop and Adagrad.</p><p>Adagrad is a stochastic gradient descent optimization method for adaptive learning rates. More info on Adagrad can be found in the link section.</p><p><strong>Triplet Loss:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Pvs_KsrdYA01mflqCRSexQ.png" /></figure><p>With triplet loss you need to understand the concept of an anchor, a positive, and a negative. So the question goes like this … what is an anchor, a positive, and a negative? Well, the triplet function consist of three thumbnails, two identical thumbnails and a non-identical thumbnail. One of the two identical thumbnail is the anchor, while the other is the positive, the non-identical is the negative. While training the CNN network, the loss function tries to minimize the distance between the identical thumbnails( the anchor and the positive) and at the same time try to increase the distance between the anchor and the negative( the two different thumbnails).</p><p>It is good to note that loss function( triplet loss ) uses the outputs of the convolutional neural network which are 128-D embeddings, hence two identical embeddings are represented as identical thumbnails and the non-identical embedding is represented as a non-identical thumbnail.</p><p>The thumbnails are tightly fit face images.</p><p>Now, how are the triplets(embeddings) chosen? This is all thanks to spherical clustering. Simply put, with spherical clustering all the vectors are normalized, and then cosine similarity is used to measure the distance between these normalized vectors.</p><p>In more sophisticated words triplet loss embeds an image <em>x</em> into a d-dimensional Euclidean space, in the context of nearest-neighborhood classification we try to make an image of a person “A” closer to all other images of person “A” while increasing the distance of person “A” images to all other non-images of person “A” . As indicated in the<a href="https://arxiv.org/abs/1503.03832"> paper</a> extra constraint were made to keep the embedding on a d-dimensional hypersphere. A n-hypersphere (or n-sphere) is the generalization of the circle called 2-sphere. The regular sphere is called a 3-sphere(these terms are used by geometers).</p><p><strong>Embedding Dimensionality:</strong></p><p>Various embeddings were used when creating the facenet model but the embedding that produced the best results was the 128-D, here are the results of the embeddings used and their results: 64, 128, 256, 512 with accuracies of 86.8% , 87.9%, 87.7%, 85.6% plus or minus 1.7, 1.9, 1.9, 2.0 respectively.</p><p>With this I hope you have gained some insights on the FaceNet face recognition model.</p><p>Links:</p><ul><li><a href="https://arxiv.org/abs/1503.03832">FaceNet: A Unified Embedding for Face Recognition and Clustering</a></li><li><a href="https://medium.com/analytics-vidhya/triplet-loss-b9da35be21b8">The intuition of Triplet Loss</a></li><li><a href="https://mathworld.wolfram.com/Hypersphere.html">Hypersphere</a></li><li><a href="https://towardsdatascience.com/a-simple-guide-to-the-versions-of-the-inception-network-7fc52b863202">A Simple Guide to the Versions of the Inception Network</a></li><li><a href="https://towardsdatascience.com/visualising-filters-and-feature-maps-for-deep-learning-d814e13bd671">Visualising Filters and Feature Maps for Deep Learning</a></li><li><a href="https://towardsdatascience.com/difference-between-local-response-normalization-and-batch-normalization-272308c034ac">Difference between Local Response Normalization and Batch Normalization</a></li><li><a href="https://stackoverflow.com/questions/39366271/for-what-reason-convolution-1x1-is-used-in-deep-neural-networks">For what reason Convolution 1x1 is used in deep neural networks?</a></li><li><a href="https://machinelearningmastery.com/introduction-to-1x1-convolutions-to-reduce-the-complexity-of-convolutional-neural-networks/">A Gentle Introduction to 1×1 Convolutions to Manage Model Complexity - Machine Learning Mastery</a></li><li><a href="https://towardsdatascience.com/stochastic-gradient-descent-clearly-explained-53d239905d31">Stochastic Gradient Descent — Clearly Explained !!</a></li><li><a href="https://medium.com/konvergen/an-introduction-to-adagrad-f130ae871827">An Introduction to AdaGrad</a></li><li><a href="https://paperswithcode.com/method/adagrad">Papers with Code - AdaGrad Explained</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=41822ff6a87" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/in-and-out-of-facenet-41822ff6a87">In and Out of FaceNet</a> was originally published in <a href="https://medium.com/analytics-vidhya">Analytics Vidhya</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Eigenvectors and Eigenvalues + Face Recognition = Eigen Faces]]></title>
            <link>https://medium.com/swlh/eigenvectors-and-eigenvalues-face-recognition-eigen-faces-f82ebb0b1973?source=rss-4d22af97a0f8------2</link>
            <guid isPermaLink="false">https://medium.com/p/f82ebb0b1973</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[facedetection]]></category>
            <category><![CDATA[computer-vision]]></category>
            <category><![CDATA[eigenvalue]]></category>
            <category><![CDATA[eigenvectors]]></category>
            <dc:creator><![CDATA[Kenechi Ojukwu]]></dc:creator>
            <pubDate>Tue, 24 Nov 2020 18:54:53 GMT</pubDate>
            <atom:updated>2020-11-27T15:59:47.358Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*7bJb1nVEyWrNQKIHyPbpGw.jpeg" /></figure><p>In this article, I would try to explain things as easy as possible, easy enough for you to get the intuition of it all. To give a smooth read, I would try to use as less mathematical equations as possible. If interested in the mathematics, links to the articles I referenced are provided at the end.</p><p>So, what are Eigenvectors and Eigenvalues?</p><p>To explain this I would use the eigenvector and eigenvalue equation stated below( I know I said little math but don’t worry, this is all the math needed).</p><p>A * v = v * λ … (1)</p><p>Here, A is a matrix, v is a vector, and λ(lambda) is a scalar quantity. So what does this equation say exactly?</p><p>First, let’s try to understand why they equate to each other. Taking the left-hand side of the equation, which is “A * v”. A * v is simply the multiplication of a matrix A and a vector v, when we multiply this matrix and vector, we get a new vector, let’s name this new vector “b”. So we have,</p><p>A * v = b … (2)</p><p>Now, for the right-hand side of (1), if it is possible to obtain vector b by multiplying the vector v and a scalar quantity λ, we have …</p><p>b = v * λ … (3)</p><p>Substituting (3) in (2) we arrive at back at (1), what this proves is that a matrix multiplied by a vector can be obtained or substituted by the multiplication of the same vector by a scalar quantity. This special vector V (special because not all vectors can do this)is known as the eigenvector and the scalar quantity is known as the eigenvalue. The <strong><em>“eigenvalue tells how much information an</em></strong> <strong><em>eigenvector retains after reducing a matrix to a vector ”— </em></strong>in here lies the definition of eigenvalues and eigenvectors. For example, on a scale of 0 to 1, if we have an eigenvalue of 0.85, this simply means that the eigenvector was able to retain 85 percent worth of information from the matrix.</p><p>This equation basically says that we can replace a large matrix with just a vector and a scalar value, put in other words this means dimensionality reduction. I would like to state that there are other applications of eigenvectors and eigenvalues but for this article, I would focus on dimensionality reduction.</p><p>What is Face Recognition?</p><p>Face recognition in my own words is basically computers answering the question of “who is this person ?” based on their facial features.</p><p>Now, the question is, what does face recognition and eigenvalues and eigenvectors have in common?</p><p>Well, for starters, we all know computers do not see objects the way we do, for a computer to see anything it has to be in numbers. To your computer, a picture is basically a matrix of integers. To let your computer know that a said picture is just the face of a friend or a family member, you have to train it on lots of face images of that friend or family member using various deep learning algorithms. Recall that I said images are just matrices, now training a computer to understand the information(i.e. who is this person) carried in these matrices would be computationally expensive. So in order to make things easier and somewhat faster, we need to reduce the dimension of these images while still retaining as much information as possible.</p><p>This is where eigenvectors and eigenvalues come to the rescue, from this point on, things become easier. When the matrices (face images) dimensions have been reduced, the resulting eigenvector is known as an Eigen face because when displayed it produces a ghostly face (images are provided in the research paper in the link section). Another advantage to this is that this method extracts the import features of the face that may not be directly linked to the facial features we intuitively think of, such as eyes, noses, lips, etc. It is also worthy to note that number of eigenvectors is equivalent to the number of matrices (face images) present, so we pick the vectors whose eigenvalues are high.</p><p>Now, this N’ dimensional vectors(eigenvectors) span an N’ dimensional subspace called a “face space” which represents all the possible Eigen faces. To understand the concept of a face space, let’s imagine we have a smart magical board that groups objects together based on their color or a specified feature. Given the fact that we have 3 sacs of balls, where a sac is filled with balls of the same color, the colors we have are blue, red, and green.</p><p>When we throw these balls on the board, the board clusters all the balls with the same color together, now let’s say some balls irrespective of color represent the letter “A” while some do not. Here, the dynamics of things change, when the board clusters, we would have a region on the board that has a combination of all the colors the represent the letter A together while the others that do not represent anything scattered about the space. Now, let’s say the balls that represent A are the eigenvectors, in other words if A represents faces, we say they are Eigen faces, then the region on the board that has the combination of balls together is called the face space. This is some what expected since faces have a similar structure, they would most likely not appear randomly in a vector space.</p><p>The next thing would be to classify a new face, that is, “is this a face or not?” so what we do is to reduce the dimension of this image, obtain the new vector, and project it onto this face space, i.e. get a new ball, make it smaller and throw it on the board, well since the board is magical it would know where to place the new ball. Mathematically speaking, what happens is, we find the Euclidean distance between the new vector to the face space. If the minimum distance passes a specified threshold to the face space we can say this is a face, the farther it is, the more confidence we have to say it is not a face.</p><p>Assuming we have different faces i.e. the balls represent face images of people. Blue — faces of Dave, red — faces of Kene ; ), green — faces of Sam. On the magical board we are going to have a face space containing three different regions of Eigen faces. When we get a new ball( a new face), make it smaller ( get the eigenvector i.e. Eigen face) and then project it onto the face space. Like the board did earlier it will find the Euclidean distance, if the ball is closest to or in the region of the “green Eigen face” we say, the new image is probably or most likely a face image of Sam.</p><p>That’s it, basically we are just applying eigenvectors and eigenvalues in the field of face recognition.</p><p>Links (References):</p><ul><li><a href="https://lpsa.swarthmore.edu/MtrxVibe/EigMat/MatrixEigen.html">Eigenvalues and Eigenvectors</a></li><li><a href="https://www.mathsisfun.com/algebra/eigenvalue.html">Eigenvector and Eigenvalue</a></li><li><a href="https://medium.com/fintechexplained/what-are-eigenvalues-and-eigenvectors-a-must-know-concept-for-machine-learning-80d0fd330e47">What are Eigenvalues and Eigenvectors?</a></li><li><a href="https://medium.com/fintechexplained/what-is-dimension-reduction-in-data-science-2aa5547f4d29">What Is Dimension Reduction In Data Science?</a></li><li><a href="https://builtin.com/data-science/step-step-explanation-principal-component-analysis">Principal Component Analysis (PCA) Explained | Built In</a></li><li><a href="https://datascienceplus.com/understanding-the-covariance-matrix/">Understanding the Covariance Matrix</a></li><li><a href="https://machinelearningmastery.com/introduction-to-deep-learning-for-face-recognition/">A Gentle Introduction to Deep Learning for Face Recognition - Machine Learning Mastery</a></li></ul><p>Research Paper:</p><p><a href="https://www.computer.org/csdl/proceedings-article/cvpr/1991/00139758/12OmNAHmOrk">CSDL | IEEE Computer Society</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f82ebb0b1973" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/eigenvectors-and-eigenvalues-face-recognition-eigen-faces-f82ebb0b1973">Eigenvectors and Eigenvalues + Face Recognition = Eigen Faces</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Web scraping using Python]]></title>
            <link>https://kenechiojukwu.medium.com/web-scraping-using-python-bf677172d6ba?source=rss-4d22af97a0f8------2</link>
            <guid isPermaLink="false">https://medium.com/p/bf677172d6ba</guid>
            <category><![CDATA[web-scraping]]></category>
            <category><![CDATA[python-programming]]></category>
            <dc:creator><![CDATA[Kenechi Ojukwu]]></dc:creator>
            <pubDate>Sun, 24 Mar 2019 16:03:05 GMT</pubDate>
            <atom:updated>2019-03-24T16:36:33.710Z</atom:updated>
            <content:encoded><![CDATA[<h3>Web scraping with Python(using BeautifulSoup)</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*a4xWpmTJ14YsMVDg0Wwlbw.jpeg" /></figure><p>As usual the first set of questions always go like this, what is web scraping? What is the usefulness? And how do I do it? Now, to answer the first two questions with the simplest of words, web scraping is simply the collection of specific data or information from a web site or a simple web page, to which this information or data could be used for analysis or whatever the web scraper needs such information for. Several programming languages can be used for web scraping, but as stated above we would be using the python programming language to scrape a web site. How do I do it? lets get right to it with a simple example. First, it would be a good thing to note that one of the languages used in building a website is the Hyper Text Mark-up Language(HTML). HTML contains large amount of data in text form. To scrape data from a web site, we would use the beautifulsoup4 from the bs4 python library and the lxml parser( there are other types of parsers but we would be using ‘lxml’ for this example). These tools are way more preferable, very helpful and easy to use when it comes to web scraping.</p><p><strong>Getting Started:</strong></p><p>You would need to create a folder, after which you create a virtual environment in that folder, then install these tools and libraries in the virtual environment. All these steps would be done in the command prompt using pip.</p><pre>#on the command prompt<br>1) mkdir work<br>2) cd work <br>3) virtualenv work_flow_env <br>4) work_flow_env\Scripts\activate<br>5) pip install beautifulsoup4<br>6) pip install lxml<br>7) pip install html5lib #optional<br>8) pip install requests</pre><pre># explanation of code lines:</pre><pre>line 1 creates a folder named work<br>line 2 opens the folder<br>line 3 creates a virtual environment named work_flow_env in that folder<br>line 4 activates the virtual environment(this code is for a windows os)<br>line 5,6,7 and 8 installs the tools and libraries needed for web scraping.</pre><p>I will assume that most of the readers have an idea even if it’s a little knowledge on HTML, but if you have none, you could always skim through a good free source website, in which I will recommend “w3schools.com”.</p><p>Now if you are using sublime text, all you have to do is drag your folder named “work’’ into the sublime text application and you are ready to code. If you have a well downloaded anaconda application, jupyter notebook has all these installed, so you would not have to go through the ‘Getting started’ phase.</p><p>Our task is really simple, we are to get the name of movies from ‘<a href="http://toxicwap.com/New_Movies/">http://toxicwap.com/New_Movies/</a>’ and their links. In your already set compiler, you import the libraries.</p><p><strong>Importing Libraries:</strong></p><pre>from bs4 import BeautifulSoup<br>import requests<br></pre><p><strong>Getting the raw data:</strong></p><p>After importing the libraries, you get the information in text format from the web page using requests.get().text</p><pre>source = requests.get(&#39;<a href="http://toxicwap.com/New_Movies/&#39;).text">http://toxicwap.com/New_Movies/&#39;).text</a> </pre><p><strong>Parsing:</strong></p><p>Now, you have gotten the information needed, so you parse through the text using lxml, you make it clean and readable using prettify().</p><pre>soup = BeautifulSoup(source, &#39;lxml&#39;)<br>print(soup.prettify())</pre><p><strong>Inspecting the web page:</strong></p><p>Go back to the web page and inspect it( you right click and and select inspect), you then navigate the web page from the source code seen, you navigate to the point you are able to highlight the part you want to scrape. When you have gotten all you need, you go back to your code then look through your “prettified” text. When going through your cleaned up data(prettified text) you would see the code you highlighted from the web page, depending on the site you are scraping you may have to dig a lot deeper before getting to what you want.</p><p><strong>Digging(navigating) through the text data:</strong></p><pre>div = soup.find(&#39;div&#39;, attrs={&#39;data-role&#39;:&#39;content&#39;})<br>ul = div.find(&#39;ul&#39;)<br>li = ul.find(&#39;li&#39;)<br>print(li)</pre><p>To explain the code. First, if you are doing exactly what I am doing, when you inspect the web page you would notice the tags are mostly “div”, now line 1 selects the particular div that holds the content you want to scrape. Line 2 digs deeper into the div to the ul(unordered list) and line 3 digs into the ul to the li(list). Well, We all know what line 4 does( it displays the list).</p><p>Note: some sources online use ‘class_=()’ when trying to get to a particular div, but you would notice that in this particular case the prettified text did not display the class of the div, hence resulting to the use of ‘attrs ={}’.</p><pre>title = li.a.text<br>print(title)<br>link = li.a<br>print(link[&#39;href&#39;])</pre><p>Now, the first line says put in the variable named title the text which can be found in the ‘a’ tag(&lt;a&gt;: link tag in HTML), which is also found in the ‘li’ tag. It is literally just digging from ‘li’ into ‘a’ to the ‘text’. From what I have said, you should be able to interpret the third line. Basically, you are already done, but this written code will get you just the first title and the first link, to get all the titles and links you use a for loop.</p><p><strong>Displaying the whole output:</strong></p><pre>for li in ul.find_all(&#39;li&#39;):<br>    title = li.a.text<br>    print(title)<br>    <br>    link =li.a<br>    print(link[&#39;href&#39;])</pre><p>Notice how .find() changed to .find_all()? That’s what you do when you want to get all the data needed. It is good practice to use .find() first when trying to navigate, then when the code format is gotten you use the .find_all() to get the data remaining. So now the whole code should look like this.</p><p><strong>Complete code:</strong></p><pre>from bs4 import BeautifulSoup<br>import requests</pre><pre>source = requests.get(&#39;<a href="http://toxicwap.com/New_Movies/&#39;).text">http://toxicwap.com/New_Movies/&#39;).text</a><br>soup = BeautifulSoup(source, &#39;lxml&#39;)</pre><pre>div = soup.find(&#39;div&#39;, attrs={&#39;data-role&#39;:&#39;content&#39;})<br>ul = div.find(&#39;ul&#39;)<br>li = ul.find(&#39;li&#39;)</pre><pre>for li in ul.find_all(&#39;li&#39;):<br>    title = li.a.text<br>    print(title)<br>    <br>    link = li.a<br>    print(link[&#39;href&#39;])<br>    print()<br>    <br> </pre><p>You are done, but if you want to save the scrapped data into a text file or csv file, you can. I’ll be saving this into a csv file.</p><p><strong>Saving in a format:</strong></p><pre>from bs4 import BeautifulSoup<br>import requests<br>import csv</pre><pre>source = requests.get(&#39;<a href="http://toxicwap.com/New_Movies/&#39;).text">http://toxicwap.com/New_Movies/&#39;).text</a><br>soup = BeautifulSoup(source, &#39;lxml&#39;)</pre><pre>div = soup.find(&#39;div&#39;, attrs={&#39;data-role&#39;:&#39;content&#39;})<br>ul = div.find(&#39;ul&#39;)<br>li = ul.find(&#39;li&#39;)</pre><pre>file = open(&#39;s_data.csv&#39;, &#39;w&#39;)<br>file_writer = csv.writer(file)<br>file_writer.writerow([&#39;Titles&#39;,&#39;Links&#39;])</pre><pre>for li in ul.find_all(&#39;li&#39;):<br>    title = li.a.text<br>    print(title)<br>    <br>    link = li.a<br>    print(link[&#39;href&#39;])<br>    print()<br>    <br>    file_writer.writerow([title, link ])</pre><pre>file.close()</pre><p>I would like to add that some websites make it really hard to scrape their page and for some it is illegal to scrape their page.</p><p>That is it. It is all done. I guess I could say you just learnt how to scrape a website.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bf677172d6ba" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>