<?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 Isheunesu Tembo on Medium]]></title>
        <description><![CDATA[Stories by Isheunesu Tembo on Medium]]></description>
        <link>https://medium.com/@isheunesu48?source=rss-60800ed0a0b5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*4zSmafNRgXrxPk5_2aBZZg.jpeg</url>
            <title>Stories by Isheunesu Tembo on Medium</title>
            <link>https://medium.com/@isheunesu48?source=rss-60800ed0a0b5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 10:00:36 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@isheunesu48/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[Dockerizing an Express Js Backend App and Deploying it on AWS (ECS ,ECR ,Task Definitions…]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://isheunesu48.medium.com/dockerizing-an-express-js-backend-app-and-deploying-it-on-aws-ecs-ecr-task-definitions-c68e792343b0?source=rss-60800ed0a0b5------2"><img src="https://cdn-images-1.medium.com/max/1280/1*t_4_F_j5Hxr7YE4I8P0iaw.png" width="1280"></a></p><p class="medium-feed-snippet">So you have worked on your backend system on localhost but now how do you now expose your API to the world?</p><p class="medium-feed-link"><a href="https://isheunesu48.medium.com/dockerizing-an-express-js-backend-app-and-deploying-it-on-aws-ecs-ecr-task-definitions-c68e792343b0?source=rss-60800ed0a0b5------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://isheunesu48.medium.com/dockerizing-an-express-js-backend-app-and-deploying-it-on-aws-ecs-ecr-task-definitions-c68e792343b0?source=rss-60800ed0a0b5------2</link>
            <guid isPermaLink="false">https://medium.com/p/c68e792343b0</guid>
            <dc:creator><![CDATA[Isheunesu Tembo]]></dc:creator>
            <pubDate>Sun, 20 Jul 2025 00:17:02 GMT</pubDate>
            <atom:updated>2025-07-21T16:35:44.965Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Untitled]]></title>
            <link>https://isheunesu48.medium.com/untitled-4f4d1dd130eb?source=rss-60800ed0a0b5------2</link>
            <guid isPermaLink="false">https://medium.com/p/4f4d1dd130eb</guid>
            <dc:creator><![CDATA[Isheunesu Tembo]]></dc:creator>
            <pubDate>Wed, 14 May 2025 18:22:08 GMT</pubDate>
            <atom:updated>2025-05-14T18:22:08.741Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8-UBTonHial-qk2sxP_Gyg.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4f4d1dd130eb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Flutter BLoC State Management The Ultimate Beginner Guide Part 1]]></title>
            <link>https://isheunesu48.medium.com/flutter-bloc-state-management-the-ultimate-beginner-guide-part-1-342286d311db?source=rss-60800ed0a0b5------2</link>
            <guid isPermaLink="false">https://medium.com/p/342286d311db</guid>
            <category><![CDATA[flutter-web]]></category>
            <category><![CDATA[flutter-bloc-pattern]]></category>
            <category><![CDATA[flutter-clean-code]]></category>
            <category><![CDATA[flutter-state-management]]></category>
            <category><![CDATA[flutter-app-development]]></category>
            <dc:creator><![CDATA[Isheunesu Tembo]]></dc:creator>
            <pubDate>Thu, 04 Jan 2024 20:34:28 GMT</pubDate>
            <atom:updated>2024-01-04T20:34:28.302Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mDxccHpTbxho3pamSCUA3w.jpeg" /></figure><p>If you are coming from Native Android application development with Kotlin or Java like l did , you will find that the issue of state in flutter might be confusing but don’t worry l will break it down in a moment .</p><p>To understand state management we first need to understand how flutter on itself works as a framework.Unlike imperative framework in android native (using xml ) , flutter rebuilds parts of the UI from scratch , because it is fast when doing so that you can barely notice it.Flutter is a declarative framework that means that it changes its UI when its state changes.That means that flutter has functions that take the state as parameter and changes the UI according to the state change this function is usually the build() function</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aBZFHTrqSpvsPm2LxDGuDg.jpeg" /></figure><p>Since you now have a basic knowledge of state if not you can read it <a href="https://docs.flutter.dev/data-and-backend/state-mgmt/declarative">here</a>.Since we were in flashback moment let’s move forward a bit and talk about BLoC which is a state management Library for flutter.</p><p>One of the most difficult challenges when building mobile applications is seperating business logic from part of the user interface , and knowing in which state is your application in luckily for us BLoC addresses some of these challenges .</p><p>To understand BLoC we need to understand how streams work , since the BLoC library is built on top of streams .Don’t panic a stream is just a sequence of asynchronous data.For example think about a pipe of water carrying water from a water source to your house , the pipe in this case is the stream and the water is the asynchronous data simple is it not ?</p><p>We create a Stream in dart by using the async*(async generator) as following below where we are going to create a countStream as follows</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AWmqdmSJXcrXrC4S2HSE-A.png" /></figure><p>By marking a function as <strong>async*</strong> we are able to use the <strong>yield</strong> keyword and return a <strong>Stream</strong> of data. In the above example, we are returning a <strong>Stream</strong> of integers up to the <strong>max</strong> integer parameter.Since we said the stream is the pipe bringing water to your home think of async* as the pump pushing water into the pipe to your home in this case , async* is pumping asynchronous data.</p><p>We can consume the above <strong>Stream</strong> in several ways. If we wanted to write a function to return the sum of a <strong>Stream</strong> of integers it could look something like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G_neFg8uDNtfs0akgihzqQ.png" /></figure><p>By marking the above function as <strong>async</strong> we are able to use the <strong>await</strong> keyword and return a <strong>Future</strong> of integers. In this example, we are awaiting each value in the stream and returning the sum of all integers in the stream.</p><p>By marking the above function as <strong>async</strong> we are able to use the <strong>await</strong> keyword and return a <strong>Future</strong> of integers. In this example, we are awaiting each value in the stream and returning the sum of all integers in the stream.</p><p>We can put it all together like so:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zJyrw5h8Xs2aGysSDnPtXw.png" /></figure><p>With this we have completed the first step to learning BLoC , in the next article l will talk about the Cubit</p><p><strong>References</strong></p><p><a href="https://bloclibrary.dev/#/coreconcepts">BLoC Documentation</a></p><p>For more flutter based tutorials you can check out my<a href="https://www.youtube.com/channel/UCGfU4kZ0QHYriCMLhBoC1aA"> youtube channel</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=342286d311db" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Factor to consider when building machine learning(AI) apps for Africa]]></title>
            <link>https://isheunesu48.medium.com/factor-to-consider-when-building-machine-learning-ai-apps-for-africa-359701f12c5b?source=rss-60800ed0a0b5------2</link>
            <guid isPermaLink="false">https://medium.com/p/359701f12c5b</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[africa]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[deep-learning]]></category>
            <dc:creator><![CDATA[Isheunesu Tembo]]></dc:creator>
            <pubDate>Mon, 17 Jul 2023 22:02:59 GMT</pubDate>
            <atom:updated>2023-07-17T22:06:27.119Z</atom:updated>
            <content:encoded><![CDATA[<p>So l have been working on a machine learning app to help African farmers detect plant diseases using machine learning and their smart phone camera and unlike developing machine learning systems for developed countries in Africa we have a wide range of problems such as high cost of broad band , limited internet coverage ,low end smart phones which translates to limited storage on user’s devices.</p><ol><li>Africa is mobile first economy</li></ol><p>Africa is mobile<a href="https://afridigest.com/three-lessons-founders-africas-mobile-first-economy/#:~:text=More%20than%20anywhere%20else,EBANX."> first economy</a> , that means a lot of people turn to their smartphones for business learning …etc .This means that if you are developing machine learning solutions that are going to serve a lot of people these solutions must be fully optimized for mobile devices .When l developed <a href="https://play.google.com/store/apps/details?id=tembo.tech.drplantx">Dr Plant X</a> ( an app that used machine learning to help farmers detect plant diseases) l emphasized on a mobile first approach because that many farmers have a smartphone and serving ML via mobile devices would help a lot of farmers rather than using the web.</p><p>2. High cost of internet and limited internet coverage</p><p>It’s not a secret that data is very expensive in Africa as compared to other continents and also broadband coverage is poor in some areas . Thus if one is to develop machine learning solutions in such an environment one must consider a on device approach (inference takes place on the device ),which eliminates the need to communicate with a server which saves user’s data and allows the app to be used in remote areas .For example with<a href="https://play.google.com/store/apps/details?id=tembo.tech.drplantx"> Dr Plant X</a> some farmers are in remote areas which would be difficult for them to use the app if communicated with an external server , but with on device ML powered with Tensorflow lite ,they can use the application even in remote areas once the app is downloaded .</p><p>3.Application Size</p><p>As l have highlighted before people in Africa don’t have the luxury of installing large apps on their devices , thus if you are a machine learning developer developing machine learning solutions for Africa you must optimize your ML model size so that it will not result in a huge app size.When we developed Dr Plant X , we had to use the mobile net architecture , which is an architecture to build light weight deep neural networks that do not have a large size . So if you are going to develop ML solutions for Africa choose architectures with few parameters that do not result in large models</p><p>Thanks for reading please clap for this article if you find it useful.</p><p>Check out my machine learning app Dr Plant:<a href="https://play.google.com/store/apps/details?id=tembo.tech.drplantx">https://play.google.com/store/apps/details?id=tembo.tech.drplantx</a></p><p>You can also buy me a coffee :<a href="https://www.buymeacoffee.com/isheunesu4Q">https://www.buymeacoffee.com/isheunesu4Q</a></p><p>Twitter:<a href="https://twitter.com/IsheunesuTembo">https://twitter.com/IsheunesuTembo</a></p><p>LinkedIn:<a href="https://www.linkedin.com/in/isheunesu-tembo-ab340b148/">https://www.linkedin.com/in/isheunesu-tembo-ab340b148/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=359701f12c5b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Stateful vs Stateless Widget Explained For Dummies]]></title>
            <link>https://isheunesu48.medium.com/stateful-vs-stateless-widget-explained-for-dummies-d861f7bbe00c?source=rss-60800ed0a0b5------2</link>
            <guid isPermaLink="false">https://medium.com/p/d861f7bbe00c</guid>
            <category><![CDATA[flutter-widget]]></category>
            <category><![CDATA[flutter-app-development]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[statelesswidget]]></category>
            <category><![CDATA[statefulwidget]]></category>
            <dc:creator><![CDATA[Isheunesu Tembo]]></dc:creator>
            <pubDate>Sun, 05 Feb 2023 06:39:13 GMT</pubDate>
            <atom:updated>2023-02-05T06:39:13.881Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sG3dYswmGXwyFDPNJrW3lg.jpeg" /></figure><p>First let’s talk about water and a rock , before we move into stateful vs stateless widgets . Water has three states which are ice , liquid and vapour and it changes into these states when it is exposed to different conditions , for example if we heat ice at 100 degrees celsius it turns into liquid and then vapour when further heated . The opposite is true for a rock if we heat it at 100 degrees or cool it at 0 degrees celcius it remains a rock.</p><p>Let’s rewind a bit , we forgot to define what’s a state , so a state is any value that can change. So in our example the water’s state changes form ice , to liquid to vapour or vice versa , so we can easily say that water is a <strong>stateful widget </strong>since it’s state changes and a rock is a stateless widget since it’s state does not change.</p><p>So going back to stateful and stateless widget , we can say that a stateful widget is a widget with a state that can change and a stateless widget is a widget is a widget with a value that does not change. So a stateful widget is water (it’s state can change) , where a stateless widget is a rock (it’s state does not change)</p><p>That’s it from me you can watch my video on stateful vs stateless widget.</p><p><a href="https://www.youtube.com/watch?v=jXKg3g2AOJ4">https://www.youtube.com/watch?v=jXKg3g2AOJ4</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d861f7bbe00c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is dependancy injection?]]></title>
            <link>https://isheunesu48.medium.com/what-is-dependancy-injection-be119948797e?source=rss-60800ed0a0b5------2</link>
            <guid isPermaLink="false">https://medium.com/p/be119948797e</guid>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[android]]></category>
            <category><![CDATA[androiddev]]></category>
            <category><![CDATA[dependency-injection]]></category>
            <dc:creator><![CDATA[Isheunesu Tembo]]></dc:creator>
            <pubDate>Mon, 02 Jan 2023 22:10:30 GMT</pubDate>
            <atom:updated>2023-01-03T11:21:33.562Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-EOiibBUQ27UjYJ2adJ1fQ.png" /></figure><p>In Object Oriented Programming Classes depend on each other , for example we might have a car class and an engine class. For the car to move it depends on the engine class , so the car class is dependend on the engine class . Let’s take a look at the two classes:</p><pre>class Engine {<br><br>    fun start(){}<br>}</pre><pre>class Car {<br>  private val engine=Engine()<br><br>    fun start(){<br>        engine.start()<br>        println(&quot;Car has started&quot;)<br>    }<br>}</pre><p>As you can see from the two classes to make use of the Engine class inside the car class we have to instantiate the engine class inside the Car class , as shown above.</p><p>What about if we have the same car but with 2 different types of engine implementations , for example for the same Car we might have disiel engines and electric engines so what do we do ? Create another Car class with a different engine ? but remember it’s the same Car but with different engine implementation.</p><p>To solve this we will have to pass in the engine class as a parameter to the car class as shown below , this is what we call dependancy injection.</p><pre>class Car(private val engine:Engine) {<br><br><br>    fun start(){<br>        engine.start()<br>        println(&quot;Car has started&quot;)<br>    }<br>}</pre><p>In this way rather than changing the Car class , we will just inject the different engine implementation like below for a disiel car</p><pre>fun main(args: Array&lt;String&gt;) {<br>      val disielEngine=Engine()<br>     val car=Car(disielEngine)<br>    car.start()<br><br><br>}</pre><p>and for an electric engine like below:</p><pre>fun main(args: Array&lt;String&gt;) {<br>      val electricEngine=Engine()<br>     val car=Car(electricEngine)<br>    car.start()<br><br><br>}</pre><p>One more example , Let’s say we have a Phone class and a processor class , we know that the phone is dependent on the processor class.Like shown below</p><pre>class Phone() {<br><br>    val processor=Processor()<br><br>    fun start(){<br>        processor.turnOn()<br>        println(&quot;processor is On&quot;)<br>    }<br>}</pre><pre>class Processor {<br><br>    fun turnOn(){}<br>}</pre><p>Let’s say we have a phone with different processors for example samsung galaxy s8 which came with a qualcom processor and an exynos processor.</p><p>With the code above to provide 2 processor we will have two create another phone class so that we pass the other processor but remember we only have one galaxy s8 so it does not make sense to create another one so to implement another processor we simply pass in the processor object as a parameter to the phone class like below:</p><pre>class Phone(val processor: Processor) {<br><br>    <br><br>    fun start(){<br>        processor.turnOn()<br>        println(&quot;processor is On&quot;)<br>    }<br>}</pre><p>I hope this helps you understand dependancy injection you can also check my video on youtube</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F72FL-nF53as%3Fstart%3D76%26feature%3Doembed%26start%3D76&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D72FL-nF53as&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F72FL-nF53as%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/a6c1fee7fbffc095f861488c80cfe80c/href">https://medium.com/media/a6c1fee7fbffc095f861488c80cfe80c/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=be119948797e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The mistakes I made when I created my first android app.]]></title>
            <link>https://isheunesu48.medium.com/the-mistakes-i-made-when-i-created-my-first-android-app-68267767c303?source=rss-60800ed0a0b5------2</link>
            <guid isPermaLink="false">https://medium.com/p/68267767c303</guid>
            <category><![CDATA[firebase]]></category>
            <category><![CDATA[android-architecture]]></category>
            <category><![CDATA[kotlin]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[android-app-development]]></category>
            <dc:creator><![CDATA[Isheunesu Tembo]]></dc:creator>
            <pubDate>Sat, 02 Apr 2022 20:53:03 GMT</pubDate>
            <atom:updated>2022-04-02T20:59:28.222Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*08jRDtRjtJriHY-j4C6-vg.jpeg" /></figure><p>So before we dive what happened in the middle of the ocean let us begin by looking into what happened at the shore so that we can have a clear path of where we are going . I grew up in a small town called Chinhoyi in Zimbabwe , so one of the main problems was that people used to go house by house knocking and asking if they was a spare room or vacant house to rent. As someone who grew up watching all these problem l decided to use my dev skills to create a mobile app where house owners , agents and landlord can list their properties on the app l developed which l called houseflip. This would make it easier for those looking for homes or rooms to rent by just browsing on the listings in the app and if they find the house they like they can just contact the homeowner ,agent or landlord via the app.</p><p>Now that we are aware of what took place at the shore , let’s dive into the middle of the ocean . So when l created houseflip there are a couple of mistakes that l made .</p><ol><li>The first mistake that l made was using the wrong database for my app , you see firebase is great backend as a service , it allows rapid development for developers but you will run in to a lot of problems with firebase . For an app like houseflip l wanted to allow users to be able to search by city ,town or street but l ran into problems because queries on the cloud firestore with firebase are limited you can’t do full text search . If you want to full text search you will have to use another third part library called algolia which would get expensive if you are just a startup just starting out and without a huge budget . Firebase is very good BAAS but if you want to something with advanced queries better create your own backend with node.js , django or flask.</li><li>The second mistake l made was using a poor architecture for my mobile app. If you are developing android applications you should not place business logic code inside activities and fragments . When l created houseflip I did not know about this and l just wrote logic inside fragments and activities. The problem that comes with this poor architecture is that when the OS kills activities , let’s say if someone calls while using houseflip or if the user rotates the phone the data is lost which is a bad experience for user experience . Also if as your app gains more users this poor architecture does not scale . For using a good android architecture l recommend you check the official <a href="https://developer.android.com/topic/architecture">android architecture components </a>.</li><li>The third mistake was that l was so obsessed with developing more features for the application rather than marketing the app itself. Imagine a this scenario you build a nice hotel and you don’t spread the word or place a banner at the gate that there is a new hotel in town do you think anyone will come ? No one will come until you advertise . The same scenario is similar to creating a mobile application and not market it . You should focus on marketing strategies to make sure that the application is known by landlords and users which is something that l did not do. l should have focused more on making sure that the app is known out there.</li></ol><p>Thanks for reading guys , l hope you might have learned something from this short article . You can also subscribe to my <a href="https://www.youtube.com/channel/UCGfU4kZ0QHYriCMLhBoC1aA">youtube</a> channel for more mobile development videos and machine learning tutorials.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=68267767c303" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cross-Validation Using K-Fold With Scikit-Learn]]></title>
            <link>https://isheunesu48.medium.com/cross-validation-using-k-fold-with-scikit-learn-cfc44bf1ce6?source=rss-60800ed0a0b5------2</link>
            <guid isPermaLink="false">https://medium.com/p/cfc44bf1ce6</guid>
            <category><![CDATA[k-fold-cross-validation]]></category>
            <category><![CDATA[k-nearest-neighbours]]></category>
            <category><![CDATA[scikit-learn]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Isheunesu Tembo]]></dc:creator>
            <pubDate>Mon, 14 Mar 2022 16:10:31 GMT</pubDate>
            <atom:updated>2022-03-14T16:14:08.452Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/292/1*gC-U7SMZ9YYtp3rjwqlRFQ.png" /></figure><p>Imagine that you are a medical research scientist and your task is to find a cure for a particular disease , you perform experiments and test the drug on animals before you administer it to humans .</p><p>The same happens with machine learning we train the models , test them , then deploy them for real world use.</p><p>Learning the performance of a prediction function and testing it on the same data is a methodological mistake. A model would just repeat the labels of the samples that it has just seen would have have a perfect score but would fail to predict anything useful on yet unseen data , this situation is what we call overfitting. To avoid it , it is common to hold out part of available data as test set.</p><p>When evaluating different hyparameters for estimators such as the C setting that must be manually set for an SVM classifier , there is still a high risk of overfitting on the test set because parameters can be tweaked until the estimator performs optimally. This way , knowledge about the test set can “leak” into the model and evaluation metrics will no longer report on the generalization performance.</p><p>To solve this problem , yet another part of the dataset can be held as a “validation set”.</p><p>By partitioning data another problem arises which is we drastically reduce the number of samples which can be used for learning by the model , and the results can depend on a particular random choice for the pair (training , validation) sets.</p><p>A solution to this problem is a procedure called cross-validation , but the validation set is no longer needed when doing CV. Using an approach called K-fold , the training set is split into k smaller sets.</p><p>The following procedure is followed for each of the K-fold :</p><p>1 .A model is trained using K-1 of the folds as training data</p><p>2.The resulting model is validated on the remaining part of the data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/885/1*E1e-8OmoqJaSmHxxPXcPGg.png" /></figure><p>Let see a code example :</p><pre><strong>import</strong> numpy <strong>as</strong> np <br><strong>import</strong> pandas <strong>as</strong> pd<br><strong>import</strong> os</pre><pre><strong>from</strong> sklearn.datasets <strong>import</strong> load_iris<br>iris<strong>=</strong>load_iris()<br><br>X<strong>=</strong>iris<strong>.</strong>data<br>y<strong>=</strong>iris<strong>.</strong>target</pre><pre>X<strong>=</strong>(X<strong>-</strong>np<strong>.</strong>min(X))<strong>/</strong>(np<strong>.</strong>max(X)<strong>-</strong>np<strong>.</strong>min(X))</pre><p>In [5]:</p><pre><strong>from</strong> sklearn.model_selection <strong>import</strong> train_test_split<br>x_train, x_test, y_train, y_test<strong>=</strong>train_test_split(X,y,test_size<strong>=</strong>0.3)</pre><p>In [6]:</p><pre><strong>from</strong> sklearn.neighbors  <strong>import</strong> KNeighborsClassifier<br>knn<strong>=</strong> KNeighborsClassifier(n_neighbors<strong>=</strong>3)</pre><p>In [7]:</p><pre><strong>from</strong> sklearn.model_selection <strong>import</strong> cross_val_score<br>accuracies<strong>=</strong>cross_val_score(estimator<strong>=</strong>knn,X<strong>=</strong>x_train,y<strong>=</strong>y_train,cv<strong>=</strong>10)<br>accuracies</pre><pre>array([0.83333333, 1.        , 1.        , 1.        , 1.        ,<br>       1.        , 1.        , 1.        , 1.        , 1.        ])</pre><pre>print(&quot;average accuracy :&quot;,np<strong>.</strong>mean(accuracies))<br>print(&quot;average std :&quot;,np<strong>.</strong>std(accuracies))</pre><pre>average accuracy : 0.9833333333333334<br>average std : 0.04999999999999999</pre><pre>knn<strong>.</strong>fit(x_train,y_train)<br>print(&quot;test accuracy :&quot;,knn<strong>.</strong>score(x_test,y_test))</pre><pre>test accuracy : 0.9555555555555556</pre><h3>GridSearch</h3><pre><strong>from</strong> sklearn.model_selection <strong>import</strong> GridSearchCV<br><br>grid <strong>=</strong>{&quot;n_neighbors&quot;:np<strong>.</strong>arange(1,50)}<br>knn<strong>=</strong> KNeighborsClassifier()<br>knn_cv<strong>=</strong>GridSearchCV(knn,grid,cv<strong>=</strong>10) <em>#GridSearchCV</em><br>knn_cv<strong>.</strong>fit(X,y)</pre><pre>rint(&quot;tuned hyperparameter K:&quot;,knn_cv<strong>.</strong>best_params_)<br>print(&quot;tuned parametreye göre en iyi accuracy (best score):&quot;,knn_cv<strong>.</strong>best_score_)</pre><pre>tuned hyperparameter K: {&#39;n_neighbors&#39;: 13}<br>tuned parametreye göre en iyi accuracy (best score): 0.98</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*V3GstUTuMJDUmF2L0tqABw.png" /></figure><h3>What is K-Fold Cross Validation</h3><p>K-Fold CV is where a given data set is split into a K number of sections/folds where each fold is used as a testing set at some point. Lets take the scenario of 5-Fold cross validation(K=5). Here, the data set is split into 5 folds. In the first iteration, the first fold is used to test the model and the rest are used to train the model. In the second iteration, 2nd fold is used as the testing set while the rest serve as the training set. This process is repeated until each fold of the 5 folds have been used as the testing set.</p><pre><strong>from</strong> sklearn.model_selection <strong>import</strong> KFold<br>scores<strong>=</strong>[]<br>kFold<strong>=</strong>KFold(n_splits<strong>=</strong>10,random_state<strong>=</strong>42,shuffle<strong>=False</strong>)<br><strong>for</strong> train_index,test_index <strong>in</strong> kFold<strong>.</strong>split(X):<br>    print(&quot;Train Index: &quot;, train_index, &quot;\n&quot;)<br>    print(&quot;Test Index: &quot;, test_index)<br>    <br>    X_train, X_test, y_train, y_test <strong>=</strong> X[train_index], X[test_index], y[train_index], y[test_index]<br>    knn<strong>.</strong>fit(X_train, y_train)<br>    scores<strong>.</strong>append(knn<strong>.</strong>score(X_test, y_test))</pre><pre>knn<strong>.</strong>fit(X_train,y_train)<br>scores<strong>.</strong>append(knn<strong>.</strong>score(X_test,y_test))</pre><pre>print(np<strong>.</strong>mean(scores))</pre><pre>0.9393939393939394</pre><pre>cross_val_score(knn, X, y, cv<strong>=</strong>10)</pre><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FO0rjfiJbcMs%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DO0rjfiJbcMs&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FO0rjfiJbcMs%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/94efb403f53ca26a07f6cecbc3f05aa5/href">https://medium.com/media/94efb403f53ca26a07f6cecbc3f05aa5/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cfc44bf1ce6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Natural Language Processing , what is it ? How can we represent text using the Tensorflow Tokenizer]]></title>
            <link>https://isheunesu48.medium.com/natural-language-processing-what-is-it-how-can-we-represent-text-using-the-tensorflow-tokenizer-a64330827ce8?source=rss-60800ed0a0b5------2</link>
            <guid isPermaLink="false">https://medium.com/p/a64330827ce8</guid>
            <category><![CDATA[keras]]></category>
            <category><![CDATA[naturallanguageprocessing]]></category>
            <category><![CDATA[tensorflow]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[tokenization]]></category>
            <dc:creator><![CDATA[Isheunesu Tembo]]></dc:creator>
            <pubDate>Mon, 14 Mar 2022 10:52:56 GMT</pubDate>
            <atom:updated>2022-03-14T10:52:56.672Z</atom:updated>
            <content:encoded><![CDATA[<h3>Natural Language Processing , what is it ? How can we represent text using the Tensorflow Tokenizer</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/806/1*d1OEZwAbDdKzrhHsTlZJnQ.jpeg" /></figure><p>One thing that makes us great as humans is our ability to learn new languages and communicate with other humans ,but can computers match our ability to understand languages ? It seems so , recent advancements in computational power and deep learning have made it possible for computers to understand human languages , but wait a bit computers don’t understand the human language as it we need to hack the human language for them to understand.</p><p>Computers cannot understand text so we need to convert human language into numbers , strange right ?How can we do that , they are two ways of doing that .</p><p><strong>Representing Text Using Character Level Representation</strong></p><p>We represent test by treating each character as a number. Given that we have C different characters in our text corpus ,the word ‘Hello’ could be represented by a tensor of Cx5.Each letter would correspond to tensor in one-hot encoding</p><p><strong>Representing Text Using Word Representation</strong></p><p>we create a vocubulary of all words in our text , and then represent the words using one-hot encoding .This approach is better than character level representation because each letter by itself does not have much meaning .Given a large dictionary size , we need to deal with high dimensional sparse tensors.</p><p><strong>Text Vectorization</strong></p><p>If we want word-level representation , we need to do 2 things :</p><ul><li>use a tokenizer to split text into tokens</li><li>build a vocubulary of those tokens</li></ul><p>Now that we know the ways of representing text , let’s dive into how we can do it with tensorflow and keras. First thing we need to import the dependencies</p><p>import tensorflow as tf<br>from tensorflow import keras<br>from tensorflow.keras.preprocessing.text import Tokenizer<br>from tensorflow.keras.preprocessing.sequence import pad_sequences</p><p>Let’s take a look at the following list of sentences</p><p>sentences=[‘I love my girlfriend’,<br> ‘I love my dog!’,<br> ‘You love my dog ?’,<br> ]</p><p>We need to initialize the tokenizer from tensorflow and after that we fit our sentences to the tokenizer</p><p>tokenizer=Tokenizer(num_words=100)<br>tokenizer.fit_on_texts(sentences)<br>word_index=tokenizer.word_index<br>print(word_index)</p><pre>{&#39;love&#39;: 1, &#39;my&#39;: 2, &#39;i&#39;: 3, &#39;dog&#39;: 4, &#39;girlfriend&#39;: 5, &#39;you&#39;: 6}</pre><p>As you can see our words have been converted into numbers as shown above but the words do not make sense for them to make sense we need to convert them into word sequences.</p><p>sequences=tokenizer.texts_to_sequences(sentences)</p><p>print(sequences)</p><pre>[[3, 1, 2, 5], [3, 1, 2, 4], [6, 1, 2, 4]]</pre><p>As you can see we have converted our words into sequence of words</p><p>for example the first sequence [3,1,2,5] represents “ l love my dog ”</p><p>Now let’s feed our text to sequences with test data</p><p>test_data=[‘I really love my dog’,<br> ‘my dog loves my manatee’]</p><p>test_seq=tokenizer.texts_to_sequences(test_data)<br>print(test_seq)</p><pre>[[3, 1, 2, 4], [2, 4, 2]]</pre><p>Let’s take the first sequence [3,1,2,4] represents “my i my girlfriend” as you can see that this sentence is meaningless , because our vocubulary of words is small , when training sequence models you need a large vocubulary of words , but how can we solve this ?</p><p>To solve this we need to pass in the oov_token into the Tokenizer instance so that all unseen words are replaced with oov</p><p>tokenizer=Tokenizer(num_words=100,oov_token=”&lt;OOV&gt;”)<br>tokenizer.fit_on_texts(sentences)<br>word_index=tokenizer.word_index<br>print(word_index)</p><pre>{&#39;&lt;OOV&gt;&#39;: 1, &#39;love&#39;: 2, &#39;my&#39;: 3, &#39;i&#39;: 4, &#39;dog&#39;: 5, &#39;girlfriend&#39;: 6, &#39;you&#39;: 7}</pre><p>As you can see we now have &lt;oov&gt; into our vocubulary</p><p>Let’s run our test data again and see</p><p>test_seq=tokenizer.texts_to_sequences(test_data)<br>print(test_seq)</p><pre>[[4, 1, 2, 3, 5], [3, 5, 1, 3, 1]]</pre><p>As you can see now from our sequence [4,1,2,3,5] we now have “I &lt;oov&gt; love my girlfriend” now it’s now better.</p><p>The other problem we will face is that sentences are not of equal length , this will give us problems when training sequence models , so to solve this we need to introduce padding to do so</p><p>padded=pad_sequences(sequences)<br>print(padded)</p><pre>[[ 0  0  0  5  3  2  7]<br> [ 0  0  0  5  3  2  4]<br> [ 0  0  0  6  3  2  4]<br> [ 8  6  9  2  4 10 11]]</pre><p>The whole code:</p><p>import tensorflow as tf<br>from tensorflow import keras<br>from tensorflow.keras.preprocessing.text import Tokenizer<br>from tensorflow.keras.preprocessing.sequence import pad_sequences</p><p>sentences=[‘I love my girlfriend’,<br> ‘I love my dog!’,<br> ‘You love my dog ?’,<br> ‘Do you think my dog is amazing ?’]</p><p>tokenizer=Tokenizer(num_words=100,oov_token=”&lt;OOV&gt;”)<br>tokenizer.fit_on_texts(sentences)<br>word_index=tokenizer.word_index<br>print(word_index)</p><p>sequences=tokenizer.texts_to_sequences(sentences)</p><p>print(sequences)</p><p>test_data=[‘I really love my dog’,<br> ‘my dog loves my manatee’]</p><p>padded=pad_sequences(sequences)<br>print(padded)</p><p>Now that we have computers understand the human language .</p><p>You can check out my youtube video</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FL841-s8DX0I&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DL841-s8DX0I&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/75077d4062f49643b10379eda3921f60/href">https://medium.com/media/75077d4062f49643b10379eda3921f60/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a64330827ce8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why you should develop your next mobile app using Android Architecture Components Part 1]]></title>
            <link>https://isheunesu48.medium.com/why-you-should-develop-your-next-mobile-app-using-android-architecture-components-part-1-9ecae9a346a8?source=rss-60800ed0a0b5------2</link>
            <guid isPermaLink="false">https://medium.com/p/9ecae9a346a8</guid>
            <category><![CDATA[architecture-components]]></category>
            <category><![CDATA[native-app]]></category>
            <category><![CDATA[android-app-development]]></category>
            <category><![CDATA[firebase]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Isheunesu Tembo]]></dc:creator>
            <pubDate>Fri, 02 Apr 2021 10:44:27 GMT</pubDate>
            <atom:updated>2021-04-02T10:44:27.950Z</atom:updated>
            <content:encoded><![CDATA[<p>Let’s assuming you are building an ecommerce app right (you want to build the next amazon).Let’s say that a user was browsing for phones to buy and left the app , do you want the same user to come and find out that the same Activity they were on about phones is killed and their back to the menu Activity ? , obviously no.</p><p>The way android UI classes are designed that is Activity and Fragment classes is to only handle UI logic and not business logic .If you are aware of the activity lifecycle which l am sure you are if not here is the <a href="https://developer.android.com/guide/components/activities/activity-lifecycle#:~:text=to%20App%20Architecture.-,Activity%2Dlifecycle%20concepts,activity%20enters%20a%20new%20state."><strong>link</strong></a>. The way android works is that the OS kills the activity and restarts it depending on the user interaction with the app. So to solve our ecommerce app user experience above the best way is to use the android architecture components .</p><p>What is android architecture components ?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*-yY0l4XD3kLcZz0rO1sfRA.png" /><figcaption>Android Architecture Components diagram</figcaption></figure><p>Android architecture components are a collection of libraries that help you design ,robust ,testable , and maintainable apps. So let me explain this part here let’s say for our ecommerce app separating the UI and business makes it easier to perform tests as we can have teams working independently on the UI and the business logic making our mobile app easier to perform tests.</p><p>To solve our problem of the the OS killing and restarting the app depending on the user interactions (let’s say the user receives a phone call during browsing smartphones on our app we want the user to go back Activity he /she was before receiving the phone call) we need to drive our UI from Model(View Model as shown in the diagram) instead of the View classes (Activity and Fragments)</p><p>Models are components that are responsible for handling the data for our app and they are completely independent from the View classes .This is good news for us because that means that they are unaffected by the app’s lifecycle and the associated concerns. Models are also persistent which is ideal for the following reasons :</p><p><strong>.</strong>Users don’t lose data if the android OS destroys your app to free up resources</p><p>.Our app continues to work in cases when a network is flaky or unavailable</p><p>In the picture above about the architecture component each component depends on the component one level below it .For example the Activity/Fragment depend only on the view model .The repository class is only class that depends on multiple other classes. The good thing about using the architecture components is that a consistent and pleasant user experience.</p><p>Thanks for reading the article if it helped you don’t be afraid to click the clap button , and stay tuned for part 2.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9ecae9a346a8" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>