<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Ogunbiyi Ibrahim</title>
    <description>The latest articles on DEV Community by Ogunbiyi Ibrahim (@comejoinfolks).</description>
    <link>https://dev.to/comejoinfolks</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F578312%2F7a750d69-450c-4619-80cf-b4061be9a0cd.jpg</url>
      <title>DEV Community: Ogunbiyi Ibrahim</title>
      <link>https://dev.to/comejoinfolks</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/comejoinfolks"/>
    <language>en</language>
    <item>
      <title>Feature Engineering: The Transformation phase (How to Encode Categorical Features)</title>
      <dc:creator>Ogunbiyi Ibrahim</dc:creator>
      <pubDate>Sun, 15 May 2022 11:12:01 +0000</pubDate>
      <link>https://dev.to/comejoinfolks/feature-engineering-the-transformation-phase-how-to-encode-categorical-features-19od</link>
      <guid>https://dev.to/comejoinfolks/feature-engineering-the-transformation-phase-how-to-encode-categorical-features-19od</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--SFtVxZ4Z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5bpbdm8cg2gq08pcu0n5.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--SFtVxZ4Z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5bpbdm8cg2gq08pcu0n5.jpg" alt="Image description" width="880" height="776"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;When developing a predictive model, one of the most important phases is feature engineering. Its major objective is to help our model understand some of the underlying features in our datasets so that our model can predict on those features. Remember that machine learning models operate best with numerical values because they are based on mathematical equations, therefore feeding the model with values other than numerical values may be daunting for our model. So, through feature engineering, we can assist our model in understanding specific features in our datasets.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;I'll be writing a series of posts in which I'll discuss several types of feature engineering. This is the first post of the series. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;To give you a quick rundown of what I'll be covering in this post. This is a summary of the posts.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What is Feature Engineering?&lt;/li&gt;
&lt;li&gt;The Categories of Feature Engineering&lt;/li&gt;
&lt;li&gt;What is a Categorical Feature?&lt;/li&gt;
&lt;li&gt;What are the type of Categorical Feature&lt;/li&gt;
&lt;li&gt;How do you encode a Categorical feature and what are the use cases that will allow you to use a particular encoding technique.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What is Feature Engineering?
&lt;/h2&gt;

&lt;p&gt;In order for me to clarify what feature engineering entails. I'd like to start with this Wikipedia definition because it gave me an intuition of what Feature Engineering is all about.&lt;/p&gt;

&lt;p&gt;According to Wikipedia, feature engineering is the process of &lt;u&gt;extracting features from raw data using domain knowledge &lt;/u&gt;. The purpose for this is to leverage the extra features to &lt;u&gt; improve the quality of a machine learning process&lt;/u&gt; rather than providing merely raw data to the machine learning process.&lt;/p&gt;

&lt;p&gt;As we all know, for ML models to perform well, the data must be in an appropriate format (mostly numerical values), and in order for us to do that, there must be domain knowledge or expertise that will guide us as to how we want to engineer these features so that after we are finished with the engineering, the new features will still portray what the older ones are all about.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Consider the following scenario: you have a categorical feature that you want to encode in your dataset. As a data scientist, you must have domain knowledge or seek expertise so that when you encode a variable using a specific technique, how will it effect the data and will the encoding technique still convey what the data is all about?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;So my take on feature engineering will be that: In layman's words, feature engineering is the process of selecting, extracting, manipulating, and transforming data using domain expertise so that the resulting features still reflect what the data is all about and are easily understood by the model.&lt;/p&gt;

&lt;p&gt;Feature engineering can be a difficult process to do because it involves expertise knowledge and takes a long time. However, it is critical to concentrate on. When I think of feature engineering, I always think of these two quotes from two of the data space's most famous figures.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Coming with features is difficult, time consuming, requires expert knowledge. Applied Machine learning is basically feature engineering&lt;/strong&gt; — Prof. Andrew NG.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The feature you use influences more than everything else the result. No algorithm alone, to my knowledge, can supplement the information gain given by correct feature engineering&lt;/strong&gt; — Luca Massaron&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Categories of Feature Engineering
&lt;/h2&gt;

&lt;p&gt;Feature Engineering is divided into 4 different categories which include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Feature Transformation.&lt;/li&gt;
&lt;li&gt;Feature Extraction.&lt;/li&gt;
&lt;li&gt;Feature Creation.&lt;/li&gt;
&lt;li&gt;Feature Selection.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;As our topic suggests in this post, we will discuss feature transformation; other categories will be discussed in later series.&lt;/p&gt;

&lt;h3&gt;
  
  
  Feature Transformation
&lt;/h3&gt;

&lt;p&gt;The process of turning raw features into a format suitable for model construction is known as feature transformation. Our model will be able to understand what each feature represents thanks to feature transformation. Feature transformation includes things like numerical transformation and scaling, categorical variable encoding, and so on. We will talk about numerical transformation and scaling in the next series.&lt;/p&gt;

&lt;h2&gt;
  
  
  What are Categorical Variables/Features?
&lt;/h2&gt;

&lt;p&gt;Categorical features represent data that may be classified into groups. Colors, animals, and other things could be represented by them. Examples include race, color, animal, and so on.&lt;/p&gt;

&lt;h2&gt;
  
  
  Type of Categorical Features
&lt;/h2&gt;

&lt;p&gt;Categorical variables can be divided into 3 categories which include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Binary Values:&lt;/strong&gt; They often depict two quantities. They are regarded as either/or values. Examples include yes or no, True or False.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Nominal Values:&lt;/strong&gt; In the real world, this type of category feature does not depict order. When you try to order them, nothing makes sense. Example include (Colors: black, blue, and red), (Animal: cat, dog, fox), etc. We can see that each element represents a separate unit, therefore attempting to organize them makes no sense.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Ordinal Values:&lt;/strong&gt; In the real world, this type of data can be ordered. For example, (cold, hot, very hot), (low, medium, high), grade score(A, B, C) and so on.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  How to Encode Categorical Features
&lt;/h2&gt;

&lt;p&gt;We can encode our category features using a variety of encoding techniques. We'll go through the most common one you'll come across on a daily basis. However, encoding binary and ordinal categorical features is simple and does not need much effort, whereas encoding nominal data can be difficult and sometimes requires domain expertise when working with them. We'll go over how to encode all of these categorical features.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Note: For encoding categorical features I will be using a library in python called &lt;strong&gt;category_encoders&lt;/strong&gt; if you don't have it installed you can use the following below code&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;#For Pip install
&lt;/span&gt;&lt;span class="n"&gt;pip&lt;/span&gt; &lt;span class="n"&gt;install&lt;/span&gt; &lt;span class="n"&gt;category_encoders&lt;/span&gt;

&lt;span class="c1"&gt;#For conda environment 
&lt;/span&gt;&lt;span class="n"&gt;conda&lt;/span&gt; &lt;span class="n"&gt;install&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="n"&gt;conda&lt;/span&gt;&lt;span class="o"&gt;-&lt;/span&gt;&lt;span class="n"&gt;forge&lt;/span&gt; &lt;span class="n"&gt;category_encoders&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Encoding Binary Values
&lt;/h3&gt;

&lt;p&gt;It is not difficult to encode binary categorical variables. Because binary categorical variables like True or False can be related to the value of a logic gate (0's and 1's). We may simply accomplish this with a Python function or method. True values will be treated as 1s, while false values will be treated as 0s. It also works for Yes and No. We can use either of these codes to achieve this.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--fMWcNe5I--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5v7jdyys4iq4isonki1z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--fMWcNe5I--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5v7jdyys4iq4isonki1z.png" alt="Binary variable" width="880" height="300"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;#converting the first feature win1 using the replace method
&lt;/span&gt;&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"win1"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"win1"&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="n"&gt;replace&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;&lt;span class="s"&gt;"N"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"Y"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;})&lt;/span&gt;

&lt;span class="c1"&gt;#converting the second feature win2 using an anonymous function
&lt;/span&gt;&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"win2"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"win2"&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="nb"&gt;apply&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="o"&gt;==&lt;/span&gt;&lt;span class="s"&gt;"T"&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s"&gt;"F"&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Ogff8974--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3ohol2wlkk3zc6gh7w60.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Ogff8974--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3ohol2wlkk3zc6gh7w60.png" alt="Bin Result" width="880" height="243"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Encoding Ordinal Values
&lt;/h3&gt;

&lt;p&gt;Encoding ordinal values is also a pretty task to perform since they those values are ordered i.e. they can be ranked it is easier to get straight with them. Consider the following scenario. You have an ordinal value that ranges from &lt;strong&gt;extremely weak to weak to strong&lt;/strong&gt;. Because extremely weak is the lowest value and strong is the highest, we can encode this value in the logical order of &lt;strong&gt;1, 2, 3&lt;/strong&gt;. 1 represents very weak, 2 represents weak, and 3 represents strong. Now that we've understood that for us to do this in python we type.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ds156bnT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tzeza309rqigwfpx17nc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ds156bnT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tzeza309rqigwfpx17nc.png" alt="Ordinal" width="880" height="237"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;category_encoders&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;OrdinalEncoder&lt;/span&gt;
&lt;span class="n"&gt;transformer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;OrdinalEncoder&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;mapping&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[{&lt;/span&gt;&lt;span class="s"&gt;'col'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s"&gt;'ordinal_data'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
                            &lt;span class="s"&gt;'mapping'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="s"&gt;"strong"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'weak'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;'extremely weak'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;}}])&lt;/span&gt;

&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"ordinal_data"&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;transformer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;fit_transform&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"ordinal_data"&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;You must provide the column that you want to encode in the mapping parameter (i.e. the one with the col key in the code above), otherwise it will encode any categorical feature it sees. Also, the mapping key tells the encoder how to rank the variable, because if you don't supply it, the encoder will choose the first value as 1. For example, in our scenario, if we don't provide the first value, it will be encoded as 1, and the other values will be encoded as they occur.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0aG2Iq8i--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dr1563dr66md06uulfpj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0aG2Iq8i--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dr1563dr66md06uulfpj.png" alt="Ordinal result" width="880" height="233"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Encoding Nominal Data
&lt;/h3&gt;

&lt;p&gt;As I previously stated, encoding nominal values can be tricky because it necessitates knowledge of how to encode them. Some of the most common methods of encoding nominal data are as follows.&lt;/p&gt;

&lt;h4&gt;
  
  
  One-Hot Encoding
&lt;/h4&gt;

&lt;p&gt;Consider a column with three values: black, red, and blue to better comprehend one hot encoding. One-hot encoding will take each categorical value in that column and convert it into a new column, assigning the values 1 and 0 to them. Let's look at an example to better grasp what's going on.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ohMUPv0T--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j6yqdy5avduidu9vzrfd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ohMUPv0T--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j6yqdy5avduidu9vzrfd.png" alt="One Hot" width="880" height="240"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;category_encoders&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;OneHotEncoder&lt;/span&gt;
&lt;span class="n"&gt;transformer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;OneHotEncoder&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cols&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"one_hot_data"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;use_cat_names&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;df&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;transformer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;fit_transform&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--YI7L84vV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/86tkd990j447ekucp9m2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--YI7L84vV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/86tkd990j447ekucp9m2.png" alt="Image " width="880" height="238"&gt;&lt;/a&gt;&lt;br&gt;
As seen in the preceding figure, new columns were constructed from those values, and whenever each value occurs in that row, it will be allocated 1 while the others will be assigned 0. We can see in the previous image that black was the first value that occurred in the row, and in the second image that it was allocated 1 while other values were assigned 0 because only black occurred in the row. Similarly, blue occurred in the second row, therefore in the new image blue was assigned 1 only then black and blue column were assigned 0.&lt;/p&gt;
&lt;h4&gt;
  
  
  Frequency Encoding
&lt;/h4&gt;

&lt;p&gt;It a very simpler technique. What is does is that it counts the number of times a nominal value occurs. Then it then maps the frequency back to the column. Let's go over an example so we understand what's going on.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KEih2z1c--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jnqnml2v69t26akucogu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KEih2z1c--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jnqnml2v69t26akucogu.png" alt="Image description" width="880" height="240"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;category_encoders&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;CountEncoder&lt;/span&gt;
&lt;span class="n"&gt;transformer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;CountEncoder&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cols&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"one_hot_data"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;df&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;transformer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;fit_transform&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--az7yKnmi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/augn0owqpqwrfcshafu8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--az7yKnmi--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/augn0owqpqwrfcshafu8.png" alt="I3" width="880" height="233"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can see that in the previous figure black occurred 2 times and red occurred 3 times. So Frequency encoder assigns the frequency at which those value occur to the column back. This technique is very efficient. You can also add a normalize parameter if you wish to have the relative frequency of each value. Something like this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;category_encoders&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;CountEncoder&lt;/span&gt;
&lt;span class="n"&gt;transformer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;CountEncoder&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;cols&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s"&gt;"one_hot_data"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;normalize&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="n"&gt;df&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;transformer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;fit_transform&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--97FjLjSR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fxhng71yalcclb2o7yn0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--97FjLjSR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fxhng71yalcclb2o7yn0.png" alt="Im" width="880" height="234"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Note: You might be thinking when to use the relative frequency or the Frequency only. Consider for instance you have a column with high cardinality. It will be efficient for you to make use of the relative frequency rather than the normal frequency.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h4&gt;
  
  
  When To Use OneHot Or Frequency Encoding.
&lt;/h4&gt;

&lt;p&gt;If the number of unique nominal values in your column is small, you can use OneHot encoding. However, if they are numerous, i.e. there is a high cardinality, utilize frequency or relative frequency. However, I prefer the relative frequency😀.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion and learning More.
&lt;/h2&gt;

&lt;p&gt;Please keep in mind that there are other encoding techniques available, each with its own set of applications. If you want to learn more about them, I will employ you to investigate more online . However, the encodings listed above are some of the more typical ones you will see on a daily basis. Thank you for taking the time to read this. I'll be releasing my second series soon, which will cover numerical transformation and scaling. Watch out for it 🚀🚀.&lt;/p&gt;

</description>
      <category>python</category>
      <category>machinelearning</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>Intuitive Introduction to Logistic Regression (Understanding the mathematics behind the model)</title>
      <dc:creator>Ogunbiyi Ibrahim</dc:creator>
      <pubDate>Sun, 24 Apr 2022 08:42:50 +0000</pubDate>
      <link>https://dev.to/comejoinfolks/intuitive-introduction-to-logistic-regression-understanding-the-mathematics-behind-the-model-39k3</link>
      <guid>https://dev.to/comejoinfolks/intuitive-introduction-to-logistic-regression-understanding-the-mathematics-behind-the-model-39k3</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyrd5behho6f2e88y02x6.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyrd5behho6f2e88y02x6.jpg" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;I've been working with Logistic Regression to fit my data and make good predictions as a beginner. But as soon as I'm done with that I feel empty and the reason for that was simply because I was performing the same task iteratively (i.e. Just fitting and predicting which could get boring because of not understanding what's going on behind the scene). I've always thought of how is the model able to perform the predictions.&lt;/p&gt;

&lt;p&gt;But then I sat down one day and studied how the Logistic regression can perform its prediction. Funny enough, I was able to have a little knowledge of it, so I will be sharing my knowledge on what's learned so far. Relax and feel free because it's going to be interesting. Heads up! thanks in advance.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Logistic Regression?
&lt;/h2&gt;

&lt;p&gt;I will like to use the definition of Aurelian Geron which he defined in his  &lt;a href="https://www.oreilly.com/library/view/hands-on-machine-learning/9781492032632/" rel="noopener noreferrer"&gt;book&lt;/a&gt; which says:&lt;/p&gt;

&lt;p&gt;Logistic Regression (also called Logit Regression) is commonly used to estimate the probability that an instance belongs to a particular class.&lt;/p&gt;

&lt;p&gt;To better understand the above definition. I love to use this analogy to explain. Consider for instance if a doctor was observing a patient record to know if the patient has a headache or not. Given all those records the doctor can predict that the patient &lt;strong&gt;has a headache&lt;/strong&gt; (this is usually referred to as the positive class and it is labeled 1) or the patient does &lt;strong&gt;not have a headache&lt;/strong&gt; (negative class usually labeled with 0). This is how Logistic Regression works as well. If the estimated probability (i.e. the chance of the headache occurring) is greater than 50% or 0.5 then the model predicts 1 (positive class) or else 0 (the negative class).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flj10asb8lly6hgzal4zx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flj10asb8lly6hgzal4zx.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Please note that Logistic Regression is not based only on predicting discrete values (i.e. 0 and 1 or whether something is this or not) usually referred to as binary classification. You can also use it to predict more than 2 labels. For instance, you wanted to build a model that can predict whether an image is a dog, cat, or wolf. Logistic Regression can also do that. This is referred to as Multinomial Classification.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  How Does Logistic Regression Makes its Prediction?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsoz9ku9gw7wkawo07gsy.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fsoz9ku9gw7wkawo07gsy.jpg" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hmm, now we've gotten to the part where I and most people are curious about. To comprehend how it makes its prediction I will go through the formula step by step. I will be using a binary classification to explain and it will be based on one input variable(or predictor variable) in this article with that we can grasp how it predicts more input variables and also the Multinomial Classification.&lt;/p&gt;

&lt;p&gt;Consider, for instance, we want to predict whether an individual will go bankrupt given his credit card balance.&lt;/p&gt;

&lt;p&gt;In simple mathematical terms, this is how Logistic Regression does its prediction.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;br&gt;
Pr(individual=bankruptcy|balance)&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
The above expression can be interpreted as the probability of an individual going into bankruptcy given his balance. The pipe symbol | is used to denote given.&lt;/p&gt;

&lt;p&gt;However, that doesn't stop there. The above expression is just a way of how a lazy statistician will explain the formula of Logistic Regression.&lt;/p&gt;

&lt;p&gt;Going deep the above expression miraculously transforms into this&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F31a23mee165gx2ufdjc4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F31a23mee165gx2ufdjc4.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now you might be thinking what the heck is this. Let's unpack what we have above.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxng6w4nhm1sic1cpzqw4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxng6w4nhm1sic1cpzqw4.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
To better understand the above equation let's look at another equation that we might be familiar with.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm29t0zbe2abq1gpx3kq8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm29t0zbe2abq1gpx3kq8.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The above equation is the most popular linear regression formula. More conventionally it is written as&lt;/p&gt;

&lt;p&gt;Looking at the above equation we can see that it looks somewhat like the logistic regression if not all. Linear regression is used to find the best fit line that can be used to predict the value of y. Check the image below.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fppszg5dyy1i52c19aq8z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fppszg5dyy1i52c19aq8z.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's say we want to predict the value of y where the value of x (input variable) is 5&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fprj16lbiz0gcrp1yg8q5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fprj16lbiz0gcrp1yg8q5.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now we might be curious about the two parameters. &lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyhwr1f9cxcleaiy1pt5o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyhwr1f9cxcleaiy1pt5o.png" alt="Image description"&gt;&lt;/a&gt; These two parameters are needed for our model to pick the best fit line (i.e. they are needed for us to accurately predict the values of y). However, to get the values for these parameters there are mathematical approaches that can help us solve those values such as normal equation formula, gradient boosting, SVD, etc. But since our main focus is not on linear regression. We will head back to how we can calculate the parameters as well for Logistic Regression.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Note that the formula is used for predicting whether an individual will go bankrupt given his balance. On the other hand, if we want to calculate whether an individual will not go bankrupt given his credit card balance we can easily do that using the beautiful law of probability. The formula is stated later in the article.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;To calculate the parameters in a Logistic function we use a technique called the maximum like hood estimation. Now before I go into the mathematical details of this technique. I will like to point out some terms in computer science called abstraction and leap of faith. This means that you don't necessarily need to go deep down into details of how things work (I.e. if you don't know how things work for now it's okay as you advance in your learning you will surely know). Thank to those mathematicians and statisticians that came up with this formula. So therefore I won't be talking about how the parameters are being calculated using maximum likely hood. However, if you wish to know more about it you can check out this &lt;a href="http://math.arizona.edu/~jwatkins/o-mle.pdf" rel="noopener noreferrer"&gt;link&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Another way of using Logistic regression is in terms of the log odds ratio. Before we do that let's define the odds&lt;/p&gt;

&lt;p&gt;Odds can be defined as the probability that an event will occur divided by the probability that an event will not occur.&lt;/p&gt;

&lt;p&gt;From the logistic function. The probability that an individual will go bankrupt is &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F31a23mee165gx2ufdjc4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F31a23mee165gx2ufdjc4.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The probability that the individual will not go bankrupt is:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbzy3io89iosre68v0fni.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbzy3io89iosre68v0fni.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now for us to find the odds, we divide the probability of the individual going bankrupt by the probability of not going bankrupt&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6n2t89pl7pl08by7jv2w.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6n2t89pl7pl08by7jv2w.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When you perform the cross multiplication your result should be this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqzyxge1yj2y5v9w9i8ln.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqzyxge1yj2y5v9w9i8ln.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now when we take the natural log of both sides we have:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5v1d9dy673cbpu6ftjph.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5v1d9dy673cbpu6ftjph.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Remember that the natural log of e^a = a&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;We can see that the Logistic regression formula now looks like that of linear regression. That means we can arrive at logistic regression in two ways.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;By finding the probability estimate of the logistic function based on x&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F31a23mee165gx2ufdjc4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F31a23mee165gx2ufdjc4.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;By finding the log odds of the linear function based on x&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5v1d9dy673cbpu6ftjph.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5v1d9dy673cbpu6ftjph.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now that we've understood that let's look at the reason why we can predict classification problems using linear regression.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Linear Regression Won't work
&lt;/h2&gt;

&lt;p&gt;The reason why Linear regression won't work simply is that looking at the below image we can be sure that using linear regression the model can predict values that are less than 0 i.e. we can have negative values and also the model can predict values greater than 1, imagine our model predicts values such as 5. This is not efficient enough. The goal of classification is to have values between 0 and 1.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fppszg5dyy1i52c19aq8z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fppszg5dyy1i52c19aq8z.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
       &lt;em&gt;(c)Author:Saishruthi Swaminathan Linear Regression&lt;/em&gt;&lt;br&gt;
The logistic function solves this problem. The numerator part of it ensures that the values are greater than 0 or equal to 0 and also the denominator ensures that the values are less than or equal to 1.  With this, the Logistic regression graphs form an S shape curve, unlike the Linear regression which is just a straight line.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcje9efy6ttik0e1g7b38.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcje9efy6ttik0e1g7b38.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
              &lt;em&gt;(c) Author: z_ai towardsdatascience&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Thank you for taking your time to read this article Logistic regression is one of the popular estimators used to predict classification problems. This article is just a beginner guide on how it makes its prediction. You can check books and blog posts if you wish to know more about the mathematical concept behind them. Thank you.&lt;/p&gt;

</description>
      <category>datascience</category>
      <category>machinelearning</category>
      <category>beginners</category>
      <category>python</category>
    </item>
    <item>
      <title>4 Core things to always do when cleaning your data for predictive models.</title>
      <dc:creator>Ogunbiyi Ibrahim</dc:creator>
      <pubDate>Mon, 28 Mar 2022 13:08:46 +0000</pubDate>
      <link>https://dev.to/comejoinfolks/4-core-things-to-always-do-when-cleaning-your-data-for-predictive-models-5g0k</link>
      <guid>https://dev.to/comejoinfolks/4-core-things-to-always-do-when-cleaning-your-data-for-predictive-models-5g0k</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--V6sJA4pB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tkmpehzq22biwj85gnzx.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--V6sJA4pB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tkmpehzq22biwj85gnzx.jpg" alt="Image description" width="880" height="586"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;It's always vital to know what to do while cleaning data so that you can get correct insights from it. Data that isn't accurately cleansed for analysis can produce false results, as well as prevent your model from generalizing properly when tested with new data.&lt;/p&gt;

&lt;p&gt;In this article, we'll go through the four things you should do every time you clean data so it's ready for analysis and predictions. &lt;/p&gt;

&lt;p&gt;Let's get this party started.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisite
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Make sure you have your environment set up (i.e. you must have a jupyter notebook)&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Have pandas library installed on your notebook.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Have Seaborn library installed on your notebook.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Have Numpy library installed on your notebook.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What is Data Cleansing?
&lt;/h2&gt;

&lt;p&gt;The process of finding and fixing inaccurate data from a dataset or data source is known as data cleaning. In simple terms, it refers to the process of preparing your data for exploratory data analysis (EDA).&lt;/p&gt;

&lt;p&gt;Now that we've understood what data cleaning entails, we can begin working on the four items necessary to prepare the data for EDA.&lt;/p&gt;

&lt;p&gt;So, due to proprietary issues, I won't be able to disclose the datasets that we'll be utilizing in this article, but I'll provide screenshots so we can see what's going on.&lt;/p&gt;

&lt;p&gt;These are the four things to do when you want to clean your data for analysis and predictions.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Note: make sure you have imported these two libraries into your environment.&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;pandas&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;seaborn&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;sns&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;numpy&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;np&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  1. Dealing with missing values
&lt;/h2&gt;

&lt;p&gt;The first thing as a data scientist/analyst is to always check the info of your data for missing values. To do this type the following code&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;df&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;pd&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;read_csv&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;file_path&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;#Input the filepath
&lt;/span&gt;
&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;info&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the case of my file, this is my screenshot.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_51xR0Ic--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y80qf2sw3xiqk5zi7v8p.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_51xR0Ic--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y80qf2sw3xiqk5zi7v8p.PNG" alt="File Path" width="880" height="440"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can see from the above image (the annotation part) that we have 8606 entries. Now looking at the columns/features in the dataframe we can see obviously that we have missing values. The next thing for us is to deal with those missing values. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Now this is where the question comes&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  How can we deal with missing values?
&lt;/h3&gt;

&lt;p&gt;When it comes to data that isn't Time-Series (I will talk about that in another article). There are two ways to go about it.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Dropping the values.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Imputation.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Dropping values
&lt;/h3&gt;

&lt;p&gt;The only time you should drop values in a dataframe is if more than 60% of the observations are missing. So, if you review the dataframe and discover that 60% of the data is missing, it may be wise to drop the column with that missing value if you think it is unnecessary. If you want to drop those observations you can type&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Another thing to consider is if you're building a model to predict something and you discover that the target column (i.e. this is the column you want to forecast) has missing values. You must remove all missing values from the target column, which will have an impact on other columns as well.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;So in our case now our target column("price_usd_per_m2") has missing values so we have to drop those values. To do that we have to type:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dropna&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;subset&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"price_usd_per_m2"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;inplace&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now let's check the info of our data frame.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;info&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Pml1K3Do--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/syuiic62vxhbevgr6zma.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Pml1K3Do--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/syuiic62vxhbevgr6zma.PNG" alt="Price USD" width="880" height="438"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We can now observe that our dataframe has shrunk from 8606 to 4895 entries. However, as you can see, there are still some missing values. Now let's have a look at the two criteria for dealing with missing data. We can see that the first criteria, &lt;strong&gt;Dropping values&lt;/strong&gt;, applies to some of our columns which are &lt;strong&gt;floor and expenses&lt;/strong&gt; the best thing to do is to drop those columns away(though it is not advisable to drop the floor column, bit for the case article we'll have to drop it).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;drop&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;columns&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"floor"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"expenses"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;inplace&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--WuQ25TTW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/awpp0oebws09eotkdtm5.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--WuQ25TTW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/awpp0oebws09eotkdtm5.PNG" alt="Floor" width="880" height="390"&gt;&lt;/a&gt;&lt;br&gt;
We can see that we still have some missing values, but they are not up to 60% so we move to the other types of dealing with missing values.&lt;/p&gt;
&lt;h3&gt;
  
  
  Imputation
&lt;/h3&gt;

&lt;p&gt;When it comes to the imputation of missing data, the most common method is to use the mean value of all the total values in the column. However, there are several guidelines for when you should not use  &lt;strong&gt;mean&lt;/strong&gt; which I will outline below. They are as follows:&lt;br&gt;
-If your column contains values with different variances, such as positive and negative numbers, you should not utilize mean.&lt;br&gt;
-If your column contains just binary values of 1s and 0s, you should avoid using the mean approach.&lt;/p&gt;

&lt;p&gt;If your columns as the following features it is advisable to drop those observations.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Note don't confuse observation with a column. Observation means row so if you want to drop rows you make use of the following code&lt;br&gt;
&lt;/p&gt;


&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;dropna&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;subset&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;""&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;inplace&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;As previously stated, this approach does not work with time-series data. It has a different approach to dealing with missing values, which I'll cover in a later article.&lt;/p&gt;

&lt;p&gt;Also note it is always advisable to fill a column that has numeric missing values such as float and integer. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Now back to our dataset since our dataset does not have the above criteria I'm going to use the mean approach and I have only 1 numeric column(which is room) that has missing values. So I'm going to fill it with the mean value of the total values. To do that type the below code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;fillna&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;np&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;mean&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"rooms"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;inplace&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lh1Tn5zG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/us0yudmlq9vv5rbt3tf9.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lh1Tn5zG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/us0yudmlq9vv5rbt3tf9.PNG" alt="Missing Value" width="880" height="438"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now that we don't have numerical columns that have missing values we are good to go.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Checking for Multicollinearity
&lt;/h2&gt;

&lt;p&gt;Multicollinearity is a statistical concept in which independent variables in a feature matrix (which includes all variables in the dataframe except the target variable) are correlated. Now that we've understood what multicollinearity is. Let's check it out &lt;/p&gt;

&lt;p&gt;Back to our dataframe since &lt;strong&gt;price_aprox_usd&lt;/strong&gt; is our target value we are going to copy drop it (what this means is I'm going to pass in the drop attribute without using &lt;code&gt;inplace&lt;/code&gt; parameter) so it will return a copy of it. So to see the multicollinearity type this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;drop&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;columns&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"price_aprox_usd"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;corr&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Notice that I didn't pass in inplace so it returns a copy of the data frame without &lt;strong&gt;price_usd_per_m2&lt;/strong&gt; and also notice the &lt;code&gt;.corr()&lt;/code&gt; attribute it is used to find the correlation. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;After you run the above you should have something like this.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6XAYLP9s--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vuld9fctfohebffke4g0.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6XAYLP9s--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vuld9fctfohebffke4g0.PNG" alt="Price_aprox_usd" width="880" height="440"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now that we've seen the correlation numerically it will be nice to visualize so we can know what's going on. So we will be using seaborn. Just save the above code into a variable &lt;code&gt;vis_corr&lt;/code&gt;. Check below to see what I mean.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;vis_corr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;drop&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;columns&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"price_aprox_usd"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;corr&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now to visualize it we will use seaborn just type the following code to see the visualization.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;sns&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;heatmap&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;vis_corr&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--oafbRU3H--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zht805z26p2z2osou58m.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--oafbRU3H--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zht805z26p2z2osou58m.PNG" alt="Seaborn" width="880" height="441"&gt;&lt;/a&gt;&lt;br&gt;
So let's unpack what's going on here. The diagram above shows the level of correlation among different features in the dataframe.  However, if we have features in which their correlation value is greater than 0.5 it means those features are highly correlated with one another.&lt;/p&gt;

&lt;p&gt;Now that we've understood that we can see that price, price_aprox_local_currency are correlated with one another. Also surface_total_in_m2 and surface_covered_in_m2 are also very correlated.  So we have to drop one of those features.&lt;/p&gt;

&lt;p&gt;The issue now is "how do we know which feature to drop now that we've noticed the concerns with multicollinearity in our dataframe?"&lt;/p&gt;

&lt;p&gt;To figure out which feature to eliminate, we'll need to look at the association between each of these features and our target variable. After we've done that then the feature with the highest correlation value will be the one to be dropped. Please see the code below to understand what I'm saying, and I'll also include the correlation value for each variable as a comment.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"price"&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="n"&gt;corr&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"price_aprox_usd"&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="c1"&gt;#corr_value = 0.68
&lt;/span&gt;
&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"price_aprox_local_currency"&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="n"&gt;corr&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"price_aprox_usd"&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="c1"&gt;#corr_value = 1.0
&lt;/span&gt;
&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"surface_covered_in_m2"&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="n"&gt;corr&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"price_aprox_usd"&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="c1"&gt;#corr_value = 0.13
&lt;/span&gt;
&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"surface_total_in_m2"&lt;/span&gt;&lt;span class="p"&gt;].&lt;/span&gt;&lt;span class="n"&gt;corr&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"price_aprox_usd"&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="c1"&gt;#corr_value=0.21
&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Okay now that we've seen the correlation values of all the features so the features that have to be dropped are &lt;code&gt;price_aprox_local_currency&lt;/code&gt; and  &lt;code&gt;surface_covered_in_m2&lt;/code&gt;.&lt;br&gt;
I will be dropping &lt;code&gt;surface_covered_in_m2&lt;/code&gt; rather than &lt;code&gt;surface_total_in_m2&lt;/code&gt;. I feel like the adjective "total" makes it have more information well. &lt;br&gt;
So to speak there might be sometimes in which you have to go for the one which has the lowest value. But based on my preference I choose to drop &lt;code&gt;surface_covered_in_m2&lt;/code&gt;&lt;br&gt;
So to do that we have to type&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;drop&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;columns&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"price_aprox_local_currency"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"surface_covered_in_m2"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;inplace&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Okay so having done that we are good to go. Let us look at another core thing we need to look at.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Dealing with leaky features
&lt;/h3&gt;

&lt;p&gt;To understand what leaky features are. Consider the following scenario: you were scheduled to take an exam for which you had not prepared, but you were fortunate enough to see the answers to the exam questions before entering the room. How will you perform as opposed to you didn't see the answers at all?  You will pass all the exams right!. That is what leaky features are also. They're features that fool the model into thinking it's some kind of geek who can predict anything unusual, while, when it comes to predicting data that hasn't been seen before, the model will completely fail.&lt;/p&gt;

&lt;p&gt;So back to our dataframe let's check maybe we have any leaky features in our data frame.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;info&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--9uaaQLOj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lh2tw9gzhq99r1koqd99.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--9uaaQLOj--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lh2tw9gzhq99r1koqd99.PNG" alt="Leaky features" width="880" height="443"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So in our dataframe we can see that we have leaky features in it. Our leaky features are the &lt;code&gt;price&lt;/code&gt;, &lt;code&gt;price_usd_per_m2&lt;/code&gt;, &lt;code&gt;price_per_m2&lt;/code&gt;. We can see that these features are cheats to our dataframe considering that we want to build a model that can predict house prices. It will be very stupid to have prices columns again in our dataframe. These columns are cheats to our target variable which is &lt;code&gt;price_aprox_usd&lt;/code&gt;. We have to drop them from our dataframe.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;drop&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;columns&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"price_usd_per_m2"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"price_per_m2"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;inplace&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now that we are done we are good to go. So let's look at the last core thing we need to focus on when building a predictive model.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Dropping high and low cardinality categorical variables.
&lt;/h3&gt;

&lt;p&gt;A cardinality categorical variable (e,g places, names, emails, etc.) is said to be low or high when it has few or many unique numbers of value.&lt;/p&gt;

&lt;p&gt;So for us to be able to check the cardinality of our categorical variable which are most types of &lt;code&gt;object datatype&lt;/code&gt;. We will use the following code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;select_dtypes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"O"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="n"&gt;nunique&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After running the code we can see that we have 1 low and high cardinality variable which are &lt;code&gt;operation&lt;/code&gt; and &lt;code&gt;properati_url&lt;/code&gt;. So we have to drop them. The essence of dropping the cardinality variable is that it will cause insanity in our model which we don't want.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;df&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;drop&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;columns&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s"&gt;"operation"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s"&gt;"properati_url"&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt; &lt;span class="n"&gt;inplace&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hIp5eb6q--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y1ivjiognntlzo0shhyb.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hIp5eb6q--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y1ivjiognntlzo0shhyb.PNG" alt="Cardinality" width="880" height="438"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;So we have gotten to the end of our journey, there are still other core things to look at when cleaning the data like dealing with outliers and other kinds of stuff. Thank you for reading. I'm open to suggestions, feedback, and where I need to improve on the article. You can follow me for more articles.Thanks&lt;/p&gt;

</description>
      <category>datascience</category>
      <category>python</category>
      <category>programming</category>
      <category>beginners</category>
    </item>
    <item>
      <title>How to Control your Home Device (DVD) Via tuya Link SDK and ESP 32</title>
      <dc:creator>Ogunbiyi Ibrahim</dc:creator>
      <pubDate>Fri, 24 Dec 2021 23:59:31 +0000</pubDate>
      <link>https://dev.to/comejoinfolks/controlling-home-device-dvd-via-tuya-link-sdk-and-esp-32-1hfa</link>
      <guid>https://dev.to/comejoinfolks/controlling-home-device-dvd-via-tuya-link-sdk-and-esp-32-1hfa</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Controlling your home devices via the cloud can be so cool and not stressful. With you just picking up your phone and controlling your home device is something you should know much about. In this tutorial, we are going to learn how to control your DVD/ Home theater(Works the same way) via Tuya link SDK and ESP 32.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What we will be building&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In this tutorial, we will learn how to control our DVD/ Home theater via Tuya link SDK and ESP32.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Hardware component&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; ESP32&lt;/li&gt;
&lt;li&gt;Infrared  led transmitter&lt;/li&gt;
&lt;li&gt;Transistor Bc457&lt;/li&gt;
&lt;li&gt;Ac/dc  5v power supply&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Software Component&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Tuya IoT platform&lt;/li&gt;
&lt;li&gt;Tuya smart App&lt;/li&gt;
&lt;li&gt;Arduino IDE&lt;/li&gt;
&lt;li&gt;Command Prompt&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;GitHub Link: &lt;a href="https://github.com/Folksconnect123/DVD-CONTROL" rel="noopener noreferrer"&gt;https://github.com/Folksconnect123/DVD-CONTROL&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is Tuya&lt;/strong&gt;&lt;br&gt;
Tuya Smart (NYSE: TUYA) is a global IoT development platform that creates interconnectivity standards to connect brands, OEMs, developers, and retailers across a variety of smart devices and industries. Tuya integrates many intelligent scenarios and smart devices by providing hardware development tools, integrating public cloud services, and giving an intelligent business development platform, all of which are based on the global public cloud.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftspxmmxoka5mz72xzwsf.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftspxmmxoka5mz72xzwsf.jpg" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is Tuya link Sdk?&lt;/strong&gt;&lt;br&gt;
Tuya link SDK makes life a lot easier. It facilitates the creation of cloud development projects involving OpenAPI or message subscription capabilities.&lt;/p&gt;

&lt;p&gt;Tuya Link SDK is one such SDK that encapsulates fundamental services like device activation, DP (Data-Points) upstream and downstream, and firmware OTA (Over-The-Air) upgrading into an interface. It is appropriate for connecting the logic services of a self-developed gadget to the cloud by developers.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwr0okxz0f0vr5lm7i0wi.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwr0okxz0f0vr5lm7i0wi.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is ESP32?&lt;/strong&gt;&lt;br&gt;
The ESP32 is a low-cost Wi-Fi microchip by Espressif Systems that has built-in TCP/IP networking software and a microprocessor/ Microcontroller capability.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Setting up the environment&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Before we get started let me give you a heads up that if you haven’t created a tuya account before do create because you will be given a free device license to create a hands-on project.&lt;/p&gt;

&lt;p&gt;To use Tuya Link SDK, we will need to make a product to interact and connect to Tuya IoT Cloud. Go to your Tuya IoT account and log in, if you haven't registered for an account register one &lt;strong&gt;&lt;a href="http://iot.tuya.com/?_source=3bb57e086a1738fc4d1ecf7a7f79188e" rel="noopener noreferrer"&gt;click here&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1:&lt;/strong&gt; Create a product by clicking on Create button on the home page&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8yrfpml40p0035vuubg5.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8yrfpml40p0035vuubg5.PNG" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2:&lt;/strong&gt; A page will appear where you will need to select a category for your project or product, since we are using Esp32 as a custom device so we will need to click on “Can’t find the category” and enter the details as shown below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmxb337zd5r5v1ip8bv5b.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmxb337zd5r5v1ip8bv5b.PNG" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3:&lt;/strong&gt; We need a standard function for the power state of the DVD (On/Off) and a custom function to be able to control the DVD like (open and close, Skip, Play, etc.). To create a standard function to either switch the DVD on/ off. Click on add and search for Switch then click Ok. Now you have to edit the name of the Switch for more clarity. You can rename it to DVD power _state. If done click on add again and search for Switch 2, then click ok. Also, rename it to Open/close. We also need to create a standard function for Play/pause. Click on add again. And search for switch then rename to Play/Pause. We need to create a custom function for skip (Note that we can also create a standard function for Skip.). On the custom function tab click on add, then set the Data-point to (SkipFor), the identifier to (skipfor) Datatype to (Bool), Data transfer type (Send only). Do the rest for the other function To know more about creating custom functions click on this &lt;strong&gt;&lt;a href="http://iot.tuya.com/?_source=3bb57e086a1738fc4d1ecf7a7f79188e" rel="noopener noreferrer"&gt;link&lt;/a&gt;&lt;/strong&gt;. Keep note of the PID we will need it later.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frx8tg5nv1jzgjr0ycca9.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Frx8tg5nv1jzgjr0ycca9.PNG" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4:&lt;/strong&gt; To interact with the device we need to have a beautiful Panel with all required functionalities, although you can drag and drop UI design in the Tuya design panel since we are working on a prototype and debugging I like to have things very quick I would click on the tuya DIY Style Panel. You can change it to your preference as soon as you are done.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 5:&lt;/strong&gt; Go to the Hardware Development Section of your product and click on Link SDK. You will need a license to be able to use link SDK, but don’t bother Tuya issues free licenses for new tech hobbyists.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgkx7uut0zfbhbh4y8uyi.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgkx7uut0zfbhbh4y8uyi.PNG" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For ESP32 we are going to use General CPU as a hardware type, also you would see an option to generate a free license if you are new to the platform. Click place the order and download the License list. The** license is composed of tuya UUID and AuthKey** which is needed to authorize the device to receive and send data to the Tuya Cloud.&lt;/p&gt;

&lt;p&gt;Now we are done with the major part of the software development for our Tuya IoT platform now we move to the setting up of the hardware and the implementation of our code.&lt;/p&gt;

&lt;h2&gt;
  
  
  Installing Tuya Link SDK
&lt;/h2&gt;

&lt;p&gt;Now is time to install Tuya link SDK to be able to connect our just completed application above with ESP32. To do that we have to type this code on our command prompt in order to clone the GitHub repository and install tuya link SDK. &lt;/p&gt;

&lt;p&gt;Note: make sure you have Git installed on your pc. If you don’t you can download and install the application.&lt;/p&gt;

&lt;p&gt;The first step is to type this code on the command prompt.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

git clone https://github.com/tuya/tuyaos-link-sdk-python.git


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

&lt;/div&gt;

&lt;p&gt;The second step is to install the tuya link SDK. Note you have to have wheel installed on your machine if you don’t have one. Install it using this line of code. If done, you can finally type the below code.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

pip install wheel 


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

&lt;/div&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

python -m pip install ./tuyaos-link-sdk-python


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

&lt;/div&gt;

&lt;p&gt;Now we are done with the installation of the Tuya link SDK you should have this pop-up on your screen if due procedures are followed.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjc50eb6mdj896vob0nc1.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjc50eb6mdj896vob0nc1.PNG" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Hardware setup:
&lt;/h2&gt;

&lt;p&gt;Grab your ESP32 and other required hardware projects we are ready to get our hands dirty.&lt;/p&gt;

&lt;p&gt;Make sure the required hardware items are complete. Follow the schematics of the hardware and make sure everything is connected properly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;For receiving the address use this schematic&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You connect the Signal/Data pin of the infrared to D15 on the ESP. The anode of the reciever to 5v and the cathode to the ground.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy8t8ysgsfdtz8d161wac.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy8t8ysgsfdtz8d161wac.PNG" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;&lt;em&gt;For sending the Address to the DVD use this schematic&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You connect the base pin of the transistor to pin D4 on the ESP 32. The Collector pin of the transistor to ground. Then the Emitter to the cathode of the LED.Then the Anode of the led must be connected with 220 ohms resistor to Vin.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4ccmia6vrmo8xqnff8g2.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4ccmia6vrmo8xqnff8g2.PNG" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Implementing your Program
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Getting the address from the remote.
&lt;/h3&gt;

&lt;p&gt;Now that we have gotten to this level, the next step to be done is to implement the code. Download the  IRremote_decode file from the Git hub account.&lt;/p&gt;

&lt;p&gt;Now run the IRremote_decode file and open the Serial monitor to get the address from your Remote after that you can now modify the DVD_control file to input the address.&lt;/p&gt;

&lt;p&gt;This is the hardware schematics for the remote decoder address.&lt;/p&gt;

&lt;p&gt;For ESP32 connect the Signal pin of the IR receiver to 15 and the Positive pin to 5v, the last pin to the ground.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5c9lflxugwyabhyihdhb.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5c9lflxugwyabhyihdhb.PNG" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is the address from my remote controller. Then I have inserted the address into the DVD code.&lt;/p&gt;

&lt;p&gt;Modifying the DVD_Control file&lt;/p&gt;

&lt;p&gt;After you’ve gotten the address you can now modify the DVD_control file from GitHub to your own address like this.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzfvxoh5rbcqrcavme3xt.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzfvxoh5rbcqrcavme3xt.PNG" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can run the file and test the code via the serial monitor with your DVD on to see if everything is going perfectly.&lt;/p&gt;

&lt;h2&gt;
  
  
  Finalizing our work
&lt;/h2&gt;

&lt;p&gt;After you’ve successfully uploaded and run the above code it is time to control our microcontroller via the cloud. Now Download the TuyaLinkSDk file from GitHub and modify the code for your PID, Auth key and UUID, and the COM port of your microcontroller. After those are done then you can now run the code on your command prompt by using the cd method. Like in my own case I copied the file to the desktop, then I typed this on my command prompt&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
 desktop

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

&lt;/div&gt;

&lt;p&gt;Then you type the name of the file. In my own case TuyaLinkSDK.py&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy4hc5jpdodqdp6n2g6y0.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fy4hc5jpdodqdp6n2g6y0.PNG" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You should have this after you’ve successfully run the code. Now you can download the Tuya smart app from Playstore and click on add new device, then scan the code to add the device.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8i1m5r3r6hu2zuu9b6pr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8i1m5r3r6hu2zuu9b6pr.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftlh512oes06qgk1c6roh.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftlh512oes06qgk1c6roh.jpg" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here is the video to the output. &lt;a href="https://youtu.be/VcfcegE9fgk" rel="noopener noreferrer"&gt;https://youtu.be/VcfcegE9fgk&lt;/a&gt;. Thank you for reading.&lt;/p&gt;

</description>
      <category>iot</category>
      <category>cloud</category>
      <category>arduino</category>
      <category>tuya</category>
    </item>
    <item>
      <title>Creating an Image Sketch with OpenCV (10 Lines of Code).</title>
      <dc:creator>Ogunbiyi Ibrahim</dc:creator>
      <pubDate>Wed, 10 Nov 2021 13:42:10 +0000</pubDate>
      <link>https://dev.to/comejoinfolks/creating-an-image-sketch-with-opencv-10-lines-of-code-ed9</link>
      <guid>https://dev.to/comejoinfolks/creating-an-image-sketch-with-opencv-10-lines-of-code-ed9</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Have you ever considered utilizing a computer language to create a rough sketch of an image?&lt;br&gt;
I'll show you how to make a sketch of an image without having any programming skills in this article. Hold on to your seat and take out your pen, because this is going to be enlightening and comprehensive.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Note: To follow along with this guide, you simply need a basic understanding of how computers function. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If you are curious about trying this out, here is the 10 lines of code below 👇&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;    &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;cv2&lt;/span&gt;
    &lt;span class="n"&gt;path&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sa"&gt;r&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;C:\Users\folksconnect\Pictures\2020-07&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
    &lt;span class="n"&gt;image_path&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;cv2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;imread&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;grey_image&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;cv2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;cvtColor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;image_path&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="n"&gt;cv2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;COLOR_BGR2GRAY&lt;/span&gt;
    &lt;span class="n"&gt;cv2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;imshow&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Image&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;grey_image&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;invert&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;cv2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;bitwise_not&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;grey_img&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;blur&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;cv2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;GaussianBlur&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;invert&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;cv2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;BORDER_DEFAULT&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;invertedblur&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;cv2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;bitwise_not&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;blur&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;sketch&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;cv2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;divide&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;grey_img&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;invertedblur&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;scale&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mf"&gt;256.0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;cv2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;imwrite&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;sketch.png&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sketch&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But if you are not in a hurry, this article explains everything you need to know about creating an Image Sketch with OpenCV.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is OpenCV?
&lt;/h3&gt;

&lt;p&gt;OpenCV is a big open-source library for computer vision, machine learning, and image processing that is presently playing an important role in real-time operations, which are vital in today's systems. It can recognize objects, people, and even human handwriting in photographs and videos.&lt;br&gt;
To summarize, we will utilize OpenCV to process a photo, i.e. to build an image sketch, in this guide. &lt;/p&gt;
&lt;h3&gt;
  
  
  What is Python?
&lt;/h3&gt;

&lt;p&gt;Python is a programming language that is widely used to construct websites and apps, automate tasks, and analyze data. Python is a general-purpose programming language, which means it can be used to create a large variety of applications and is not specialized for any specific problem. &lt;/p&gt;

&lt;p&gt;To be able to use OpenCV for image processing we have to import it in Python programming language, but before we start coding, let’s set up our environment so we can work efficiently.&lt;/p&gt;
&lt;h3&gt;
  
  
  Setting up your Python Environment
&lt;/h3&gt;

&lt;p&gt;The first thing to do is to make sure you have a Python interpreter on your computer(PC), else here is a link to install Python on your &lt;a href="https://www.edureka.co/blog/install-python-on-windows/" rel="noopener noreferrer"&gt;Windows PC&lt;/a&gt; and &lt;a href="https://www.dummies.com/programming/python/how-to-install-python-on-a-mac/" rel="noopener noreferrer"&gt;MacOS&lt;/a&gt;.&lt;/p&gt;
&lt;h4&gt;
  
  
  Setting up the OpenCV Environment
&lt;/h4&gt;

&lt;p&gt;The next step is to install the &lt;code&gt;OpenCV&lt;/code&gt; library on your PC after you've successfully installed python on your computer. &lt;/p&gt;

&lt;p&gt;To install OpenCV launch command prompt on your computer and run this command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;    pip &lt;span class="nb"&gt;install &lt;/span&gt;opencv-python
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Please make sure you have an internet connection whilst typing this command, as it will be downloaded from the internet. Once that has been downloaded successfully, you can now launch the Python idle installed on your PC. Just type &lt;strong&gt;python idle&lt;/strong&gt; on the search bar of your computer (PC).&lt;/p&gt;

&lt;h2&gt;
  
  
  Implementing our Code
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;Note: Any text (variable) at the left hand-side before the assignment symbol ( = ) is used to store information, the statement(code) at the right hand-side is stored into the left hand side.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The first step after running our idle is to create a new Python script file. This can be done by typing the &lt;code&gt;Ctrl + N&lt;/code&gt; shortcut and this will create a new file.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The second step is to write the statement
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;    &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;cv2&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This line of code import the &lt;code&gt;OpenCV&lt;/code&gt; library into your Python code, so that you can gain functionalities of all the actions performed by it.&lt;/p&gt;

&lt;p&gt;The next step is to assign the path of the image to the variable path and adding &lt;code&gt;r&lt;/code&gt; at the front of the string(path). Here is an example below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;    &lt;span class="n"&gt;path&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sa"&gt;r&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;C:\Users\folksconnect\Pictures\2020-07&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;The next statement to type is:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;    &lt;span class="n"&gt;image_path&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;cv2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;imread&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What the above line of code does is; it reads the path of the image you entered and stores it in the variable &lt;code&gt;image_path&lt;/code&gt;. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Note if the path or image cannot be read (maybe it does not exist or there is an error in the path) this method returns an empty matrix.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;The next line of statement to type is:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;    &lt;span class="n"&gt;grey_image&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;cv2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;cvtColor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;image_path&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="n"&gt;cv2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;COLOR_BGR2GRAY&lt;/span&gt; &lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This line converts the color of the image you stored into image_path into a grey color image.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;To show this image you can type the code:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;    &lt;span class="n"&gt;cv2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;imshow&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Image&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;grey_image&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This code shows the image in a dialog box with the name of the dialog box as image.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Now moving on to the next line of code:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;    &lt;span class="n"&gt;invert&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;cv2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;bitwise_not&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;grey_img&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This line of code is used to invert the image. it changes the image pixels to zero if the pixel is greater than zero and vice-versa.  For instance; a white image will be changed to black.&lt;/p&gt;

&lt;p&gt;Using incremental development law. You can also add this line of code to see how the inverted image looks like.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;    &lt;span class="n"&gt;cv2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;imshow&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;image&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;invert&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;The next step is to blur the image and to do that
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;    &lt;span class="n"&gt;blur&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;cv2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;GaussianBlur&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;invert&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;cv2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;BORDER_DEFAULT&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The syntax for the &lt;code&gt;GaussianBlur()&lt;/code&gt; method is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;    &lt;span class="n"&gt;cv2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;GaussianBlur&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;src&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ksize&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sigmaX&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sigmaY&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;borderType&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In &lt;code&gt;GaussianBlur()&lt;/code&gt; method, you need to pass &lt;code&gt;src&lt;/code&gt; and &lt;code&gt;ksize&lt;/code&gt; values every time and either one, two, or all parameters value from remaining &lt;code&gt;sigmaX&lt;/code&gt;, &lt;code&gt;sigmaY&lt;/code&gt; and &lt;code&gt;borderType&lt;/code&gt; parameter should be passed.&lt;/p&gt;

&lt;p&gt;Both &lt;code&gt;sigmaX and sigmaY&lt;/code&gt; parameters become optional if you mention the &lt;code&gt;ksize(kernal size)&lt;/code&gt; value other than (0,0).&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;src&lt;/code&gt; stands for the source file which we've input has invert since we want to work on invert.&lt;br&gt;
The &lt;code&gt;ksize&lt;/code&gt; value is always in tuple -- i.e. values enclosed in a parenthesis, You can set the value to any range you want depending on your preference.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;sigmaX&lt;/code&gt; and &lt;code&gt;sigmaX&lt;/code&gt; are optional since &lt;code&gt;ksize&lt;/code&gt; as been set&lt;br&gt;
The &lt;code&gt;borderType&lt;/code&gt; should also be included, but I love using the default type, so you pass in &lt;code&gt;cv2.BORDER_DEFAULT&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The next line of code is to invert the blur image again, and we can do that using
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;    &lt;span class="n"&gt;invertedblur&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;cv2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;bitwise_not&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;blur&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;The next line of code is to divide the image
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;    &lt;span class="n"&gt;sketch&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;cv2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;divide&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;grey_img&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;invertedblur&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;scale&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mf"&gt;256.0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;Now we are done with our code the last code is just to write the image into a portable network graphic(PNG) and we can achieve that by typing
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;    &lt;span class="n"&gt;cv2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;imwrite&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;sketch.png&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sketch&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Congratulations, We have successfully create a sketch of an image. This is an example of the image we sketched using &lt;code&gt;OpenCV&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fihmclgyxo8h3eodcwce9.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fihmclgyxo8h3eodcwce9.jpeg" alt="Image Sketch"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is the full implementation of the code for easy access/use.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;    &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;cv2&lt;/span&gt;
    &lt;span class="n"&gt;path&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="sa"&gt;r&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;C:\Users\folksconnect\Pictures\2020-07&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
    &lt;span class="n"&gt;image_path&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;cv2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;imread&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;grey_image&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;cv2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;cvtColor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;image_path&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;  &lt;span class="n"&gt;cv2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;COLOR_BGR2GRAY&lt;/span&gt;
    &lt;span class="n"&gt;cv2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;imshow&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;Image&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;grey_image&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;invert&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;cv2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;bitwise_not&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;grey_img&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;blur&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;cv2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;GaussianBlur&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;invert&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="n"&gt;cv2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;BORDER_DEFAULT&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;invertedblur&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;cv2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;bitwise_not&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;blur&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;sketch&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;cv2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;divide&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;grey_img&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;invertedblur&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;scale&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mf"&gt;256.0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;cv2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;imwrite&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;sketch.png&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;sketch&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;Note: Ensure you change the path of the image to your own path ( the path on your PC) as the above path is a directory to an image on my PC.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;In this guide, We just built a sketch of an image using OpenCV in Python. If you followed through this guide properly you should be able to set up your own version of this project and also help you in explore other cool features of this awesome library e.g. face recognition and lots more. &lt;/p&gt;

&lt;p&gt;You can also improve on it by adding/implementing other features and functionalities.&lt;/p&gt;

&lt;h2&gt;
  
  
  Useful Resources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://opencv.org/" rel="noopener noreferrer"&gt;https://opencv.org/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.python.org/" rel="noopener noreferrer"&gt;https://www.python.org/&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Happy Coding!&lt;/p&gt;

</description>
      <category>python</category>
      <category>opencv</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>Beginners path-way on how to get started with Robotics</title>
      <dc:creator>Ogunbiyi Ibrahim</dc:creator>
      <pubDate>Thu, 29 Apr 2021 11:56:18 +0000</pubDate>
      <link>https://dev.to/comejoinfolks/yo-you-want-to-get-started-with-robotics-but-don-t-know-the-road-map-to-follow-4358</link>
      <guid>https://dev.to/comejoinfolks/yo-you-want-to-get-started-with-robotics-but-don-t-know-the-road-map-to-follow-4358</guid>
      <description>&lt;p&gt;&lt;strong&gt;&lt;em&gt;Get ready to roll up your sleeves because i got you covered .&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Firstly: what is Robotics
&lt;/h3&gt;

&lt;p&gt;Robotics in lame man's term is using machine to perform  task that can be done by human being. Your phone is typically a robot because it can perform calculations  like adding , subtraction of two numbers which you can essentially do.&lt;/p&gt;

&lt;p&gt;Robotics is making  machine that thinks like you. Robots are widely used in industries to perform simple repetitive task. Tesla cars is typically an example of automobiles robots.&lt;/p&gt;

&lt;h3&gt;
  
  
  Do you think robotics is worth learning in 2021.
&lt;/h3&gt;

&lt;p&gt;If you want to dive in into robotics  because of the monetary aspect  well this if for you according to glassdoor the average salary is ..... Whao! That's a huge money there .&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--s98IXcT8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1619692628981/GARJRupKb.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--s98IXcT8--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1619692628981/GARJRupKb.jpeg" alt="20210429_113637.jpg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  What programming should I learn for robotics.
&lt;/h4&gt;

&lt;p&gt;When I wanted to start my robotics software engineering career I was pondering  on what programming to learn because there were lots of them.&lt;/p&gt;

&lt;p&gt;*&lt;strong&gt;&lt;em&gt;But heads up! *&lt;/em&gt;&lt;/strong&gt;  I got you covered here are the 3 core programming languages you need to know&lt;/p&gt;

&lt;p&gt;*&lt;strong&gt;&lt;em&gt;python&lt;/em&gt;&lt;/strong&gt;*&lt;/p&gt;

&lt;p&gt;*&lt;strong&gt;&lt;em&gt;c language&lt;/em&gt;&lt;/strong&gt;*&lt;/p&gt;

&lt;p&gt;*&lt;strong&gt;&lt;em&gt;c++ language&lt;/em&gt;&lt;/strong&gt;*&lt;/p&gt;

&lt;h3&gt;
  
  
  1. python:
&lt;/h3&gt;

&lt;p&gt;Why Python!. python as far as I'm concerned is one of the simplest  language to learn. It as a lot of libraries  for robotics  with less coding  compared to c and c++. Python is intuitive and easy for newbies  starting their career in robotics. Python is used in raspberry pi and can also be used with ROS(robotics operating system)&lt;/p&gt;

&lt;p&gt;###2. C language:&lt;/p&gt;

&lt;p&gt;Why C!. A lot of hardware libraries are used in robotics are written in C this libraries allow  interaction  with low level hardware and real time performance. &lt;/p&gt;

&lt;h3&gt;
  
  
  3. C++:
&lt;/h3&gt;

&lt;p&gt;Why C++! The main reason is &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Performance &lt;/li&gt;
&lt;li&gt;Scalability &lt;/li&gt;
&lt;li&gt;Memory management. &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I will drop  resources for these programming languages listed above  mostly free.&lt;/p&gt;

&lt;h4&gt;
  
  
  Do I need to get stucked with  Mathematics.
&lt;/h4&gt;

&lt;p&gt;Mathematics is one of the main reason people don't want to dive in into robotics. You don't need much mathematics to start with robotics. All you need is your high school or basic knowledge in algebra after that your advancement in robotics will require you to learn &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Calculus&lt;/li&gt;
&lt;li&gt;Linear algebra &lt;/li&gt;
&lt;li&gt;Statistics &lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  These are the step by step road map I wished I had followed before now to build your career in robotics
&lt;/h3&gt;

&lt;h4&gt;
  
  
  1. Learn 3 core programming languages
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;Python &lt;/li&gt;
&lt;li&gt;C language &lt;/li&gt;
&lt;li&gt;C++ &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You can start with the first two so you will be able to do hands on project like arduino and raspberry pi &lt;/p&gt;

&lt;h5&gt;
  
  
  2. Learn  mechatronic
&lt;/h5&gt;

&lt;p&gt;Mechatronic is a cool stuff to start with as an hands on project I know you might be thinking well I don't know anything about mechatronic.  *&lt;strong&gt;&lt;em&gt;But folks! *&lt;/em&gt;&lt;/strong&gt; you better want to start with with something rather than nothing  and to make life easier for you start with *&lt;strong&gt;&lt;em&gt;Arduino and Raspberry pi&lt;/em&gt;&lt;/strong&gt;*&lt;/p&gt;

&lt;p&gt;*&lt;strong&gt;&lt;em&gt;1. Arduino&lt;/em&gt;&lt;/strong&gt;* is an open source electronic prototyping platform enabling user to create  interactive electronic projects.  You will need the basic knowledge of *&lt;strong&gt;&lt;em&gt;C language&lt;/em&gt;&lt;/strong&gt;* to start with arduino you can buy the arduino kit online at amazon or other ecommerce websites &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Jc4g9V2B--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1619694950015/fuaqb7BQA.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Jc4g9V2B--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://cdn.hashnode.com/res/hashnode/image/upload/v1619694950015/fuaqb7BQA.jpeg" alt="20210429_121520.jpg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;*&lt;strong&gt;&lt;em&gt;2. Raspberry pi&lt;/em&gt;&lt;/strong&gt;* is a tiny  and affordable computer that you can use to learn programming through practical projects. You will need *&lt;strong&gt;&lt;em&gt;python or c++&lt;/em&gt;&lt;/strong&gt;* to start with raspberry pi &lt;/p&gt;

&lt;p&gt;*&lt;strong&gt;&lt;em&gt;This article will be continued *&lt;/em&gt;&lt;/strong&gt;&lt;br&gt;
If you found it useful don't forget to like and share across all platforms. &lt;br&gt;
You can reach  at my handle &lt;/p&gt;

&lt;p&gt;&lt;a href="http://twitter.com/%5B@Comejoinfolks%5D"&gt;Twitter&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;&lt;a href="https://t.me/Ibrahimogunbiyi"&gt;Telegram&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Thanks🥳🥳&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>python</category>
      <category>career</category>
      <category>programming</category>
    </item>
    <item>
      <title>Five free ebooks i wish i add earlier when i was a python beginner programmer. Thank me later</title>
      <dc:creator>Ogunbiyi Ibrahim</dc:creator>
      <pubDate>Sat, 13 Feb 2021 04:44:50 +0000</pubDate>
      <link>https://dev.to/comejoinfolks/five-free-ebooks-i-wish-i-add-earlier-when-i-was-a-python-beginner-programmer-thank-me-later-1j5c</link>
      <guid>https://dev.to/comejoinfolks/five-free-ebooks-i-wish-i-add-earlier-when-i-was-a-python-beginner-programmer-thank-me-later-1j5c</guid>
      <description>&lt;p&gt;Five python free ebooks I wish I add earlier when I was a beginner folks it's very easy to decipher. &lt;br&gt;
1) programming in python 3 mark summerfield &lt;br&gt;
2)Begin to code with python  Rob miles&lt;br&gt;
3)learn python the hard way&lt;br&gt;
4) A practical introduction to python programming Brian heiniod&lt;br&gt;
5)Fundamental  of python first programming Kenneth Lambert &lt;/p&gt;

&lt;p&gt;*For advanced programmers I recommend you try *&lt;br&gt;
Python tricks  Dan bader&lt;/p&gt;

&lt;p&gt;Thank me later 😀🥰🥰🥳🥳&lt;/p&gt;

&lt;h1&gt;
  
  
  python
&lt;/h1&gt;

</description>
      <category>python</category>
      <category>beginners</category>
    </item>
    <item>
      <title>A quick introduction of who i am</title>
      <dc:creator>Ogunbiyi Ibrahim</dc:creator>
      <pubDate>Fri, 12 Feb 2021 16:34:30 +0000</pubDate>
      <link>https://dev.to/comejoinfolks/a-quick-introduction-of-who-i-am-58m8</link>
      <guid>https://dev.to/comejoinfolks/a-quick-introduction-of-who-i-am-58m8</guid>
      <description>&lt;p&gt;I'm a 300 level computer science student at the olusegun agagu university of science and technology in ondo.im currently a python wizard but aspiring to become a data scientist so I can achieve my purpose in robotics AI&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
