<?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: Rishal Hurbans</title>
    <description>The latest articles on DEV Community by Rishal Hurbans (@rishalhurbans).</description>
    <link>https://dev.to/rishalhurbans</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%2F81305%2Fc915ff75-7b94-40b2-ae47-58089720ec99.jpg</url>
      <title>DEV Community: Rishal Hurbans</title>
      <link>https://dev.to/rishalhurbans</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rishalhurbans"/>
    <language>en</language>
    <item>
      <title>Reinforcement learning with Q-learning</title>
      <dc:creator>Rishal Hurbans</dc:creator>
      <pubDate>Wed, 22 Dec 2021 09:27:21 +0000</pubDate>
      <link>https://dev.to/rishalhurbans/reinforcement-learning-with-q-learning-59dn</link>
      <guid>https://dev.to/rishalhurbans/reinforcement-learning-with-q-learning-59dn</guid>
      <description>&lt;p&gt;Like other machine learning algorithms, a reinforcement learning model needs to be trained before it can be used. The training phase centers on exploring the environment and receiving feedback, given specific actions performed in specific circumstances or states.&lt;/p&gt;

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

&lt;p&gt;The life cycle of training a reinforcement learning model is based on the Markov Decision Process, which provides a mathematical framework for modeling decisions. Let's use an autonomous car parking as an example.&lt;/p&gt;

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

&lt;p&gt;A simulator needs to model the environment, the actions of the agent, and the rewards received after each action. A reinforcement learning algorithm will use the simulator to learn through practice by taking actions in the simulated environment and measuring the outcome.&lt;/p&gt;

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

&lt;p&gt;Initialize the environment: This function involves resetting the environment, including the agent, to the starting state. Get the current state of the environment: This function provides the current state of the environment, which will change after each action is performed.&lt;/p&gt;

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

&lt;p&gt;Apply an action to the environment: This function involves having the agent apply an action to the environment - the environment is affected by the action, which may result in a reward.&lt;/p&gt;

&lt;p&gt;Calculate the reward of the action: This function is related to applying the action to the environment. The reward for the action and effect on the environment need to be calculated.&lt;/p&gt;

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

&lt;p&gt;Determine whether the goal is achieved: This function determines whether the agent has achieved the goal. In an environment in which the goal cannot be achieved, the simulator needs to signal completion when it deems necessary.&lt;/p&gt;

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

&lt;p&gt;After many cycles of simulation, and the agent taking actions, the Q-table will be trained with sequences of actions that are favourable to get to the destination. Note: Without varying environment data, the model will be overfitted and perform poorly in real-world situations.&lt;/p&gt;

&lt;p&gt;Learn more about reinforcement learning in Grokking AI Algorithms with Manning Publications: &lt;a href="http://bit.ly/gaia-book"&gt;http://bit.ly/gaia-book&lt;/a&gt;, consider following me - &lt;a href="https://twitter.com/RishalHurbans"&gt;@RishalHurbans&lt;/a&gt;, or join my mailing list for infrequent knowledge drops: &lt;a href="https://rhurbans.com/subscribe"&gt;https://rhurbans.com/subscribe&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>watercooler</category>
    </item>
    <item>
      <title>Intuition of reinforcement learning</title>
      <dc:creator>Rishal Hurbans</dc:creator>
      <pubDate>Wed, 15 Dec 2021 08:02:01 +0000</pubDate>
      <link>https://dev.to/rishalhurbans/intuition-of-reinforcement-learning-3kdc</link>
      <guid>https://dev.to/rishalhurbans/intuition-of-reinforcement-learning-3kdc</guid>
      <description>&lt;p&gt;Reinforcement learning (RL) is an area of machine learning inspired by behavioral psychology. The concept of reinforcement learning is based on cumulative rewards or penalties for the actions that are taken by an agent in a dynamic environment.&lt;/p&gt;

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

&lt;p&gt;Think about a young dog growing up. The dog is the agent in an environment that is our home. When we want the dog to sit, we usually say, “Sit.” The dog doesn’t understand English, so we might nudge it by lightly pushing down on its hindquarters.&lt;/p&gt;

&lt;p&gt;After it sits, we pet the dog or give it a treat. This process will need to be repeated several times, and we would have positively reinforced the idea of sitting. The trigger in the environment is saying “Sit”; the behavior learned is sitting; and the reward is treats.&lt;/p&gt;

&lt;p&gt;Where supervised learning uses labeled data to make predictions and classifications, and unsupervised learning uses unlabeled data to find clusters and trends, RL uses feedback from actions performed to learn what actions are most beneficial in different scenarios toward a goal.&lt;/p&gt;

&lt;p&gt;Learn more about reinforcement learning in Grokking AI Algorithms with Manning Publications: &lt;a href="http://bit.ly/gaia-book"&gt;http://bit.ly/gaia-book&lt;/a&gt;, consider following me - &lt;a href="https://twitter.com/RishalHurbans"&gt;@RishalHurbans&lt;/a&gt;, or join my mailing list for infrequent knowledge drops: &lt;a href="https://rhurbans.com/subscribe"&gt;https://rhurbans.com/subscribe&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>watercooler</category>
    </item>
    <item>
      <title>Introduction to purpose-specific neural networks</title>
      <dc:creator>Rishal Hurbans</dc:creator>
      <pubDate>Wed, 08 Dec 2021 09:56:10 +0000</pubDate>
      <link>https://dev.to/rishalhurbans/introduction-to-purpose-specific-neural-networks-5e0i</link>
      <guid>https://dev.to/rishalhurbans/introduction-to-purpose-specific-neural-networks-5e0i</guid>
      <description>&lt;p&gt;Artificial neural networks (ANNs) are versatile and can be designed to address different problems. Specific architectural styles are useful for solving certain problems. Think of the architecture as being the fundamental configuration of the network.&lt;/p&gt;

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

&lt;p&gt;Convolutional neural networks (CNNs) are designed for image recognition. These networks can be used to find the relationships among different objects and unique areas within images. If you’ve ever searched for an image online, you have likely interacted indirectly with a CNN.&lt;/p&gt;

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

&lt;p&gt;Whereas standard ANNs accept a fixed number of inputs, recurrent neural networks (RNNs) accept a sequence of inputs with no predetermined length. These inputs are like spoken sentences. RNNs are useful in applications pertaining to speech and text recognition and prediction.&lt;/p&gt;

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

&lt;p&gt;A generative adversarial network (GAN) consists of a generator network and a discriminator network. For example, the generator creates a potential solution like an image or a landscape, and a discriminator uses real images of landscapes to determine the realism or correctness.&lt;/p&gt;

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

&lt;p&gt;GANs can be used to generate convincing fake images and videos (also known as deepfakes), which raises concern about the authenticity of information in the media. They can also be used in extraordinary ways for CGI for movies.&lt;/p&gt;

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

&lt;p&gt;Learn more about artificial neural networks in Grokking AI Algorithms with Manning Publications: &lt;a href="http://bit.ly/gaia-book"&gt;http://bit.ly/gaia-book&lt;/a&gt;, consider following me - &lt;a href="https://twitter.com/RishalHurbans"&gt;@RishalHurbans&lt;/a&gt;, or join my mailing list for infrequent knowledge drops: &lt;a href="https://rhurbans.com/subscribe"&gt;https://rhurbans.com/subscribe&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>watercooler</category>
    </item>
    <item>
      <title>Intuition of data in artificial neural networks</title>
      <dc:creator>Rishal Hurbans</dc:creator>
      <pubDate>Thu, 02 Dec 2021 05:40:47 +0000</pubDate>
      <link>https://dev.to/rishalhurbans/intuition-of-data-in-artificial-neural-networks-2jo2</link>
      <guid>https://dev.to/rishalhurbans/intuition-of-data-in-artificial-neural-networks-2jo2</guid>
      <description>&lt;p&gt;To explore the workings of multi-node ANNs, consider an example dataset related to car collisions. Suppose that we have data from several cars at the moment that an unforeseen object enters the path of their movement.&lt;/p&gt;

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

&lt;ul&gt;
&lt;li&gt;Speed— The speed at which the car was traveling before encountering the object.&lt;/li&gt;
&lt;li&gt;Terrain quality— The quality of the road on which the car was traveling before encountering the object.&lt;/li&gt;
&lt;li&gt;Degree of vision— The driver’s degree of vision before the car encountered the object.&lt;/li&gt;
&lt;li&gt;Total experience— The total driving experience of the driver of the car.&lt;/li&gt;
&lt;li&gt;Collision occurred?— Whether a collision occurred or not.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Because a single hidden node is connected to every input node but every connection has a different weight, independent hidden nodes might be concerned with specific relationships among two or more input nodes.&lt;/p&gt;

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

&lt;p&gt;The nodes in a hidden layer can be conceptually compared with the analogy of ants. Individual ants fulfil small tasks that are seemingly insignificant, but when the ants act as a colony, intelligent behavior emerges.&lt;/p&gt;

&lt;p&gt;The nodes of the network all process the inputs through a phase of training to find relationships and understand what relationships influence the classification of the situation.&lt;/p&gt;

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

&lt;p&gt;ANNs are versatile and can be designed to address different problems. Learn more in Grokking AI Algorithms with Manning Publications: &lt;a href="http://bit.ly/gaia-book"&gt;http://bit.ly/gaia-book&lt;/a&gt;, consider following me - &lt;a href="https://twitter.com/RishalHurbans"&gt;@RishalHurbans&lt;/a&gt;, or join my mailing list for infrequent knowledge drops: &lt;a href="https://rhurbans.com/subscribe"&gt;https://rhurbans.com/subscribe&lt;/a&gt;.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>ML and decision trees for beginners</title>
      <dc:creator>Rishal Hurbans</dc:creator>
      <pubDate>Wed, 17 Nov 2021 06:26:44 +0000</pubDate>
      <link>https://dev.to/rishalhurbans/ml-and-decision-trees-for-beginners-3nca</link>
      <guid>https://dev.to/rishalhurbans/ml-and-decision-trees-for-beginners-3nca</guid>
      <description>&lt;p&gt;Suppose that we have several vehicles that are cars and trucks. We measure the weight of each vehicle and the number of wheels of each vehicle. We also forget for now that cars and trucks look different. How can we make an algorithm tell them apart?&lt;/p&gt;

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

&lt;p&gt;If you haven't already, check out this article for the intuition of machine learning before we continue: &lt;a href="https://rhurbans.com/machine-learning-intuition/"&gt;https://rhurbans.com/machine-learning-intuition/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Almost all cars have exactly four wheels, and many large trucks have more than four wheels. Trucks are usually heavier than cars, but a large sport-utility vehicle may be as heavy as a small truck. We could find relationships between the weight and number of wheels of vehicles to predict whether a vehicle is a car or a truck. A decision tree can be useful here.&lt;/p&gt;

&lt;p&gt;Decision trees are structures that describe a series of decisions that are made to find a solution to a problem. So a decision tree can be used to encompass the above logic. Let's think about how we might train a model to categorize diamonds.&lt;/p&gt;

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

&lt;p&gt;A decision tree includes decision nodes, and leaf nodes. A decision node contains a question being asked, the positive examples related to the question, and the negative examples.&lt;/p&gt;

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

&lt;p&gt;A decision tree also includes leaf nodes containing a list of examples only. These are all examples which were categorised correctly.&lt;/p&gt;

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

&lt;p&gt;In building a decision tree, we test all possible questions to determine which one is the best question to ask at a specific point in the decision tree. To test a question, we use the concept of entropy — the measurement of uncertainty of a dataset.&lt;/p&gt;

&lt;p&gt;If we had 5 Perfect diamonds and 5 Okay diamonds, and tried to pick a Perfect diamond by randomly selecting a diamond from the 10, what are the chances that the diamond would be Perfect?&lt;/p&gt;

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

&lt;p&gt;Decision trees are a simple but powerful ML algorithm. To learn more, see Grokking AI Algorithms with Manning Publications: &lt;a href="http://bit.ly/gaia-book"&gt;http://bit.ly/gaia-book&lt;/a&gt;, consider following me - &lt;a href="https://twitter.com/RishalHurbans"&gt;@RishalHurbans&lt;/a&gt;, or join my mailing list for infrequent knowledge drops: &lt;a href="https://rhurbans.com/subscribe"&gt;https://rhurbans.com/subscribe&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>watercooler</category>
    </item>
    <item>
      <title>Machine learning flavours</title>
      <dc:creator>Rishal Hurbans</dc:creator>
      <pubDate>Tue, 09 Nov 2021 10:16:23 +0000</pubDate>
      <link>https://dev.to/rishalhurbans/machine-learning-flavours-2ac8</link>
      <guid>https://dev.to/rishalhurbans/machine-learning-flavours-2ac8</guid>
      <description>&lt;p&gt;Machine learning is useful only if you have the right data and have questions to ask that it might be able to answer. Machine learning algorithms find patterns in data but cannot do useful things magically.&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%2Fafk0tbjxt7bomhtrplvq.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%2Fafk0tbjxt7bomhtrplvq.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;One of the most common techniques in traditional machine learning is called supervised learning. We want to look at data, understand the patterns and relationships among the data, and predict the results if we are given new examples of different data in the same format.&lt;/p&gt;

&lt;p&gt;Regression involves drawing a line through a set of data points to most closely fit the overall shape of the data. Regression can be used for applications such as finding trends between marketing initiatives and sales, or determining rent like in the next example.&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%2Fof4afj54t40cpokchg9t.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%2Fof4afj54t40cpokchg9t.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A simple example of supervised learning: &lt;a href="https://rhurbans.com/machine-learning-intuition/" rel="noopener noreferrer"&gt;https://rhurbans.com/machine-learning-intuition/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Classification aims to predict categories of examples based on their features. Can we determine whether something is a car or a truck based on its number of wheels, weight, and top speed?&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%2Fawp9xq5yax4y544sthra.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%2Fawp9xq5yax4y544sthra.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Unsupervised learning involves finding underlying patterns in data that may be difficult to find by inspecting the data manually. Unsupervised learning is useful for clustering data that have similar features and uncovering features that are important in the relationships.&lt;/p&gt;

&lt;p&gt;On an e-commerce site, for example, products might be grouped based on customer purchase behavior. If many customers purchase soap, sponges, and towels together, it is likely that more customers would want that combination of products.&lt;/p&gt;

&lt;p&gt;Reinforcement learning is inspired by behavioral psychology and operates by rewarding or punishing an algorithm based on its actions in an environment. It has similarities to supervised learning and unsupervised learning, as well as many differences.&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%2Fpegopoe287b7iaff3bm3.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%2Fpegopoe287b7iaff3bm3.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you're interested in more details about ML algorithms, see Grokking AI Algorithms with Manning Publications: &lt;a href="http://bit.ly/gaia-book" rel="noopener noreferrer"&gt;http://bit.ly/gaia-book&lt;/a&gt;, consider following me - &lt;a href="https://twitter.com/RishalHurbans" rel="noopener noreferrer"&gt;@RishalHurbans&lt;/a&gt;, or join my mailing list for infrequent knowledge drops: &lt;a href="https://rhurbans.com/subscribe" rel="noopener noreferrer"&gt;https://rhurbans.com/subscribe&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>watercooler</category>
    </item>
    <item>
      <title>Machine learning intuition</title>
      <dc:creator>Rishal Hurbans</dc:creator>
      <pubDate>Tue, 02 Nov 2021 11:00:14 +0000</pubDate>
      <link>https://dev.to/rishalhurbans/machine-learning-intuition-ge9</link>
      <guid>https://dev.to/rishalhurbans/machine-learning-intuition-ge9</guid>
      <description>&lt;p&gt;Machine learning can seem like a daunting concept to learn and apply, but with the right framing and understanding of the process and algorithms, it can be interesting, useful, and fun. Let's explore apartment prices in a city.&lt;/p&gt;

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

&lt;p&gt;Suppose that you’re looking for a new apartment. You speak to friends and family, and do some online searches for apartments in the city. You notice that apartments in different areas are priced differently.&lt;/p&gt;

&lt;p&gt;A one-bedroom apartment in the city center (close to work) costs $5,000 per month. A two-bedroom apartment in the city center costs $7,000 per month. A one-bedroom apartment outside the city center, where you will need to travel to work, costs $3,000 per month.&lt;/p&gt;

&lt;p&gt;You notice some patterns. Apartments in the city center are most expensive and are usually between $5,000 and $7,000 per month. Apartments outside the city are cheaper. Increasing the number of rooms adds between $1,500 and $2,000 per month.&lt;/p&gt;

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

&lt;p&gt;This example shows how we use data to find patterns and make decisions. If you encounter a two-bedroom apartment in the city center with a garage, it’s reasonable to assume that the price would be about $8,000 per month.&lt;/p&gt;

&lt;p&gt;Machine learning aims to find patterns in data for useful applications in the real world. We could spot the pattern in this small dataset, but machine learning spots them for us in large, complex datasets.&lt;/p&gt;

&lt;p&gt;If you're interested in more details about ML algorithms, see Grokking AI Algorithms with Manning Publications: &lt;a href="http://bit.ly/gaia-book"&gt;http://bit.ly/gaia-book&lt;/a&gt;, consider following me - &lt;a href="https://twitter.com/RishalHurbans"&gt;@RishalHurbans&lt;/a&gt;, or join my mailing list for infrequent knowledge drops: &lt;a href="https://rhurbans.com/subscribe"&gt;https://rhurbans.com/subscribe&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>watercooler</category>
    </item>
    <item>
      <title>Intuition of particle swarm optimization</title>
      <dc:creator>Rishal Hurbans</dc:creator>
      <pubDate>Tue, 26 Oct 2021 12:35:31 +0000</pubDate>
      <link>https://dev.to/rishalhurbans/intuition-of-particle-swarm-optimization-32m4</link>
      <guid>https://dev.to/rishalhurbans/intuition-of-particle-swarm-optimization-32m4</guid>
      <description>&lt;p&gt;Swarm intelligence is an amazing phenomena in nature. We see it in flocks of birds, bees in a hive, bacterial growth, and more. The behaviour of these wonderful creatures have been studied and inspired useful algorithms. Here's an introduction to particle swarm optimization.&lt;/p&gt;

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

&lt;p&gt;Particle swarm optimization is a swarm intelligence algorithm. It relies on emergent behavior of many individuals to solve difficult problems as a collective. The most amazing feats are always achieved as a collective. Learn more about swarms here: &lt;a href="https://rhurbans.com/optimization-finding-the-best-solutions/"&gt;https://rhurbans.com/optimization-finding-the-best-solutions/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Bird flocks are an ideal example of swarm intelligence in nature. When a single bird is flying, it might attempt several maneuvers and techniques to preserve energy - jumping and gliding or leveraging wind currents to carry it in the right direction of travel.&lt;/p&gt;

&lt;p&gt;This behavior indicates some primitive level of intelligence in a single individual. But birds also have the need to migrate during different seasons. In winter, there is less availability of insects and food, nesting locations are scarce, and warm weather is better for survival.&lt;/p&gt;

&lt;p&gt;Migration is usually not a short trip. It takes thousands of kilometers of movement to arrive at an area with suitable conditions. When birds travel these long distances, they tend to flock.&lt;/p&gt;

&lt;p&gt;The formation that we observe in bird flocks has several advantages. A large, strong bird will take the lead, and when it flaps its wings, it creates uplift for the birds behind it. These birds can fly while using significantly less energy.&lt;/p&gt;

&lt;p&gt;Particle swarm optimization involves a group of individuals at different points in the solution space, all using real-life swarm concepts to find an optimal solution. Imagine building a drone and finding the optimal plastic, aluminium, while minimizing drag in the wind.&lt;/p&gt;

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

&lt;p&gt;Each combination of the values for plastic, aliminium, and drag is a possible solution. We want to find the values for plastic and aluminium that minimize the drag value. Particle swarm optimization can help us with this.&lt;/p&gt;

&lt;p&gt;PSOs are useful in large search spaces —There are many data points and possibilities of combinations. And search spaces with high dimensions —There are many parameters that influence how well a solution performs.&lt;/p&gt;

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

&lt;p&gt;A PSO particle contains a:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Position —The position of the particle in all dimensions&lt;/li&gt;
&lt;li&gt;Best position —The best position found using the fitness function&lt;/li&gt;
&lt;li&gt;Velocity —The current velocity of the particle’s movement&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;Particle swarm optimization provides a means to search a large search space without checking every value in each dimension. These attributes help particles search the solution space and converge to good solutions inspired by swarms in nature.&lt;/p&gt;

&lt;p&gt;If you found this interesting and useful, see Grokking AI Algorithms with Manning Publications: &lt;a href="http://bit.ly/gaia-book"&gt;http://bit.ly/gaia-book&lt;/a&gt;, consider following me - &lt;a href="https://twitter.com/RishalHurbans"&gt;@RishalHurbans&lt;/a&gt;, or join my mailing list for infrequent knowledge drops: &lt;a href="https://rhurbans.com/subscribe"&gt;https://rhurbans.com/subscribe&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>watercooler</category>
    </item>
    <item>
      <title>Learning from ants</title>
      <dc:creator>Rishal Hurbans</dc:creator>
      <pubDate>Thu, 21 Oct 2021 10:08:00 +0000</pubDate>
      <link>https://dev.to/rishalhurbans/learning-from-ants-11be</link>
      <guid>https://dev.to/rishalhurbans/learning-from-ants-11be</guid>
      <description>&lt;p&gt;Learning from ants: Ant colony optimization algorithms are versatile and useful for several real-world applications. These applications usually center on complex optimization problems. Here are three uses for the algorithm.&lt;/p&gt;

&lt;p&gt;If you haven't already, gain the intuition of the ant colony optimization algorithm here: &lt;a href="https://rhurbans.com/ant-colony-optimization-for-beginners/"&gt;https://rhurbans.com/ant-colony-optimization-for-beginners/&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Route optimization
&lt;/h2&gt;

&lt;p&gt;In a logistics example, perhaps the distance between destinations, traffic conditions, types of packages being delivered, and times of day are important constraints to optimize the operations of the business. ACOs can help with that.&lt;/p&gt;

&lt;h2&gt;
  
  
  Job scheduling
&lt;/h2&gt;

&lt;p&gt;Job scheduling is required in almost any industry. Nurse shifts are important to ensure that good health care can be provided while keeping nurses healthy. Computational jobs on servers must be scheduled in an optimal manner to maximize the use of the hardware.11&lt;/p&gt;

&lt;h2&gt;
  
  
  Image processing
&lt;/h2&gt;

&lt;p&gt;Although there are better ways, ACOs can be used for edge detection in image processing. An image is composed of several adjacent pixels, and the ants can move from pixel to pixel, leaving behind pheromone trails that would trace an object.&lt;/p&gt;

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

&lt;p&gt;If you're interested in more details about ant colony optimization and AI, see Grokking AI Algorithms with Manning Publications: [&lt;a href="http://bit.ly/gaia-book"&gt;http://bit.ly/gaia-book&lt;/a&gt;], consider following me - &lt;a href="https://twitter.com/RishalHurbans"&gt;@RishalHurbans&lt;/a&gt;, or join my mailing list for infrequent knowledge drops: &lt;a href="https://rhurbans.com/subscribe"&gt;https://rhurbans.com/subscribe&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>watercooler</category>
      <category>computerscience</category>
    </item>
    <item>
      <title>Ant colony optimization for beginners</title>
      <dc:creator>Rishal Hurbans</dc:creator>
      <pubDate>Thu, 09 Sep 2021 11:10:47 +0000</pubDate>
      <link>https://dev.to/rishalhurbans/ant-colony-optimization-for-beginners-47hn</link>
      <guid>https://dev.to/rishalhurbans/ant-colony-optimization-for-beginners-47hn</guid>
      <description>&lt;p&gt;A single ant can carry 10 to 50 times its own body weight and run 700 times its body length per minute. These are impressive qualities; however, when acting in a group, that single ant can accomplish much more.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--dhX8uHSM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qitbgf6650sa730ewzxo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--dhX8uHSM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qitbgf6650sa730ewzxo.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In groups, ants build colonies, retrieve food, and even use peer pressure to influence others. They achieve this with pheromones - essentially, perfumes that ants drop wherever they go. Other ants can sense these perfumes and change their behavior based on them.&lt;/p&gt;

&lt;p&gt;An experiment based on real-life harvesting ants showed that they always converged to the shortest path between the nest and the food source. Ants that have walked specific paths increased the pheromone intensity on those paths that other ants pick up on.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--maFeXi-5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/swx9oa7srky48vh7n64v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--maFeXi-5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/swx9oa7srky48vh7n64v.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Ant colony optimization (ACO) algorithms simulate the emergent behavior shown in this experiment. In the case of finding the shortest path, the algorithm converges to a similar state, as observed with real ants. How can we use this to solve a more practical problem?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--F8pWTvpk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3u70mg9ecbrqbfb76lnn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--F8pWTvpk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3u70mg9ecbrqbfb76lnn.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Imagine we're visiting a carnival that has many attractions to experience. Each attraction is located in a different area, with varying distances between them. Because we don’t feel like wasting time walking too much, we want to find the shortest paths between all attractions.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jVg_-_ss--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/esyzemrwt1ifxoo057o4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jVg_-_ss--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/esyzemrwt1ifxoo057o4.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Ant colony optimization can help in finding the shortest path between all the attractions in a more computationally efficient way. If we represent an ant's memory, best distance, and actions it can take, we can simulate a colony and solve hard problems.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--kQhxlb96--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5cvjgeabgo7pe77vv9v5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--kQhxlb96--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5cvjgeabgo7pe77vv9v5.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Follow for the next part to this thread  - &lt;a href="https://twitter.com/RishalHurbans"&gt;@RishalHurbans&lt;/a&gt;. To learn the details of this algorithm, see Grokking AI Algorithms with Manning Publications: &lt;a href="http://bit.ly/gaia-book"&gt;http://bit.ly/gaia-book&lt;/a&gt;, or join my mailing list for infrequent knowledge drops: &lt;a href="https://rhurbans.com/subscribe"&gt;https://rhurbans.com/subscribe&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>algorithms</category>
      <category>watercooler</category>
    </item>
    <item>
      <title>Encoding genetic algorithms</title>
      <dc:creator>Rishal Hurbans</dc:creator>
      <pubDate>Wed, 01 Sep 2021 10:57:27 +0000</pubDate>
      <link>https://dev.to/rishalhurbans/encoding-genetic-algorithms-2dp2</link>
      <guid>https://dev.to/rishalhurbans/encoding-genetic-algorithms-2dp2</guid>
      <description>&lt;p&gt;Genetic algorithms are a fascinating technique for solving optimisation problems. If you can create a set of rules that can measure a solution's performance, you can probably use a GA to help solve the problem. Here are some ways to encode solutions.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--jomivYbU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v4oc1gojv1ra5m1ao5k7.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--jomivYbU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v4oc1gojv1ra5m1ao5k7.gif" alt="Alt Text" width="584" height="292"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you missed my article on the intuition of genetic algorithms, check this out before continuing: &lt;a href="https://rhurbans.com/genetic-algorithms-for-beginners/"&gt;https://rhurbans.com/genetic-algorithms-for-beginners/&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Real-value encoding represents a gene with numeric values, strings, or symbols. The solution is expressed in its natural state. This encoding is used when potential solutions contain continuous values that cannot be encoded easily with binary encoding.&lt;/p&gt;

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

&lt;p&gt;Order encoding, also known as permutation encoding, represents a chromosome as a sequence of elements. Order encoding usually requires all elements to be present in the chromosome. It's useful for problems where the sequence in the solution is important.&lt;/p&gt;

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

&lt;p&gt;Tree encoding represents a chromosome as a tree of elements. Tree encoding is versatile for representing potential solutions where the hierarchy of elements is important or required. Tree encoding can even represent code functions, which consist of a tree of expressions.&lt;/p&gt;

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

&lt;p&gt;Encoding solutions is the first step in setting up a genetic algorithm for success. It can solve interesting problems on its own or even be used with artificial neural networks, like in this Super Mario example.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8cGzKp-i--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x5cfbijj3ggn448yn2wj.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8cGzKp-i--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x5cfbijj3ggn448yn2wj.gif" alt="Alt Text" width="506" height="442"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you're interested in more details about genetic algorithms, see Grokking AI Algorithms with Manning Publications: &lt;a href="http://bit.ly/gaia-book"&gt;http://bit.ly/gaia-book&lt;/a&gt;, consider following me - &lt;a href="https://twitter.com/RishalHurbans"&gt;@RishalHurbans&lt;/a&gt;, or join my mailing list for infrequent knowledge drops: &lt;a href="https://rhurbans.com/subscribe"&gt;https://rhurbans.com/subscribe&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>algorithms</category>
    </item>
    <item>
      <title>Genetic Algorithms for Beginners</title>
      <dc:creator>Rishal Hurbans</dc:creator>
      <pubDate>Fri, 27 Aug 2021 08:23:15 +0000</pubDate>
      <link>https://dev.to/rishalhurbans/genetic-algorithms-for-beginners-2353</link>
      <guid>https://dev.to/rishalhurbans/genetic-algorithms-for-beginners-2353</guid>
      <description>&lt;p&gt;Genetic algorithms are part of the family of optimization algorithms. They operate on the theory of evolution, more particularly, genetic evolution. Each solution is a chromosome that's made up of genes, and is evaluated to determine how well it performs. This repeats until a good solution is found.&lt;/p&gt;

&lt;p&gt;Evolution suggests that the living organisms that we see today did not suddenly exist that way, but evolved through millions of years of subtle changes, with each generation adapting to its environment. See this article for more: &lt;a href="https://rhurbans.com/intelligence-through-evolution/"&gt;https://rhurbans.com/intelligence-through-evolution/&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--zs_rBwyS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mv5lcis6m1ft1raba9a3.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zs_rBwyS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mv5lcis6m1ft1raba9a3.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Genetic algorithms are optimization algorithms. They are used to evaluate massive search spaces for good solutions fast. See this article for more about optimization algorithms: &lt;a href="https://rhurbans.com/optimization-finding-the-best-solutions/"&gt;https://rhurbans.com/optimization-finding-the-best-solutions/&lt;/a&gt;. Let's dive into how genetic algorithms (GAs) work next.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--kd9j6dCU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kaptgtn24riteg2f3ryu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--kd9j6dCU--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kaptgtn24riteg2f3ryu.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When we use a GA, it is paramount to do the encoding step correctly. It requires careful design of the representation of possible states. In this case we want to figure out which items to include in the knapsack to maximize the total value and not exceed the weight limit.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--BOm6vsoe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wanmxsxfpowpl53nfpd8.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--BOm6vsoe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wanmxsxfpowpl53nfpd8.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Binary encoding represents a gene in terms of 0 or 1, so a chromosome is represented by a string of binary bits. For the knapsack problem, 0 = exclude the item, and 1 = include the item. We can then sum the included items' values to find how well that chromosome performs.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--7mDFFSzX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/84xwrywvgsl6s9gy4c4y.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--7mDFFSzX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/84xwrywvgsl6s9gy4c4y.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When the search space is small, it's fairly easy for us to figure out a good solution. But what if there were 26 possible items to add to the knapsack? It becomes much more difficult for a human to solve it by hand. Here's where GAs are useful.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--UAAG2zHW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yplbvwe4am3hazh7tkse.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--UAAG2zHW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yplbvwe4am3hazh7tkse.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A genetic algorithm evaluates the performance of each chromosome and uses mixing to make new solutions that hopefully perform better - like human reproduction. Mixing chromosomes can happen in different ways. A simple approach is to take half and half.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s---tFVzLHG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dur20cwibkbfjmpo96w7.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---tFVzLHG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dur20cwibkbfjmpo96w7.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Genetic algorithms also use the concept of mutation. Like in nature, a random gene might be changed after reproduction between two parent chromosomes. This entire process runs for many cycles, called generations, until a good solution is found.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--rWtlLtpg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/19yxz6d12kj6x9qr7wxm.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--rWtlLtpg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/19yxz6d12kj6x9qr7wxm.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;GAs can perform significantly faster than other methods. But remember, they're not guaranteed to find the BEST solution. I'll be elaborating on genetic algorithms with more visual explanations in upcoming articles. Follow &lt;a href="https://twitter.com/RishalHurbans"&gt;@RishalHurbans&lt;/a&gt; for updates.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--5qYd2Q0V--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y9u8dzunwgjo8gyyw8tc.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5qYd2Q0V--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y9u8dzunwgjo8gyyw8tc.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Thank you for reading. If you're keen to learn at your leisure, see Grokking AI Algorithms with Manning Publications: &lt;a href="http://bit.ly/gaia-book"&gt;http://bit.ly/gaia-book&lt;/a&gt;. Or join my mailing list for infrequent knowledge drops: &lt;a href="https://rhurbans.com/subscribe"&gt;https://rhurbans.com/subscribe&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>beginners</category>
    </item>
  </channel>
</rss>
