<?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 Tewodros Kederalah on Medium]]></title>
        <description><![CDATA[Stories by Tewodros Kederalah on Medium]]></description>
        <link>https://medium.com/@teddylnk1?source=rss-5dd818f232c2------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*KIaDZgkFzcPzTzmr.</url>
            <title>Stories by Tewodros Kederalah on Medium</title>
            <link>https://medium.com/@teddylnk1?source=rss-5dd818f232c2------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 10:39:16 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@teddylnk1/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[Building an Ethereum dApp for Geofencing]]></title>
            <link>https://medium.com/@teddylnk1/building-an-ethereum-smart-contract-4ee68a2718?source=rss-5dd818f232c2------2</link>
            <guid isPermaLink="false">https://medium.com/p/4ee68a2718</guid>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[web3]]></category>
            <category><![CDATA[dapps]]></category>
            <dc:creator><![CDATA[Tewodros Kederalah]]></dc:creator>
            <pubDate>Sat, 16 Jul 2022 16:08:59 GMT</pubDate>
            <atom:updated>2022-07-26T14:23:18.507Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*CX-TziIK0wRHfgYpWRDBhQ.png" /></figure><h3>Introduction</h3><p>There are a lot of mechanisms employers use to track the attendance of their employees. Most of the current systems are designed for physical workplaces but in this day and age where remote work has become so prominent, we need a solution that works for all scenarios. The solution proposed in this project is to put an employee inside a geofence for the work hour duration or for hourly workers, to count the number of hours the employee spent within that geofence. The location of the employee would then be used to check if the employee fulfilled compliance or in the case of hourly workers, we can count the number of hours spent within the geofence to confirm the number of hours spent in the workplace.</p><p>This project is based on Web3 technology specifically Ethereum smart contract. In the sections below, I will first explain some key terminologies required to understand this project. Then I will describe the system built to solve the problem in detail.</p><h4>Key Concepts</h4><p>In this section, I will go over the basics of blockchain which are essential to understanding the system.</p><h4>What is a blockchain?</h4><p>A blockchain is essentially a digital ledger of transactions that is duplicated and distributed across the entire network of computer systems on the blockchain. Each block in the chain contains several transactions, and every time a new transaction occurs on the blockchain, a record of that transaction is added to every node’s ledger. This decentralization aspect provides a fault-tolerant system where there is no single point of failure.</p><h4>What is Ethereum?</h4><p>Ethereum is an implementation of blockchain also known as a second-generation blockchain. Second-generation blockchains in addition to maintaining a distributed ledger for transactions enabled smart contracts. The native currency of Ethereum is ether(ETH).</p><h4>What are smart contracts?</h4><p>A smart contract is a piece of code that implements arbitrary rules. A useful way of thinking about smart contracts is just to realize that smart contracts are essentially the same as contracts — with the difference that they will automatically execute any actions that the parties involved have agreed to.</p><p>In Ethereum, smart contracts are developed using a programming language known as Solidity. Once the smart contract is written, it is then compiled into bytecode( a lower level representation of the smart contract) and then deployed onto the EVM(Ethereum Virtual Machine).</p><p>The Ethereum Virtual Machine is a virtual component that is contained in every Ethereum node and is able to execute compiled smart contracts(bytecodes).</p><h4>Accounts</h4><p>Accounts are entities with an ether balance that can send transactions on Ethereum. Accounts can either be user-controlled or deployed as smart contracts. There are two types of accounts;</p><ul><li>Externally owned — controlled by anyone with private keys</li><li>Contract — a smart contract deployed to the network, controlled by code</li></ul><p>The main difference between the two types of contracts are</p><ul><li>Contract accounts can only send transactions in response to receiving a transaction.</li><li>Transactions from an external account to a contract account can trigger code that can execute many different actions.</li><li>Creating an externally owned contract costs nothing while creating a contract account has a cost because we’re using network storage.</li></ul><h4>Gas Fees</h4><p>In Ethereum, every transaction that is recorded in the blockchain incurs fees. This fee is for the computation power used to validate and register the transaction on the blockchain. Fees in Ethereum are called “gas”.</p><p>So Gas is the unit used to measure the amount of computational resource required to execute a specific operation on the Ethereum network.</p><h3>Business Objective</h3><p>The refund by location smart contract is aimed to be used when one party, for example, an employer, agrees to pay another party, for example, an employee, for being present in a certain geographic area for a certain duration. The employee’s phone sends its GPS location to a smart contract at a certain interval. Based on the pre-agreed contract codified in an Ethereum smart contract, a cryptocurrency payment is executed when all the agreed conditions are met.</p><p>If at any point, the GPS sensor indicates that an employee is outside the range of the agreed GPS area, the contract state will be updated to indicate that it is out of compliance.</p><p>By the end of this project, we should produce an Ethereum-based dApp that has both the smart contract tested and deployed in a testnet and a front end that will allow monitoring of the status.</p><p>The project will have three main components</p><ul><li>Web app — used by the employer to monitor the status of employees and add or remove employees from the system</li><li>Mobile app — used to monitor the employee’s location</li><li>Smart contract — handles payment to the employee by verifying compliance</li></ul><h4>Web app</h4><p>The web app is used by the employer to add and remove employees to be tracked by the system. It also provides feedback on the status of each employee registered on the system.</p><p>The employer provides the following information upon registering a new employee onto the system.</p><ul><li>Employee’s Wallet address — to receive the payment if the employee complies with the contract.</li><li>Time duration either in days or hours required by the employee to be at the designated location</li><li>Location — The GPS coordinate of the location the employee is supposed to be.</li><li>Radius — the maximum distance the employee is allowed to move from the location without defying compliance.</li><li>Payment amount — the amount of ether(ETH) to be paid if the employee complies</li></ul><p>The Web app is implemented using Flutter. Flutter is an open-source framework by Google for building beautiful, natively compiled, multi-platform applications from a single codebase. The following is a basic UI built in Flutter for the homepage of the admin panel.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o3vq38DTU85gBdkgS2ovig.png" /></figure><h4>Mobile App</h4><p>The mobile app is used to monitor the location of the employee throughout the work time duration. The app will run in the background and send its location to the smart contract at random times. The app will also randomly require the employee to manually confirm a prompt just to make sure that the device is not left in the required location. The current implementation is done in Flutter and it only allows sending the location but in future iterations, the above mention functionality will also be added.</p><h4>Smart Contract</h4><p>The smart contract is the autonomous part of the system which accepts new users from the employer and then receives the location of the employees and evaluates their compliance and makes payment.</p><p>The smart contract contains the following functionalities</p><p>Employer Side</p><ul><li>Add a new employee into the system by providing wallet address, location, duration, and amount to be paid.</li><li>Get existing employee’s compliance status</li></ul><p>Employee Side</p><ul><li>Send GPS coordinate to smart contract</li></ul><p>The smart contract is built using Solidity using <a href="https://remix.ethereum.org/">Remix IDE</a>. Remix IDE is a development environment on the web for Solidity. The smart contract is then deployed using <a href="https://infura.io/">Infura</a> which provides an easy and scalable way to deploy smart contracts.</p><h3>Conclusion</h3><p>This solution provides an easy way of monitoring attendance and can be used for other use cases. For future iterations, the tech stack used in building the mobile app and the web app will be converted to Javascript-based frameworks since there are a lot of libraries that could facilitate the interaction with the blockchain. There are very few web3 libraries in Dart and it made the development cumbersome. The implementation of this project is found on my <a href="https://github.com/teddyk251/Refund-by-Location-dApp">GitHub</a>. Check out my other <a href="https://medium.com/@teddylnk1">blogs</a> to see the other projects I’m working on.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4ee68a2718" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[NFT Certificate Issuer dApp with Algorand]]></title>
            <link>https://medium.com/@teddylnk1/algorand-web3-dapp-98c7a37af42c?source=rss-5dd818f232c2------2</link>
            <guid isPermaLink="false">https://medium.com/p/98c7a37af42c</guid>
            <dc:creator><![CDATA[Tewodros Kederalah]]></dc:creator>
            <pubDate>Sat, 18 Jun 2022 18:49:43 GMT</pubDate>
            <atom:updated>2022-06-23T19:41:34.016Z</atom:updated>
            <content:encoded><![CDATA[<h4>Business Objective</h4><p>This project is aimed at solving the challenge of ensuring that certificates are available to all 10 Academy trainees in a secure way and allowing certificate holders to benefit from smart contract actions.</p><p>At present, certificates are distributed as simple PDF files, without the ability to verify their authenticity nor can 10 Academy undertake smart actions with the trainees and their contracts.</p><p>The objective is to generate and distribute Non-Fungible Tokens (NFTs) as certificates to represent the successful completion of a weekly challenge to trainees. The Algorand blockchain is chosen to implement the project.</p><h4>Tech stack used for the project</h4><p>The front-end is implemented using React.js and the backend is implemented using Python specifically Flask. The smart contracts are also going to be implemented using Python specifically PyTeal. MongoDB is used in order to store information about users. PureStake’s API is also chosen to easily connect with the Algorand Network.</p><h4>What has been implemented so far</h4><p>A basic structure for the project has been implemented. A user, either a staff or a trainee, can register on the system and they would be forwarded to a specific page based on their role.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q2drR6K1oondMcxDzpBV8g.png" /><figcaption>Login Page</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oI2NeRFuO1elAk_9SV3Fdw.png" /><figcaption>Signup Page</figcaption></figure><p>Fields such as the public key would not be necessary once wallet integration is implemented.</p><p><a href="https://github.com/teddyk251/10x-certificate-dist-dApp">GitHub - teddyk251/10x-certificate-dist-dApp</a></p><h4>Future Plans</h4><p>So far a basic login and signup section of the project has been implemented. In the future, I intend to finish the entire project while also making a series of blog posts outlining each step of the development. The features would include wallet integration, the development of smart contracts, and a fully functional NFT minter.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=98c7a37af42c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Amharic Language Speech Recognition]]></title>
            <link>https://medium.com/@teddylnk1/amharic-language-speech-recognition-60154b29aaa3?source=rss-5dd818f232c2------2</link>
            <guid isPermaLink="false">https://medium.com/p/60154b29aaa3</guid>
            <dc:creator><![CDATA[Tewodros Kederalah]]></dc:creator>
            <pubDate>Thu, 09 Jun 2022 20:37:57 GMT</pubDate>
            <atom:updated>2022-06-14T09:01:29.443Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/628/1*nYcEj6aCooc9TYa2oDpM9g.png" /></figure><h3>Introduction</h3><p>In this article, we will explore how to build an Amharic Speech-to-text model which generates the text from the speech with good accuracy. We will go through how the model is built, the architectures chosen and the preprocessing required to train the model. The model is accessible through a web app where users can easily upload speech audio and get the Amharic transcription of the audio.</p><h3>Objective</h3><p>The World Food Program wants to deploy an intelligent form that collects nutritional information of food bought and sold at markets in two different countries in Africa — Ethiopia and Kenya. The design of this intelligent form requires selected people to install an app on their mobile phones, and whenever they buy food, they use their voice to activate the app to register the list of items they just bought in their own language. The intelligent systems in the app are expected to live to transcribe the speech-to-text and organize the information in an easy-to-process way in a database.</p><h3>Github Link</h3><p><a href="https://github.com/teddyk251/STT">GitHub - teddyk251/STT: A speech to text implementation for the Amharic and Swahili languages</a></p><h3>Data Preprocessing</h3><p>The dataset used in this project is the <a href="https://github.com/getalp/ALFFA_PUBLIC">ALFFA PUBLIC </a>dataset. It contains around 18 hours of Amharic speech with each audio clip ranging from 2 seconds to about 18 seconds. The transcription for the audio clips is also provided.</p><p>Since the goal is to build speech to text model, the input features are the audio clips and the target labels are the corresponding transcriptions.</p><p>The audio clips go through a series of preprocessing steps before they are fed to the model so we will go through each step in detail.</p><h4>Sampling Rate Standardization</h4><p>In order to generate uniform data, we are going to sample all the audio clips with the same sampling rate. The sampling rate chosen is 16kHz. The reason for choosing 16 kHz as our sampling rate is because it gives a good balance between retaining as much information as possible from our audio and reducing the computational complexity of training with audio of larger sampling rates.</p><h4>Audio Resizing</h4><p>The audio clips have a duration ranging from 2 seconds to about 19 seconds. Sampling audios with varying lengths will result in variable lengths of the input features. So in order to make the length of the input features uniform, we’ll resize each audio clip. The highest duration of an audio clip in the dataset is about 18.4 seconds. We’ll pad all other audio clips with zeros so that they will all have a duration of 18.4 seconds.</p><h4>Converting Mono to Stereo</h4><p>The dataset contains both stereo and mono audio clips. Again to standardize the input of our model we will convert all audio clips to stereo. This means we will duplicate the mono channel and combine them to convert them to stereo.</p><h4>Data Augmentation</h4><p>We apply data augmentation techniques such as changing the pitch and injecting random noise into the audio clips to add more variety to our input data.</p><h4>Feature Generation(Spectrograms)</h4><p>As a final step, we will convert the raw audio to Mel Spectrograms. A spectrogram captures the nature of the audio as an image by decomposing it into the set of frequencies that are included in it.</p><h3>Deep Learning Architecture</h3><h4>Deep Speech 2</h4><p>Deep Speech 2 was developed by a research team in Baidu. This paper gave a significant improvement as compared to its predecessor.</p><h4>Architecture</h4><p>This model takes as input the log-spectogram of the audio wave. This spectogram is fed to the network where the first 2–3 layers are convolutional. Convolutional layers help us to extract features in images and the first 3 layers extract as many features as possible from the spectogram. They use a special type of CNNs called Residual Convolutional Neural Networks. These have residual connections connecting the previous layer&#39;s output to the layer head, which results in a better performance gain and generalizes better.</p><p>The next layers are recurrent layers specifically Bidirectional Recurrent Neural Networks. Bidirectional RNNs as the name implies use the context from two directions i.e. from frames before it and also frames after it. This helps the model to make better predictions, as each step will have more information. The output of the recurrent layer would be a probability matrix of characters.</p><p>This model uses the CTC loss function. The CTC loss function solves the problem faced with alignment. In this case, CTC solves the problem faced with the variability in length of the input feature i.e the audio sequence, and the output i.e the words by aligning the input and output features.</p><h4>Model Evaluation</h4><p>The metric used for evaluation in this project is the Word Error Rate. The Word Error Rate compares the transcription of the model with the true transcription and measures the error between them.</p><h3>Training and Result</h3><p>Our model was trained for 25 epochs taking about 4 hours on an NVIDIA A10 GPU. The resulting model has a word error rate of 0.5735.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7hS_CN90V73g67EqFKWNXA.png" /><figcaption>Model Result</figcaption></figure><h3>Bias and Fairness</h3><p>The data contained both male and female voices so in that aspect it is representative. But there are many dialects in the Amharic language and the dataset only consists of one dialect. It was not possible to get additional data that was representative of the other dialects. The model has limitations in transcribing audio clips of dialects other than what it was trained on.</p><h3>Future Work</h3><p>We plan to further improve the accuracy of our model by collecting more representative data. The model was trained for a very limited time and we plan to train the model for longer epochs with more data.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=60154b29aaa3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Rossmann Sales Forecasting]]></title>
            <link>https://medium.com/@teddylnk1/time-series-forecasting-34a98cf16df8?source=rss-5dd818f232c2------2</link>
            <guid isPermaLink="false">https://medium.com/p/34a98cf16df8</guid>
            <dc:creator><![CDATA[Tewodros Kederalah]]></dc:creator>
            <pubDate>Sat, 28 May 2022 19:25:09 GMT</pubDate>
            <atom:updated>2022-06-01T08:54:12.967Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>The demand for a product varies from time to time and this in part affects the sales. For a business to succeed, it should be able to determine/forecast the future sales of a product and prepare as per the forecast. In this article, we will see how we can predict sales for Rossmann Pharmaceuticals. This case study follows two approaches. The first approach is to consider it as a Machine Learning problem and solve using ML techniques. The second approach will use Deep Learning, specifically LSTMs.</p><h3>Problem Statement</h3><p>The finance team at Rossmann Pharmaceuticals wants to forecast sales in all their stores across several cities six weeks ahead of time. Previously, the managers of each store were responsible for forecasting sales.</p><p>The data team at Rossmann Pharmaceuticals has identified features that could be important in predicting sales and they want an end-to-end ML product that delivers the forecast using the data features they provided.</p><h3>Objective</h3><p>The main objective of this project is to develop a product that could predict sales six weeks in advance given the current data.</p><h3>Data</h3><p>The data used in this project can be downloaded <a href="https://www.kaggle.com/competitions/rossmann-store-sales/data">here</a>.</p><p>Files in the dataset are:</p><ol><li>store.csv</li><li>train.csv</li><li>test.csv</li></ol><p>The data contains sales information for 1115 Stores and a total of 1017209 sales information is provided.</p><p>Here is a description of each of the fields in the data.</p><p><strong>Id</strong> — an Id that represents a (Store, Date) duple within the test set</p><p><strong>Store</strong> — a unique Id for each store</p><p><strong>Sales</strong> — the turnover for any given day (this is what you are predicting)</p><p><strong>Customers</strong> — the number of customers on a given day</p><p><strong>Open</strong> — an indicator for whether the store was open: 0 = closed, 1 = open</p><p><strong>StateHoliday</strong> — indicates a state holiday. Normally all stores, with few exceptions, are closed on state holidays. Note that all schools are closed on public holidays and weekends. a = public holiday, b = Easter holiday, c = Christmas, 0 = None</p><p><strong>SchoolHoliday</strong> — indicates if the (Store, Date) was affected by the closure of public schools</p><p><strong>StoreType</strong> — differentiates between 4 different store models: a, b, c, d</p><p><strong>Assortment</strong> — describes an assortment level: a = basic, b = extra, c = extended. Read more about assortment <a href="https://en.wikipedia.org/wiki/Retail_assortment_strategies">here</a></p><p><strong>CompetitionDistance</strong> — the distance in meters to the nearest competitor store</p><p><strong>CompetitionOpenSince[Month/Year]</strong> — gives the approximate year and month of the time the nearest competitor was opened</p><p><strong>Promo</strong> — indicates whether a store is running a promo on that day</p><p><strong>Promo2</strong> — Promo2 is a continuing and consecutive promotion for some stores: 0 = store is not participating, 1 = store is participating</p><p><strong>Promo2Since[Year/Week] </strong>— describes the year and calendar week when the store started participating in Promo2</p><p><strong>PromoInterval</strong> — describes the consecutive intervals Promo2 is started, naming the months the promotion is started anew. E.g. “Feb, May, Aug, Nov” means each round starts in February, May, August, November of any given year for that store</p><p>As shown in the description of the fields above, some of the features are categorical columns some are numerical.</p><h3>Data Preparation</h3><p>The first step was to check the dataset for missing values. The store.csv data contained some missing values.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/568/1*nvKD_pQRmkKP4KNv1Z0SmQ.png" /><figcaption>Missing values for store.csv</figcaption></figure><p>The fields Promo2SinceWeek, Promo2SinceYear, and PromoInterval have missing values for stores that are not participating in the consecutive promotion. Promo2SinceWeek and Promo2SinceYear are of <strong><em>float</em></strong> type and it makes sense to replace the missing values with 0. This means they will have a 0 value for when the stores were not participating in the promotion. PromoInterval is a categorical variable and it would make sense to replace it with <strong><em>null</em></strong> for the missing values.</p><p>For the remaining fields i.e CompetitionDistance, CompetitionOpenSinceMonth, and CompetitionOpenSinceYear we replace the missing values using the median values of each column.</p><p>The date column was also converted to <strong><em>DateTime </em></strong>so that it is possible to extract more features out of the column.</p><p>The final step in preparing the data was to merge the train.csv file with the store.csv file. The resulting dataframe provides us with complete information about a particular sale of a particular store. The same is done to create a complete test dataset.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/848/1*LggPBuDKNumf9RxLLTrzaA.png" /><figcaption>Merged store.csv with train.csv</figcaption></figure><p>In each of the steps, we version our data using DVC so that we can easily access the specific version of our data at a later time.</p><h3>Exploratory Data Analysis</h3><p>In this section, we take a look at the effect some of the features such as promotions, holidays, etc have on the Sales of a store.</p><h4>Effect of Promotion on Sales</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/393/1*nhOjJ3fM_GHlkJbPEkT2lg.png" /><figcaption>Effect of Promotion on Sales</figcaption></figure><p>We can clearly see that Sales have increased significantly because of Promotion.</p><h4>Effect of Promotion on Customer acquisition</h4><p>Here we want to see if the promotions are attracting customers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/394/1*e47GNZ9_rEuva8UuUcVD0A.png" /><figcaption>Effect of Promotion on Customers</figcaption></figure><p>Again the effect of promotion is seen clearly. There is a significant increase in the number of customers due to promotion.</p><h4>Effect of Promotion on each store type</h4><p>There are four store types in our data. We will see what effect promotion has on each store type.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JrLyGtO7Z5zuWZRbsWIdaQ.png" /><figcaption>Effect of promotion on Customer Acquisition for each store type</figcaption></figure><p>From the above plot, it is evident that store type A has gained a lot more customers as compared to the other store types due to promotion.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qNJ8od6i_NIKt-jVD3BDrw.png" /><figcaption>Effect of promotion on Sales for each store type</figcaption></figure><p>Again store type A’s sales have increased a lot more than the other store types. From the above two plots, we can see that there is a high correlation between sales and customers.</p><h4>Impact of each assortment type on Sales</h4><p>There are three assortment levels implemented in the Stores. We will see which assortment level is better in resulting in a lot of Sales.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/736/1*1TlCf20s3mPCg2-woSZBLA.png" /><figcaption>Sales vs Assortment type</figcaption></figure><p>Stores implementing assortment level B have the highest number of Sales.</p><p>We can conclude that Sales have a high correlation with Customers and promotions result in higher sales by attracting a higher number of Customers.</p><p>We will now proceed to build the model for our product. Since the data is a time-series data we should understand what a time-series data is.</p><h3>What is Time Series Data?</h3><p>Time series data is a sequence of data points indexed in time order. Time-stamped is data collected at different points in time.</p><p>These data points typically consist of successive measurements made from the same source over time and are used to track change over time.</p><p>In our case, the time series data is the sales for each store over two years. We will be using this data to identify if there are trends in the data, seasonality in the data, etc.</p><p>We will be leveraging two approaches. The first approach is to treat this forecasting as a simple ML problem. We’ll use a RandomForestRegressor to determine the sales of a particular store given the input features.</p><p>For our second approach, we will use LSTM, a type of Recurrent Neural Network most commonly used for sequence modeling.</p><h3>What is Long Short-Term Memory Networks (LSTMs)?</h3><p>LSTMs are neural networks that are most commonly used in predicting values by using time-series data. They have a special capability of retaining information encountered in a distant time. They solve the vanishing gradient problem that Recurrent Neural Networks have.</p><p>LSTMs have a feedback connection that enables them to process the entire time-series data at once rather than treating each sequence individually. This allows them to retain useful information from a distant sequence to be used in predicting future sequences.</p><p>A detailed description of LSTMs can be found <a href="https://towardsdatascience.com/lstm-networks-a-detailed-explanation-8fae6aefc7f9">here</a>.</p><h3>Modeling</h3><p>Our first approach is to treat the problem as a Machine Learning problem. We are going to be using RandomForestRegressor to build our model.</p><p>We create a class that implements a scikit pipeline to generate new features from our data. This pipeline uses the date column and generates new features such as day, month, year, isWeekday, isWeekend, day_to_holiday, and day_after_holiday.</p><p>After all the features are generated the next step is to prepare the data for modeling. This is handled using another scikit pipeline which label encodes the categorical columns, scales the numerical columns using Standard Scaler, and splits the data into target and feature split.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*suaQvdwQOh3n2_0rkfzIWw.png" /><figcaption>Preprocessing pipeline</figcaption></figure><p>The output of this pipeline is now ready for modeling and can be used in training the RandomForestRegressor model.</p><p>Initially, we start with the following parameters for our model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/326/1*XZGdlGLFwbNoumGy3DUZnQ.png" /></figure><p>We will use MLFlow to record the result and the hyperparameters for each experiment so that we can fine-tune and get the best hyperparameters that give the best result.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gxsk9cyE-MPHCh_PDwgkNQ.png" /></figure><p>After training, we see which features have higher importance from the overall data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/593/1*2GsQ7QxyjxYh1Dm7kRtmXQ.png" /><figcaption>Feature Importance — RandomForestRegressor</figcaption></figure><p>From the above plot, we can see that Customers, Promo, CompetitionDistance have the highest importance.</p><h3>Summary</h3><p>In this project, we’ve seen how we can predict Sales from the features provided by the data team. In doing so we have achieved the objective of building a model that predicts the Sales with a reasonable margin. The output of this model is used to build a <a href="https://pharma-forecast.herokuapp.com/">dashboard</a> that the managers can use to easily predict the Sales of a particular store.</p><p>The implementation of this project is found in this <a href="https://github.com/teddyk251/pharma_sales_prediction">repo</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=34a98cf16df8" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>