<?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: Sean Atukorala</title>
    <description>The latest articles on DEV Community by Sean Atukorala (@shehanat).</description>
    <link>https://dev.to/shehanat</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%2F806173%2F19eb326a-8a9f-4a36-afa0-509a8d282499.png</url>
      <title>DEV Community: Sean Atukorala</title>
      <link>https://dev.to/shehanat</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/shehanat"/>
    <language>en</language>
    <item>
      <title>Solution for "error[E0425]: cannot find function `every` in module `time`" when using Iced Rust GUI library</title>
      <dc:creator>Sean Atukorala</dc:creator>
      <pubDate>Mon, 26 Dec 2022 22:22:09 +0000</pubDate>
      <link>https://dev.to/shehanat/solution-for-errore0425-cannot-find-function-every-in-module-time-when-using-iced-rust-gui-library-4mhj</link>
      <guid>https://dev.to/shehanat/solution-for-errore0425-cannot-find-function-every-in-module-time-when-using-iced-rust-gui-library-4mhj</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.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%2F8ncobrowkhgp8hxd4z2y.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2F8ncobrowkhgp8hxd4z2y.jpg" alt="Figure 1: Winter Scenery" width="800" height="566"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Problem:&lt;/strong&gt;&lt;br&gt;
Running into the following error when trying to use the &lt;a href="https://github.com/iced-rs/iced" rel="noopener noreferrer"&gt;Iced GUI library&lt;/a&gt; for a Rust program that replicates the &lt;a href="https://github.com/iced-rs/iced/tree/master/examples/stopwatch" rel="noopener noreferrer"&gt;stopwatch Iced GUI example&lt;/a&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ cargo build
error[E0425]: cannot find function `every` in module `time`
   --&amp;gt; src\main.rs:203:23
    |
203 |                 time::every(Duration::from_millis(10)).map(Message::Tick)
    |                       ^^^^^ not found in `time`
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Solution:&lt;/strong&gt;&lt;br&gt;
The problem was that the &lt;code&gt;smol&lt;/code&gt; feature was not included in the &lt;code&gt;features&lt;/code&gt; option for the &lt;code&gt;iced&lt;/code&gt; dependency listed in the &lt;code&gt;Cargo.toml&lt;/code&gt; file.&lt;/p&gt;

&lt;p&gt;Try replacing your existing &lt;code&gt;iced&lt;/code&gt; dependency line with the following line:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Cargo.toml file

[dependencies]
iced = {version = "0.6", features = ["smol"]}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then run &lt;code&gt;cargo build&lt;/code&gt; and see if the error is resolved!&lt;/p&gt;

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

&lt;p&gt;Thanks for reading this blog post!&lt;/p&gt;

&lt;p&gt;If you have any questions or concerns please feel free to post a comment in this post and I will get back to you if I find the time.&lt;/p&gt;

&lt;p&gt;If you found this article helpful please share it and make sure to follow me on &lt;a href="https://twitter.com/SeanAtukorala" rel="noopener noreferrer"&gt;Twitter &lt;/a&gt;and &lt;a href="https://github.com/ShehanAT" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;, connect with me on &lt;a href="https://www.linkedin.com/in/shehan-atukorala-8631491a5/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt; and subscribe to my &lt;a href="https://www.youtube.com/channel/UCtxed_NljgtAXrQMMdLvhrQ" rel="noopener noreferrer"&gt;YouTube channel&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>firstpost</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>How to build a Turing Machine Using Pixi.js</title>
      <dc:creator>Sean Atukorala</dc:creator>
      <pubDate>Sun, 27 Nov 2022 18:56:11 +0000</pubDate>
      <link>https://dev.to/shehanat/how-to-build-a-turing-machine-using-pixijs-3f5o</link>
      <guid>https://dev.to/shehanat/how-to-build-a-turing-machine-using-pixijs-3f5o</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--u08TpTd_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1gt4ph3i6jkiuz1ieext.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--u08TpTd_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1gt4ph3i6jkiuz1ieext.jpg" alt="Figure 1: Winter Scenery" width="880" height="550"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Ever wondered how to create a Turing machine using a JavaScript game library? If so, keep reading to learn how to build a Turing machine using the popular JavaScript/HTML rendering library: PixiJS!&lt;/p&gt;

&lt;h2&gt;
  
  
  What is a Turing Machine?
&lt;/h2&gt;

&lt;p&gt;First of all, let's briefly go over what a Turing Machine is: A Turing machine is a theoretical machine originally conceived by the mathematician Alan Turing. The Turing machine can supposedly simulate any computer algorithm regardless of the level of complexity.&lt;/p&gt;

&lt;p&gt;Although the original idea for the machine was purely abstract and hypothetical here is an image of a physical representation of this machine:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--iyESLJ_G--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5b89x7vj3mia71dx7h47.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--iyESLJ_G--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5b89x7vj3mia71dx7h47.png" alt="Figure 2: A physical representation of a Turing machine" width="560" height="253"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Figure 2: A physical representation of a Turing machine&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Keep in mind that it is not exactly in accordance with the theoretical concept as it is not possible to have a tape of infinite length.&lt;/p&gt;

&lt;p&gt;On a more practical level, a Turing machine can read from and write to an infinite tape(although no infinite tapes exist in real life). It manipulates symbols on this theoretically infinite tape based on a predefined set of rules also known as instructions.&lt;/p&gt;

&lt;p&gt;The machine has a head which is positioned over a single square on the aforementioned infinite tape and performs one of the following three instructions:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Read the value of the square that the head is currently pointing towards&lt;/li&gt;
&lt;li&gt;Write a value based on the predefined instruction set to the square that the head is currently pointing towards&lt;/li&gt;
&lt;li&gt;Move the tape either to the left or right by one square in order to do one of this three actions on a neighboring square&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Development:
&lt;/h2&gt;

&lt;p&gt;In this tutorial we will be building a Turing Machine application that replicates a palindrome program.&lt;/p&gt;

&lt;p&gt;{/*  */}&lt;/p&gt;

&lt;p&gt;For this tutorial it would be easy if you could follow along with the sample application in this GitHub link: &lt;a href="https://github.com/ShehanAT/PalindromeTuringMachine"&gt;Palindrome Turing Machine Starter Code&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;First visit this GitHub link and clone the repo. Then open the folder in a coding editor(I'll be using VSCode for this tutorial):&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--0-gDWC_J--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/veextpzevfor89p3mam1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--0-gDWC_J--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/veextpzevfor89p3mam1.png" alt="Figure 3: Image of cloned repo in VSCode" width="880" height="496"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Figure 3: Image of the cloned repo in VSCode&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;For the sake of brevity we'll only cover the most important functions in the &lt;code&gt;main.js&lt;/code&gt; file of this program.&lt;/p&gt;

&lt;h4&gt;
  
  
  Developing the GUI:
&lt;/h4&gt;

&lt;p&gt;So let's start out by covering some rendering functions:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function RenderTapePointer() {
    // center the sprite's anchor point
    tape_pointer.anchor.set(0.5);
    // move the sprite to the center of the screen
    tape_pointer.x = app.screen.width / 2 - 45;
    tape_pointer.y = (app.screen.height / 2) + 150;
    tape_pointer.width = 30;
    tape_pointer.height = 30;

    app.stage.addChild(tape_pointer);
}

function RenderTapeWPixi() {
    firstTapeSquare = new PIXI.Text("1", { fontName: "foo" });
    secondTapeSquare = new PIXI.Text("0", { fontName: "foo" });
    thirdTapeSquare = new PIXI.Text("0", { fontName: "foo" });
    fourthTapeSquare = new PIXI.Text("1", { fontName: "foo" });
    fifthTapeSquare = new PIXI.Text("0".toString(), { fontName: "foo" });
    sixthTapeSquare = new PIXI.Text("0", { fontName: "foo" });
    seventhTapeSquare = new PIXI.Text("1", { fontName: "foo" });

    tapeSquaresArr = [firstTapeSquare, secondTapeSquare, thirdTapeSquare, fourthTapeSquare, fifthTapeSquare, sixthTapeSquare, seventhTapeSquare];

    const style = new PIXI.TextStyle();

    for (var i = 0; i &amp;lt; 7; i++) {
        // Apply the font to our text
        style.x = app.screen.width / 2;
        style.y = app.screen.height / 2;
        console.log(app.screen.height / 2);
        tapeSquaresArr[i].x = (app.screen.width - 100) / 2 + (i * 25);
        tapeSquaresArr[i].y = 400;

        // Update the font style
        style.fill = 'black';

        // Update text
        tapeSquaresArr[i].updateText();

        app.stage.addChild(tapeSquaresArr[i])
    }
}

function RenderStateText() {
    stateText.x = 50;
    stateText.y = 400;

    stateText.width = 100;
    stateText.height = 50;

    app.stage.addChild(stateText);

    stateValText.x = 170;
    stateValText.y = 400;
    stateValText.width = 50;
    stateValText.height = 50;

    app.stage.addChild(stateValText);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here is a brief explanation for the functions above:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;RenderTapePointer()&lt;/code&gt;: This function's main job is to render the tape pointer that will indicate the current tape square that the program is computing. All image objects in the Pixi.js rendering library are called &lt;a href="https://pixijs.download/dev/docs/PIXI.Sprite.html"&gt;Sprites&lt;/a&gt;. Notice the &lt;code&gt;app.stage.addChild(tape_pointer)&lt;/code&gt; line which is responsible for showing the Sprite on-screen by adding it to the Pixi.js &lt;a href="https://api.pixijs.io/@pixi/layers/Stage.html"&gt;Stage&lt;/a&gt; object. Here is a screenshot of the tape pointer:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hiqKihv6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0xo184s3s813qmi52aow.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hiqKihv6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0xo184s3s813qmi52aow.png" alt="Figure 4: Tape pointer pointing to the current tape square" width="359" height="167"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Figure 3: Tape pointer pointing to the current tape square&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;RenderTapeWPixi()&lt;/code&gt;: This function renders the actual tape that will be used by the Turing Machine. Since the Turing Machine is setup to run a Palindrome program, having a finite length of tape is feasible. Here is a screenshot of the tape containing some predefined values:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--zMa6Wh_z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h7abglxc59ypk1hvjsyv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--zMa6Wh_z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h7abglxc59ypk1hvjsyv.png" alt="Figure 5: Tape containing seven binary values" width="274" height="53"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Figure 4: Tape containing seven binary values&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;RenderStateText()&lt;/code&gt;: This function renders the text that indicates the current state of the Turing Machine. The current state of the machine is important because it influences the selecting of the new symbol to be placed in the currently selected tape square. For example: If the current state is &lt;code&gt;0&lt;/code&gt; and the current symbol is &lt;code&gt;1&lt;/code&gt; then the new symbol that will be written into the current tape square is &lt;code&gt;_&lt;/code&gt;(This is based on the state rules that we will cover soon). Here is a screenshot of the rendered state text:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--D9bvdf6u--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gar7xjad8aqzz8ialgle.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--D9bvdf6u--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gar7xjad8aqzz8ialgle.png" alt="Figure 6: Current state text rendered to the stage" width="293" height="97"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Figure 5: Current state text rendered to the stage&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Next we'll cover the functions that render the buttons and title for the application:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var startBtn = PIXI.Sprite.from("./assets/start-icon.png")
startBtn.buttonMode = true;
startBtn.anchor.set(0.5);
startBtn.position.x = 200;
startBtn.position.y = 150;
startBtn.width = 50;
startBtn.height = 50;
startBtn.interactive = true;
startBtn.on('mousedown', startPalindromeProgram);
app.stage.addChild(startBtn);

var restartBtn = PIXI.Sprite.from("./assets/restart-icon-v2.png")
restartBtn.buttonMode = true;
restartBtn.anchor.set(0.5);
restartBtn.position.x = 200;
restartBtn.position.y = 150;
restartBtn.width = 50;
restartBtn.height = 50;
restartBtn.interactive = true;
restartBtn.on('mousedown', restartPalindromeProgram);
app.stage.addChild(restartBtn);
restartBtn.visible = false;

var stopBtn = PIXI.Sprite.from("./assets/stop-icon.png")
stopBtn.buttonMode = true;
stopBtn.anchor.set(0.5);
stopBtn.position.x = 400;
stopBtn.position.y = 150;
stopBtn.width = 50;
stopBtn.height = 50;
stopBtn.interactive = true;
stopBtn.on('mousedown', stopProgram);
app.stage.addChild(stopBtn);

var resumeBtn = PIXI.Sprite.from("./assets/resume-icon.png")
resumeBtn.buttonMode = true;
resumeBtn.anchor.set(0.5);
resumeBtn.position.x = 600;
resumeBtn.position.y = 150;
resumeBtn.width = 50;
resumeBtn.height = 50;
resumeBtn.interactive = true;
resumeBtn.on('mousedown', resumeProgram);
app.stage.addChild(resumeBtn);

var moveTapeInterval = null;

function stopProgram() {
    moveTapeInterval.pause();
    toggleGameSpeedSliderVisible(true);
}

function resumeProgram() {
    moveTapeInterval.resume(gameSpeed);
    toggleGameSpeedSliderVisible(false);
}

function restartPalindromeProgram() {
    ResetGame();
    StartTape();
    restartBtn.visible = false;
    restartBtnLabel.visible = false;
}

...

const title = new PIXI.Text('Palindrome Program Turing Machine', {
    fill: '#272d37',
    fontFamily: 'Roboto',
    fontSize: 20,
    align: 'center',
});
title.roundPixels = true;
title.x = stageWidth / 2;
title.y = 40;
title.anchor.set(0.5, 0);
app.stage.addChild(title);

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

&lt;/div&gt;



&lt;p&gt;Here is a brief explanation of the code above:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;startBtn&lt;/code&gt;: This button controls the start of the Palindrome program. Notice the eventlistener &lt;code&gt;'mousedown'&lt;/code&gt; which makes starting the Palindrome program possible&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;restartBtn&lt;/code&gt;: This button allows the user to restart the Palindrome program once it has reached the end state. It is not shown in the initial startup of the application&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;stopBtn&lt;/code&gt;: This button pauses the Palindrome program. It is useful for adjusting the game speed which can only be changed when the game is paused.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;resumeBtn&lt;/code&gt;: This button allows the user to resume the game after being paused. Clicking it also makes the game speed slider disappear in order to prevent the user from changing the game speed while the program is running&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here are screenshots showing all four buttons:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--KVAaRPzD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vzc3o9dbp5io7fwh0m29.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--KVAaRPzD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vzc3o9dbp5io7fwh0m29.png" alt="Figure 7: The start, pause and resume buttons on display" width="727" height="240"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--yKzUUv9W--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y5g6rdj4kol1l0j0en3t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--yKzUUv9W--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y5g6rdj4kol1l0j0en3t.png" alt="Figure 8: The restart button on display" width="771" height="180"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Figure 6: The start, pause, resume and restart buttons on display&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Lastly the &lt;code&gt;title&lt;/code&gt; variable is an instance of &lt;a href="https://pixijs.download/dev/docs/PIXI.Text.html"&gt;&lt;code&gt;PIXI.Text()&lt;/code&gt;&lt;/a&gt;, which is used to create a title for the application on the top of the game screen.&lt;/p&gt;

&lt;h4&gt;
  
  
  Developing the internal logic:
&lt;/h4&gt;

&lt;p&gt;Moving onto the internal logic for the application, let's start out by defining the state rules for the Palindrome program:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var palindromePrgStateRules = [
    // [&amp;lt;current_state&amp;gt;, &amp;lt;current_symbol&amp;gt;, &amp;lt;new_symbol&amp;gt;, &amp;lt;direction&amp;gt;, &amp;lt;new_state&amp;gt;]
    ['0', '0', '_', 'r', '1o'],
    ['0', '1', '_', 'r', '1i'],
    ['0', '_', '_', '*', 'accept'],
    ['0', '1', '_', 'r', '1o'],
    ['1i', '_', '_', 'l', '2i'],
    ['1i', '*', '*', 'r', '1i'],
    ['1o', '*', '*', 'r', '1o'],
    ['1o', '_', '_', 'l', '2o'],
    ['2o', '0', '_', 'l', '3'],
    ['2o', '_', '_', '*', 'accept'],
    ['2o', '*', '*', '*', 'reject'],
    ['2i', '1', '_', 'l', '3'],
    ['2i', '_', '_', '*', 'accept'],
    ['2i', '*', '*', '*', 'reject'],
    ['3', '_', '_', '*', 'accept'],
    ['3', '*', '*', 'l', '4'],
    ['4', '*', '*', 'l', '4'],
    ['4', '_', '_', 'r', '0'],
    ['accept', '*', ':', 'r', 'accept2'],
    ['accept2', '*', ')', '*', 'halt-accept'],
    ['reject', '_', ':', 'r', 'reject2'],
    ['reject', '*', '_', 'l', 'reject'],
    ['reject2', '*', ')', '*', 'halt-reject'],
];
var comparisonValues = {
    "0": ["0", "*"],
    "1": ["1", "*"],
    "*": ["0", "1", "*"],
    " ": ["_"],
    "_": ["_"],
    ")": [")"]
}

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

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;palindromePrgStateRules&lt;/code&gt; 2d array is an array containing array elements, each with 5 strings in them to represent the following rules:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The first element represents the current state value of the program&lt;/li&gt;
&lt;li&gt;The second element represents the current symbol that the tape pointer is pointing to&lt;/li&gt;
&lt;li&gt;The third element represents the new symbol that should take the place of the current symbol(second element)&lt;/li&gt;
&lt;li&gt;The fourth element represents the direction that the tape pointer should take for its next move. &lt;code&gt;'l'&lt;/code&gt; means move to the left, &lt;code&gt;'r'&lt;/code&gt; means move to the right.&lt;/li&gt;
&lt;li&gt;The fifth and final element represents the new state value that should take the place of the current state value(first element)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Finally, the &lt;code&gt;comparisonValues&lt;/code&gt; object serves as a comparison reference for the current symbol that the tape pointer is pointing to and the values that are considered equivalent comparisons to it. For example: if the current symbol is &lt;code&gt;1&lt;/code&gt; then the compatible equivalents to it are &lt;code&gt;'1'&lt;/code&gt; and &lt;code&gt;'*'&lt;/code&gt;(based on the line &lt;code&gt;"1": ["1", "*"],&lt;/code&gt;). This object is very useful in deciding the appropriate next symbol to assign for a given square that the tape pointer is pointing to.&lt;/p&gt;

&lt;p&gt;Next, let's cover the functions responsible for starting the Palindrome program:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function startPalindromeProgram() {
    renderTapePointer();
    renderTapeWPixi();
    renderStateText();
    startTape();
    toggleStartBtnVisible(false);
    toggleGameSpeedSliderVisible(false);
    startBtnLabel.visible = false;
}

...

function startTape() {
    moveTapeInterval = new IntervalTimer(moveTapeLogic, gameSpeed);
    moveTapeInterval.start();
}

function moveTapeLogic() {
    var moveTapeDirection = ProcessInput();
    var counter = 0;
    console.log("moveTapeDirection: " + moveTapeDirection);
    switch (moveTapeDirection) {
        case "r":
            tape_pointer.x += 25;
            currentHeadIndex++;
            break;
        case "l":
            tape_pointer.x -= 25;
            currentHeadIndex--;
            break;
        case "halt-reject":
            clearInterval(moveTapeInterval);
            moveTapeInterval.clear();
            toggleRestartButton(true);
            break;
        default:
            break;
    }
    counter++;
}

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

&lt;/div&gt;



&lt;p&gt;Here is a brief explanation for the two functions above:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;startPalindromeProgram()&lt;/code&gt;: This the main starting function for the whole program. It calls the rendering functions to render the necessary elements on screen, hides the start button and game slider, and finally calls the &lt;code&gt;startTape()&lt;/code&gt; function.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;startTape()&lt;/code&gt;: This function starts the program by using the &lt;code&gt;IntervalTime&lt;/code&gt; class to setup an interval. You might be wondering the purpose of using the &lt;code&gt;IntervalTimer&lt;/code&gt; class instead of the more convenient &lt;code&gt;setTimeout()&lt;/code&gt; function. Well here it is: &lt;code&gt;IntervalTimer&lt;/code&gt; allows for the ability to pause, resume and clear the currently running interval by calling those respective methods.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;moveTapeLogic()&lt;/code&gt;: This function can be considered the controller for this application because it identifies the output received by calling the &lt;code&gt;ProcessInput()&lt;/code&gt; function. The output signifies the direction that the tape pointer should move next to, and this logic is handled by the switch statement in this function. The way the tape pointer's position is represented programmatically is via the &lt;code&gt;currentHeadIndex&lt;/code&gt; variable. When the tape pointer is moved one square to the right this variable is incremented by one, and when the tape pointer is moved to the left &lt;code&gt;currentHeadIndex&lt;/code&gt; is decremented by one. The ending state is reached when a output of &lt;code&gt;halt-reject&lt;/code&gt; is received from &lt;code&gt;ProcessInput()&lt;/code&gt;. The &lt;code&gt;setInterval()&lt;/code&gt; function underlying &lt;code&gt;moveTapeInterval&lt;/code&gt; is cleared, which brings the program to an end.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Next we'll cover the main processing function for this application:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function ProcessInput() {
    var i = 0;
    var foundMatch = false;
    for (i = 0; i &amp;lt; palindromePrgStateRules.length; i++) {

        var textComparison = null;
        var currentTapeVal = null;
        if (currentHeadIndex &amp;gt;= tapeSquaresArr.length) {
            textComparison = compareTapeValues(" ", palindromePrgStateRules[i][1]);
            currentTapeVal = " ";
        } else {
            textComparison = compareTapeValues(tapeSquaresArr[currentHeadIndex].text, palindromePrgStateRules[i][1]);
            currentTapeVal = tapeSquaresArr[currentHeadIndex].text;
        }

        if (textComparison &amp;amp;&amp;amp; currentState == palindromePrgStateRules[i][0]) {
            var newTapeSymbol = setNewTapeSymbol(currentTapeVal, palindromePrgStateRules[i][2]);

            try {
                tapeSquaresArr[currentHeadIndex].text = newTapeSymbol;
                tapeSquaresArr[currentHeadIndex].updateText();
            } catch (err) {
                console.log("current head index is empty");
            }

            currentState = palindromePrgStateRules[i][4];
            stateValText.text = palindromePrgStateRules[i][4];
            foundMatch = true;
            break;
        }
    }
    if (foundMatch) {
        return palindromePrgStateRules[i][3];
    } else {
        return "halt-reject";
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;ProcessInput()&lt;/code&gt; function performs the following steps in determining the next action to take when presented with the current input symbol. That is, the current tape symbol that the tape pointer is pointing to.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;It loops over the &lt;code&gt;palindromePrgStateRules&lt;/code&gt; array in order to find a matching element for the current state of the game. For example: if the current state value is &lt;code&gt;2i&lt;/code&gt; and the current tape symbol is &lt;code&gt;1&lt;/code&gt; then the element &lt;code&gt;['2i', '1', '_', 'l', '3']&lt;/code&gt; matches this criteria.&lt;/li&gt;
&lt;li&gt;Following the example in the previous step: the new symbol for the tape square is set to &lt;code&gt;_&lt;/code&gt;, the tape pointer is moved one position to the left, and the state value is change from &lt;code&gt;2i&lt;/code&gt; to &lt;code&gt;3&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;In the event that a matching element in the &lt;code&gt;palindromePrgStateRules&lt;/code&gt; array is not found to match the current state of the program, the &lt;code&gt;halt-reject&lt;/code&gt; value is returned by the function and the program is bought to the end state.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Let's quickly look at the function for comparing the current input symbol to a given input symbol in the &lt;code&gt;palindromePrgStateRules&lt;/code&gt; array:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function compareTapeValues(currentHeadVal, stateCurrentSymbolVal) {
    if ((currentState == "accept" || currentState == "accept2") &amp;amp;&amp;amp; currentHeadVal == "_") {
        return true;
    }
    if (comparisonValues[currentHeadVal.toString()].includes(stateCurrentSymbolVal.toString())) {
        return true;
    } else {
        return false;
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above function uses the &lt;code&gt;comparisonValues&lt;/code&gt; object that we defined earlier in determining whether &lt;code&gt;currentHeadVal&lt;/code&gt; and &lt;code&gt;stateCurrentSymbolVal&lt;/code&gt; match. Keep in mind that the symbol: &lt;code&gt;*&lt;/code&gt; that is found in some elements of &lt;code&gt;palindromePrgStateRules&lt;/code&gt; means that the &lt;code&gt;currentHeadVal&lt;/code&gt; gets a free pass; it will match up to any given &lt;code&gt;currentHeadVal&lt;/code&gt; value. Another condition that is considered a match is when the current state value is set to &lt;code&gt;accept&lt;/code&gt; and &lt;code&gt;currentHeadVal&lt;/code&gt; is &lt;code&gt;_&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Now let's visit the function responsible for restarting the program if the user wants to run it once more:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function resetGame() {
    // Reset tape numbers to defaults
    const tapeNumDefaults = ["1", "0", "0", "1", "0", "0", "1"];

    for (var i = 0; i &amp;lt; tapeSquaresArr.length; i++) {
        // Apply the font to our text
        tapeSquaresArr[i].text = tapeNumDefaults[i];

        // Update text
        tapeSquaresArr[i].updateText();
    }

    // Reset tape pointer to default position
    tape_pointer.x = app.screen.width / 2 - 45;
    tape_pointer.y = (app.screen.height / 2) + 150;

    // Reset current head index and current state variables to 0
    currentHeadIndex = 0;
    currentState = '0';

    toggleStartBtnVisible(false);
    toggleGameSpeedSliderVisible(false);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;resetGame()&lt;/code&gt; function resets the main state variables in the program(&lt;code&gt;currentHeadIndex&lt;/code&gt;, &lt;code&gt;currentState&lt;/code&gt;) to their default values along with changing the tape square symbols back to their default values and moving the tape pointer sprite back to its starting position. Finally, the start button and the game slider is hidden. The restart button will be displayed in place of the start button, which gives the user the option to restart the Palindrome program.&lt;/p&gt;

&lt;p&gt;That brings the development section of this blog post to a close.&lt;/p&gt;

&lt;p&gt;If you made it this far then congratulations! You have a pretty good idea of how this application functions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Program Demo:
&lt;/h2&gt;

&lt;p&gt;Here is a gif showing a demonstration of this program:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://imgur.com/a/9ZvAFAH"&gt;Game demonstration link on Imgur&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;Thanks for reading this blog post!&lt;/p&gt;

&lt;p&gt;If you have any questions or concerns feel free to post a comment in this post and I will get back to you if I find the time.&lt;/p&gt;

&lt;p&gt;If you found this article helpful feel free share it and make sure to follow me on &lt;a href="https://twitter.com/SeanAtukorala"&gt;Twitter &lt;/a&gt;and &lt;a href="https://github.com/ShehanAT"&gt;GitHub&lt;/a&gt;, connect with me on &lt;a href="https://www.linkedin.com/in/shehan-atukorala-8631491a5/"&gt;LinkedIn&lt;/a&gt; and subscribe to my &lt;a href="https://www.youtube.com/channel/UCtxed_NljgtAXrQMMdLvhrQ"&gt;YouTube channel&lt;/a&gt;.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Cross-validation in Machine Learning Explained</title>
      <dc:creator>Sean Atukorala</dc:creator>
      <pubDate>Fri, 11 Nov 2022 20:13:50 +0000</pubDate>
      <link>https://dev.to/shehanat/cross-validation-in-machine-learning-explained-4dhi</link>
      <guid>https://dev.to/shehanat/cross-validation-in-machine-learning-explained-4dhi</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Jxt6CZ6y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1wha249ltsip2ghjfzqm.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Jxt6CZ6y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1wha249ltsip2ghjfzqm.jpg" alt="Figure 1: Scenery of Newfoundland" width="880" height="587"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Cross-validation is a technique for evaluating machine learning models by training several machine learning models on subsets of the available input data and evaluating them on the complementary subset of the data.&lt;/p&gt;

&lt;p&gt;Basically, cross-validation is the practice of judging the performance and accuracy of a given machine learning model by using various different divisions of training and testing data, sometimes across multiple rounds of validation, and then finally aggregating the results to derive a highly accurate evaluation of the given machine learning model.&lt;/p&gt;

&lt;p&gt;In some types of cross-validation such as K Fold cross-validation, the subsets used for training purposes and the subset used for validating purposes are changed over multiple attempts in order to generate a more accurate conclusion about the performance of the given machine learning model.&lt;/p&gt;

&lt;p&gt;While the main benefit of cross-validation is to test the ability of a machine learning model to predict new data, it is also very effective in detecting &lt;a href="https://www.ibm.com/cloud/learn/overfitting"&gt;overfitting&lt;/a&gt; and &lt;a href="https://c3.ai/glossary/machine-learning/selection-bias/"&gt;selection bias&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Cross-validation allows us to compare the results of various machine learning models and get a sense of how well each one of them will work in practice.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8IXZllnk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9r9gewyb4vxsgnh7kccg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8IXZllnk--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9r9gewyb4vxsgnh7kccg.png" alt="Figure 2: General process of training models" width="411" height="376"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Figure 2: General process of training models&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  General process for Cross-validation:
&lt;/h3&gt;

&lt;p&gt;Although there are various different types of cross-validation all of them adhere to the following workflow listed below:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Divide the dataset into two different sections: the training section and the testing section&lt;/li&gt;
&lt;li&gt;Train the model using the training dataset&lt;/li&gt;
&lt;li&gt;Validate the model using the testing dataset&lt;/li&gt;
&lt;li&gt;Repeat steps 2 and 3. The exact number of repetitions depends on the specific type of cross-validation that you choose to use&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--d9ZhmX17--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4x68v3mewlowtla96l89.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--d9ZhmX17--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4x68v3mewlowtla96l89.png" alt="Figure 3: General process of Cross-validation" width="880" height="224"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Figure 3: General process for Cross-validation&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Different types of Cross-validation:
&lt;/h3&gt;

&lt;p&gt;There are numerous types of cross-validation. Here are brief descriptions of the most common ones:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;K-fold cross-validation: This type of cross-validation divides the dataset into k number of groups and then proceeds with the general process of cross-validation.&lt;/li&gt;
&lt;li&gt;Hold-out cross-validation: Hold-out cross-validation divides the entire dataset randomly into a training set and a validation set. This type of cross-validation has the advantage of faster execution times since the dataset is split into only two sets, the training and validation sets, the model is build just one time&lt;/li&gt;
&lt;li&gt;Stratified k-fold cross-validation: This is considered identical to K-fold cross-validation with the addition that it seeks to make sure that each group has the same proportion of observations/samples with a given categorical value. This type of cross-validation is highly useful when dealing with &lt;a href="https://developers.google.com/machine-learning/data-prep/construct/sampling-splitting/imbalanced-data"&gt;imbalanced datasets&lt;/a&gt;. Keep in mind that Stratified K Fold cross-validation is not suitable to handle time series data since the samples are selected in random order&lt;/li&gt;
&lt;li&gt;Leave-p-out cross-validation: In this type of cross-validation there are P number of data points used as test set data while the remainder of the data points are used for training purposes. Its advantage is that it uses the whole dataset for both training and testing and therefore provides much less biased results, but it is not suitable for use with large datasets as it can be very time-consuming and computationally expensive to do so&lt;/li&gt;
&lt;li&gt;Monte Carlo(shuffle-split) cross-validation: This type of cross-validation splits the dataset randomly into training and testing sets. The number of cross-validation iterations are not fixed but are decided by analysis. In contrast to K Fold cross-validation where you use one fold as the test set and the remaining folds as the training set, shuffle-split uses a specific training and test set from iteration &lt;code&gt;n&lt;/code&gt; for each round &lt;code&gt;n&lt;/code&gt;(More on this in these Stack OverFlow answers: &lt;a href="https://stackoverflow.com/a/70599003/10871450"&gt;link1&lt;/a&gt;, &lt;a href="https://stackoverflow.com/a/34731698/10871450"&gt;link2&lt;/a&gt;). Shuffle-split is a good cross-validation technique for large datasets but is not suitable for imbalanced datasets&lt;/li&gt;
&lt;li&gt;Time series(rolling) cross-validation: In this type of cross-validation the test set consists of only a single observation/sample. In contrast, the training set consists of the cumulative observations/samples that are encountered before the observation/sample that is used as the test set. When initially starting the cross-validation process, the test set is not a reliable predictor because the model is based on a small training set. Therefore, in order to leverage the full power of time series cross-validation: only when the test set is based on later observations/samples should validation for the model's accuracy be conducted.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Advantages and Disadvantages of Cross-validation:
&lt;/h3&gt;

&lt;p&gt;Overall, I believe that there are more advantages to cross-validation than disadvantages.&lt;/p&gt;

&lt;p&gt;Some pros of cross-validation include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Minimizes overfitting issues: This is accomplished by splitting the dataset into multiple sections and training the model on constantly differing sections. Doing so increases the robustness of the model and therefore reduces overfitting as well&lt;/li&gt;
&lt;li&gt;Increases efficiency of data usage: This is because almost all the observations/samples in the dataset are used for both training and testing purposes&lt;/li&gt;
&lt;li&gt;Model accuracy tends to increases: This is due to all the data in the dataset(or almost all of it) being utilized to train the model&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here are some disadvantages of cross-validation:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Expensive computational cost: Due to the increased demand of using multiple folds of the dataset for training and testing purposes, computational cost inevitably increases.&lt;/li&gt;
&lt;li&gt;High training time: Due to having to train a model on multiple training sets, using cross-validation can incur higher than average training times&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;That's it for this blog post on Cross-validation.&lt;/p&gt;

&lt;p&gt;Thanks for reading this blog post!&lt;/p&gt;

&lt;p&gt;If you have any questions or concerns please feel free to post a comment in this post and I will get back to you if I find the time.&lt;/p&gt;

&lt;p&gt;If you found this article helpful please share it and make sure to follow me on &lt;a href="https://twitter.com/SeanAtukorala"&gt;Twitter &lt;/a&gt;and &lt;a href="https://github.com/ShehanAT"&gt;GitHub&lt;/a&gt;, connect with me on &lt;a href="https://www.linkedin.com/in/shehan-atukorala-8631491a5/"&gt;LinkedIn&lt;/a&gt; and subscribe to my &lt;a href="https://www.youtube.com/channel/UCtxed_NljgtAXrQMMdLvhrQ"&gt;YouTube channel&lt;/a&gt;.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>K-Nearest Algorithm in Machine Learning Explained</title>
      <dc:creator>Sean Atukorala</dc:creator>
      <pubDate>Sat, 22 Oct 2022 20:46:49 +0000</pubDate>
      <link>https://dev.to/shehanat/k-nearest-algorithm-in-machine-learning-explained-5dl</link>
      <guid>https://dev.to/shehanat/k-nearest-algorithm-in-machine-learning-explained-5dl</guid>
      <description>&lt;p&gt;Ever wondered what the K-NN Algorithm is? If so, keep reading to find out!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--nh4mm2DK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wbolid3rnw8qqzmc48g7.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--nh4mm2DK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wbolid3rnw8qqzmc48g7.jpg" alt="Figure 1: Scenery from Banff Park in Canada" width="880" height="583"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;First let's go over the two types of machine learning algorithms in machine learning:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Supervised&lt;/strong&gt;: This type of machine learning uses labeled datasets to train models in order to classify data and predict outcomes accurately. This type of learning is useful in predicting outputs or outcomes for new and unseen data on the basis of prior experiences. Some practical examples include classifying images, words or file types. Supervised machine learning is useful when you know what you're looking for in a given dataset&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Unsupervised&lt;/strong&gt;: This is a type of machine learning in which machine learning models learn patterns through untagged and unlabeled data. The model analyses the data in order to find previously unknown patterns in the data. It can also be useful in finding features, which are independant variables that serve as input for a system, which is very useful in conducting categorization. Some practical examples include data exploration and social media recommendation systems, target marketing campaigns. Unsupervised machine learning is useful when you don't know what you're looking for in a given dataset&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Basic Overview of K-Nearest Neighbors algorithms
&lt;/h2&gt;

&lt;p&gt;K-Nearest Neighbors algorithms are considered to be one of the simplest Machine Learning algorithms that falls into the Supervised algorithms category.&lt;/p&gt;

&lt;p&gt;K-Nearest Neighbors algorithms operate on the basic assumption that closely similar things exist in closer proximity to each other that more dissimilar things. With this initial assumption, the K-NN algorithm will place new unseen data into a category that is most similar to the available categories.&lt;/p&gt;

&lt;p&gt;The K-NN algorithm is considered a &lt;a href="https://en.wikipedia.org/wiki/Lazy_learning"&gt;lazy learning&lt;/a&gt; type of algorithm because it doesn't immediately learn from the training data assigned to it. Instead, it merely stores the training data and at the time of needing to classify new and unseen data, it places that data into a category that is the most similar to the new data.&lt;/p&gt;

&lt;p&gt;The K-NN algorithm is known as an ad-hoc classifier that is used to classify test data based on distance metrics(such as Euclidean, Chebyshev, Cosine, etc)&lt;/p&gt;

&lt;p&gt;K-NN algorithms can be used for both types of Supervised Machine Learning categories: Regression and Classification. Despite this flexibility, it is mostly used for classification ML problems.&lt;/p&gt;

&lt;p&gt;Here are some pros and cons of the K-Nearest Neighbors algorithms:&lt;/p&gt;

&lt;h4&gt;
  
  
  Pros:
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;It is relatively easy and straight forward to setup&lt;/li&gt;
&lt;li&gt;It handles noisy training data pretty well, meaning it predicts accurately despite there being noisy data in the training set. &lt;a href="https://deepchecks.com/glossary/noise-in-machine-learning/"&gt;Noise&lt;/a&gt; in this context refers to inaccurate data as a result of human error in the data collection process for the dataset being used&lt;/li&gt;
&lt;li&gt;It is efficient and effective at using large training sets in the prediction process&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Cons:
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;The value of K always needs to be calculated prior to making any predictions. This can get quite tedious and complex at times&lt;/li&gt;
&lt;li&gt;Since the distance between all the training set data points in relation to each other have to be calculated the &lt;a href="https://mathoverflow.net/questions/400840/what-is-the-computational-cost-in-a-neural-network#:~:text=Computational%20cost%20is%20simply%20a,train%20or%20use%20an%20NN."&gt;computational cost&lt;/a&gt; can get quite high at times&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Basic flow of KNN
&lt;/h2&gt;

&lt;p&gt;The following list of steps provides a general overview of how the KNN algorithm works:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Load and split the data into train and test sets&lt;/li&gt;
&lt;li&gt;Pick a value for K. Look for the section below for a more in-depth explanation on how to do so&lt;/li&gt;
&lt;li&gt;In order to generate a prediction, do the following steps for all iterations from 1 to the total number of training data points:

&lt;ol&gt;
&lt;li&gt;First, calculate the distance between the test data and each row of training data. The distance metric to be used can be any of the following: Euclidean, Chebyshev, Cosine, Manhattan, Minkowski, Jaccard, etc&lt;/li&gt;
&lt;li&gt;Sort the calculated distances in ascending order based on distance values&lt;/li&gt;
&lt;li&gt;Get the number of rows equal to the value of k from the top of the sorted array. Ex: if k = 4, then get the top 4 rows from the sorted array&lt;/li&gt;
&lt;li&gt;Get the most frequent category of the rows selected in step 3&lt;/li&gt;
&lt;li&gt;Return the most frequent category as the predicted category for the current training data point&lt;/li&gt;
&lt;/ol&gt;


&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Picking a value for K
&lt;/h2&gt;

&lt;p&gt;The value of K in the K-NN algorithm indicates the count of the nearest neighbors.&lt;/p&gt;

&lt;p&gt;The value of K should optimally be a number that is not too small and not too large. Choosing a value of K that is too small leads to unstable decision boundaries and &lt;a href="https://www.ibm.com/cloud/learn/overfitting"&gt;overfitting&lt;/a&gt; problems. Meanwhile, having a value of k that is too large can lead to &lt;a href="https://www.ibm.com/cloud/learn/underfitting"&gt;underfitting&lt;/a&gt; problems.&lt;br&gt;
It is also important to note that the value of k is non-parametric, meaning it does not rely on any assumptions about the shape or parameters of the dataset from which the training data was drawn.&lt;/p&gt;

&lt;p&gt;First of all, keep in mind that there is no definite way to pick the best value for K. The most practical and widely-used strategy to use trail and error to find an optimal K value. To do this, you have to pretend that part of your training data is "unknown".&lt;/p&gt;

&lt;p&gt;Alternatively, you can use this general rule of thumb for choosing the best value of k using this following formula:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;k = sqrt(N)/2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Where &lt;code&gt;N&lt;/code&gt; stands for the number of rows in the training set.&lt;br&gt;&lt;br&gt;
It also might help to keep the value of k to an odd number so as to not create any stalemate/tie situations, arising from choosing a class/category.&lt;/p&gt;

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

&lt;p&gt;Thanks for reading this blog post!&lt;/p&gt;

&lt;p&gt;If you have any questions or concerns please feel free to post a comment in this post and I will get back to you if I find the time.&lt;/p&gt;

&lt;p&gt;If you found this article helpful please share it and make sure to follow me on &lt;a href="https://twitter.com/SeanAtukorala"&gt;Twitter &lt;/a&gt;and &lt;a href="https://github.com/ShehanAT"&gt;GitHub&lt;/a&gt;, connect with me on &lt;a href="https://www.linkedin.com/in/shehan-atukorala-8631491a5/"&gt;LinkedIn&lt;/a&gt; and subscribe to my &lt;a href="https://www.youtube.com/channel/UCtxed_NljgtAXrQMMdLvhrQ"&gt;YouTube channel&lt;/a&gt;.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Logistic Regression in Machine Learning Explained</title>
      <dc:creator>Sean Atukorala</dc:creator>
      <pubDate>Wed, 05 Oct 2022 18:55:47 +0000</pubDate>
      <link>https://dev.to/shehanat/logistic-regression-in-machine-learning-explained-3mim</link>
      <guid>https://dev.to/shehanat/logistic-regression-in-machine-learning-explained-3mim</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%2Fw8jpbudxjnutnfp7s2er.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%2Fw8jpbudxjnutnfp7s2er.jpg" alt="Figure 1: Autumn Scenery of a house amist trees with leaves"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;Logistic regression is a type of machine learning model. From the two types of machine learning models(regression and classification), it is a classification algorithm even though the name would indicate it to be a regression model.&lt;/p&gt;

&lt;p&gt;It derives its name from the logistic function, which is a type of exponential function. This function is characterized by a S-shaped curve(also known as a sigmoid curve).&lt;/p&gt;

&lt;p&gt;Accordingly, logistic regression models produce S-shaped curves when plotted on graphs, like so:&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%2Fkwh1urtyv27sopvcbkt2.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%2Fkwh1urtyv27sopvcbkt2.png" alt="Figure 2: Logistic Regression Model when graphed"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Figure 2: Logistic Regression Model when graphed&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Here are important points about Logistic Regression:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Logistic Regression is intended for classification ML problems that have a single binary output variable. Machine learning problems with any other type of output variable/(s) should not use Logistic Regression for predictive modelling purposes&lt;/li&gt;
&lt;li&gt;Logistic Regression algorithms are similar to Linear Regression algorithms in that they both are predictive analysis algorithms but with Logistic Regression using the more complex Sigmoid function instead of relatively simple linear funtions&lt;/li&gt;
&lt;li&gt;Whereas linear regression produces numeric output values, logistic regression produces binary output values(0 or 1)&lt;/li&gt;
&lt;li&gt;Although logistic regression is technically a classification algorithm, it does predict probabilities in a regression algorithm sense. Its just that the probability is then converted into a binary value(0 or 1)&lt;/li&gt;
&lt;li&gt;Logistic regression uses another machine learning algorithm: &lt;a href="https://en.wikipedia.org/wiki/Maximum_likelihood_estimation" rel="noopener noreferrer"&gt;Maximum-likelihood estimation&lt;/a&gt; in order to estimate the coefficients(Beta values b) for logistic regression from the training data available&lt;/li&gt;
&lt;li&gt;Logistic regression and linear regression share the same method of data preparation&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Example of Logistic Regression In R
&lt;/h2&gt;

&lt;p&gt;Here is a code snippet in the R programming language that demostrates the use of the Logistic Regression Model:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;library(ggplot2)
library(cowplot)

url &amp;lt;- "http://archive.ics.uci.edu/ml/machine-learning-databases/heart-disease/processed.cleveland.data"

data &amp;lt;- read.csv(url, header=FALSE)

...

logistic &amp;lt;- glm(hd ~ ., data = data, family = "binomial")

...

predicted.data &amp;lt;- data.frame(
  probability.of.hd=logistic$fitted.values,
  hd=data$hd)

predicted.data &amp;lt;- predicted.data[
  order(predicted.data$probability.of.hd, decreasing=FALSE),]
predicted.data$rank &amp;lt;- 1:nrow(predicted.data)

ggplot(data=predicted.data, aes(x=rank, y=probability.of.hd)) +
  geom_point(aes(color=hd)) +
  xlab("Index") +
  ylab("Predicted probability of getting heart disease")

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

&lt;/div&gt;



&lt;p&gt;The above code snippet is taken from &lt;a href="https://github.com/StatQuest" rel="noopener noreferrer"&gt;StatQuest with Josh Starmer &lt;/a&gt; and you can find the full version of this code in the this &lt;a href="https://github.com/StatQuest/logistic_regression_demo/blob/master/logistic_regression_demo.R" rel="noopener noreferrer"&gt;GitHub link&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, here is the graph that is produced by running the full version of the code snippet 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%2Ft32703yh1kefyrwu7dby.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%2Ft32703yh1kefyrwu7dby.png" alt="Figure 3: Logistic Regression graphed using the R programming language"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Figure 3: Logistic Regression graphed using the R programming language&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Here are some points of noteworthiness for the above graph:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The range of the Y-axis is always between 0 and 1 for Logistic Regression graphs. This is due to the dependant variable(Predicted probability of getting heart disease) being discrete&lt;/li&gt;
&lt;li&gt;The turquoise colored data points represent patients already having heart disease. The light red colored data points represent patients without any past history of heart disease&lt;/li&gt;
&lt;li&gt;The x-axis value 'Rank' is representative of the likelihood of each of the 297 patients in the &lt;code&gt;data.frame&lt;/code&gt; having heart disease, with a higher rank indicating a high likelihood of getting heart disease&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;That's it for this blog post on Logistic Regression in Machine Learning. I hope it was helpful!&lt;/p&gt;

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

&lt;p&gt;Thanks for reading this blog post!&lt;/p&gt;

&lt;p&gt;If you have any questions or concerns please feel free to post a comment in this post and I will get back to you if I find the time.&lt;/p&gt;

&lt;p&gt;If you found this article helpful please share it and make sure to follow me on &lt;a href="https://twitter.com/SeanAtukorala" rel="noopener noreferrer"&gt;Twitter &lt;/a&gt;and &lt;a href="https://github.com/ShehanAT" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;, connect with me on &lt;a href="https://www.linkedin.com/in/shehan-atukorala-8631491a5/" rel="noopener noreferrer"&gt;LinkedIn&lt;/a&gt; and subscribe to my &lt;a href="https://www.youtube.com/channel/UCtxed_NljgtAXrQMMdLvhrQ" rel="noopener noreferrer"&gt;YouTube channel&lt;/a&gt;.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>[Solved] Package xkbfile was not found in the pkg-config search path</title>
      <dc:creator>Sean Atukorala</dc:creator>
      <pubDate>Tue, 27 Sep 2022 18:27:08 +0000</pubDate>
      <link>https://dev.to/shehanat/solved-package-xkbfile-was-not-found-in-the-pkg-config-search-path-5497</link>
      <guid>https://dev.to/shehanat/solved-package-xkbfile-was-not-found-in-the-pkg-config-search-path-5497</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--MS4Q4_F3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8ftzbmkk4hou8czkgk5y.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--MS4Q4_F3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8ftzbmkk4hou8czkgk5y.jpg" alt="Figure 1: Beautiful Autumn Scenery" width="880" height="587"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Problem:
&lt;/h2&gt;

&lt;p&gt;Running into the following error when trying to build &lt;a href="https://github.com/microsoft/monaco-editor"&gt;monaco-editor&lt;/a&gt; from source(on the &lt;code&gt;yarn&lt;/code&gt; command step)on an Ubuntu VM:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Package xkbfile was not found in the pkg-config search path.
Perhaps you should add the directory containing `xkbfile.pc'
to the PKG_CONFIG_PATH environment variable
No package 'xkbfile' found
gyp: Call to '${PKG_CONFIG:-pkg-config} x11 xkbfile --cflags | sed s/-I//g' returned exit status 0 while in binding.gyp. while trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/home/sean/.nvm/versions/node/v16.17.0/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:261:16)
gyp ERR! stack     at ChildProcess.emit (node:events:513:28)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)
gyp ERR! System Linux 5.15.0-48-generic
gyp ERR! command "/home/sean/.nvm/versions/node/v16.17.0/bin/node" "/home/sean/.nvm/versions/node/v16.17.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/sean/Documents/JavaScriptApplications/vscode/node_modules/native-keymap
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Solution:
&lt;/h2&gt;

&lt;p&gt;This error should be resolved by installing the missing package like so:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt-get install libxkbfile-dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;Thanks for reading this blog post!&lt;/p&gt;

&lt;p&gt;If you have any questions or concerns please feel free to post a comment in this post and I will get back to you if I find the time.&lt;/p&gt;

&lt;p&gt;If you found this article helpful please share it and make sure to follow me on &lt;a href="https://twitter.com/SeanAtukorala"&gt;Twitter &lt;/a&gt;and &lt;a href="https://github.com/ShehanAT"&gt;GitHub&lt;/a&gt;, connect with me on &lt;a href="https://www.linkedin.com/in/shehan-atukorala-8631491a5/"&gt;LinkedIn&lt;/a&gt; and subscribe to my &lt;a href="https://www.youtube.com/channel/UCtxed_NljgtAXrQMMdLvhrQ"&gt;YouTube channel&lt;/a&gt;.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>[Solved] Package x11 was not found in the pkg-config search path</title>
      <dc:creator>Sean Atukorala</dc:creator>
      <pubDate>Tue, 27 Sep 2022 18:26:07 +0000</pubDate>
      <link>https://dev.to/shehanat/solved-package-x11-was-not-found-in-the-pkg-config-search-path-52cd</link>
      <guid>https://dev.to/shehanat/solved-package-x11-was-not-found-in-the-pkg-config-search-path-52cd</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--WpmbKKR4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l1wkoejx33lknlwbioyq.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--WpmbKKR4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l1wkoejx33lknlwbioyq.jpg" alt="Figure 1: Beautiful Autumn Scenery" width="880" height="587"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Problem:
&lt;/h2&gt;

&lt;p&gt;Running into the following error when trying to build &lt;a href="https://github.com/microsoft/monaco-editor"&gt;monaco-editor&lt;/a&gt; from source(on the &lt;code&gt;yarn&lt;/code&gt; command step) on an Ubuntu VM:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Package x11 was not found in the pkg-config search path.
Perhaps you should add the directory containing `x11.pc'
to the PKG_CONFIG_PATH environment variable
No package 'x11' found
Package xkbfile was not found in the pkg-config search path.
Perhaps you should add the directory containing `xkbfile.pc'
to the PKG_CONFIG_PATH environment variable
No package 'xkbfile' found
gyp: Call to '${PKG_CONFIG:-pkg-config} x11 xkbfile --cflags | sed s/-I//g' returned exit status 0 while in binding.gyp. while trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/home/sean/.nvm/versions/node/v16.17.0/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:261:16)
gyp ERR! stack     at ChildProcess.emit (node:events:513:28)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)
gyp ERR! System Linux 5.15.0-48-generic
gyp ERR! command "/home/sean/.nvm/versions/node/v16.17.0/bin/node" "/home/sean/.nvm/versions/node/v16.17.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/sean/Documents/JavaScriptApplications/vscode/node_modules/native-keymap
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Solution:
&lt;/h2&gt;

&lt;p&gt;This error should be resolved by installing the missing package like so:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt-get install libx11-dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;Thanks for reading this blog post!&lt;/p&gt;

&lt;p&gt;If you have any questions or concerns please feel free to post a comment in this post and I will get back to you if I find the time.&lt;/p&gt;

&lt;p&gt;If you found this article helpful please share it and make sure to follow me on &lt;a href="https://twitter.com/SeanAtukorala"&gt;Twitter &lt;/a&gt;and &lt;a href="https://github.com/ShehanAT"&gt;GitHub&lt;/a&gt;, connect with me on &lt;a href="https://www.linkedin.com/in/shehan-atukorala-8631491a5/"&gt;LinkedIn&lt;/a&gt; and subscribe to my &lt;a href="https://www.youtube.com/channel/UCtxed_NljgtAXrQMMdLvhrQ"&gt;YouTube channel&lt;/a&gt;.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>[Solved] Package libsecret-1 was not found in the pkg-config search path</title>
      <dc:creator>Sean Atukorala</dc:creator>
      <pubDate>Tue, 27 Sep 2022 18:25:07 +0000</pubDate>
      <link>https://dev.to/shehanat/solved-package-libsecret-1-was-not-found-in-the-pkg-config-search-path-4eli</link>
      <guid>https://dev.to/shehanat/solved-package-libsecret-1-was-not-found-in-the-pkg-config-search-path-4eli</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--sI1vPpSW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7nilpnemmopnrcli8d65.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--sI1vPpSW--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7nilpnemmopnrcli8d65.jpg" alt="Figure 1: Beautiful Autumn Scenery" width="880" height="550"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Problem:
&lt;/h2&gt;

&lt;p&gt;Running into the following error when trying to build &lt;a href="https://github.com/microsoft/monaco-editor"&gt;monaco-editor&lt;/a&gt; from source(on the &lt;code&gt;yarn&lt;/code&gt; command step) on an Ubuntu VM:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Package libsecret-1 was not found in the pkg-config search path.
Perhaps you should add the directory containing `libsecret-1.pc'
to the PKG_CONFIG_PATH environment variable
No package 'libsecret-1' found
gyp: Call to 'pkg-config --cflags libsecret-1' returned exit status 1 while in binding.gyp. while trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/home/sean/.nvm/versions/node/v16.17.0/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:261:16)
gyp ERR! stack     at ChildProcess.emit (node:events:513:28)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)
gyp ERR! System Linux 5.15.0-48-generic
gyp ERR! command "/home/sean/.nvm/versions/node/v16.17.0/bin/node" "/home/sean/.nvm/versions/node/v16.17.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/sean/Documents/JavaScriptApplications/vscode/node_modules/keytar
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Solution:
&lt;/h2&gt;

&lt;p&gt;This error should be resolved by installing the missing package like so:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt-get install libsecret-1-dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;p&gt;Thanks for reading this blog post!&lt;/p&gt;

&lt;p&gt;If you have any questions or concerns please feel free to post a comment in this post and I will get back to you if I find the time.&lt;/p&gt;

&lt;p&gt;If you found this article helpful please share it and make sure to follow me on &lt;a href="https://twitter.com/SeanAtukorala"&gt;Twitter &lt;/a&gt;and &lt;a href="https://github.com/ShehanAT"&gt;GitHub&lt;/a&gt;, connect with me on &lt;a href="https://www.linkedin.com/in/shehan-atukorala-8631491a5/"&gt;LinkedIn&lt;/a&gt; and subscribe to my &lt;a href="https://www.youtube.com/channel/UCtxed_NljgtAXrQMMdLvhrQ"&gt;YouTube channel&lt;/a&gt;.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Linear Regression in Machine Learning Explained</title>
      <dc:creator>Sean Atukorala</dc:creator>
      <pubDate>Sat, 24 Sep 2022 19:04:43 +0000</pubDate>
      <link>https://dev.to/shehanat/linear-regression-in-machine-learning-explained-2e86</link>
      <guid>https://dev.to/shehanat/linear-regression-in-machine-learning-explained-2e86</guid>
      <description>&lt;p&gt;Ever wonder what the terms Regression and Linear Regression mean in a machine learning context? If so, keep reading to find out!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--R1ZR0bCS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ebkqla13huiyvyjyhioj.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--R1ZR0bCS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ebkqla13huiyvyjyhioj.jpg" alt="Image of a Barn and Fence in Autumn" width="880" height="660"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Regression in Machine Learning?
&lt;/h2&gt;

&lt;p&gt;Regression is primarily a technique for analyzing the relationship between independent variables/features and a dependent variable/outcome. Regression is a method most frequently used to solve supervised machine learning problems.&lt;/p&gt;

&lt;p&gt;Regression modeling, which as the name implies uses regression, consists of building a mapping function such that input variables map to a continuous output variable. The input variables are independent and the continuous output variable is dependent in this case. This type of modelling is mainly useful in two ways: (1) To predict the outcome of new and unseen input data (2) To forecast and predict gaps in missing data.&lt;/p&gt;

&lt;h2&gt;
  
  
  What does Linear Regression mean in Machine Learning?
&lt;/h2&gt;

&lt;p&gt;Linear regression is a type of machine learning model. It is most easily explained as a linear equation that combines a specific set of input values, which are independent variables, to the predicted output value, which is a dependent variable.&lt;/p&gt;

&lt;p&gt;Although linear regression is originally a concept derived from the field of statistics, it is used extensively in machine learning for the purposes of understanding the relationship between independent input variables and a dependent output variable.&lt;/p&gt;

&lt;p&gt;There are many different types of linear regression, the most notable of which are simple linear regression(where there is only a single input variable) and multiple linear regression(where there are multiple input variables).&lt;/p&gt;

&lt;p&gt;The main points of differentiation between different types of linear regression are concerning the number of independent variables and the type of relationship between the independent and dependent variables.&lt;/p&gt;

&lt;p&gt;Linear regression can be defined as a simple linear equation due to the fact that ultimately, it is a line drawn across a set of data points that is designed to model those data points in the most accurately possible way.&lt;/p&gt;

&lt;p&gt;Here is what a linear equation looks like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;y = ax + c
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Where &lt;code&gt;a&lt;/code&gt; represents the slope of the line and the &lt;code&gt;c&lt;/code&gt; represents its y-intercept.&lt;/p&gt;

&lt;h2&gt;
  
  
  Example of Linear Regression:
&lt;/h2&gt;

&lt;p&gt;In order to better understand linear regression, let's go over an example. Here is a graph showing the heights of fathers in comparison to their sons:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--LruKJVCG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/urtdpi4vmcilu27adv7o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--LruKJVCG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/urtdpi4vmcilu27adv7o.png" alt="Figure 1: Comparison of fathers' heights to their sons" width="" height=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Figure 1: Comparison of fathers' heights to their sons&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Here is a code snippet using the R programming language that will calculate the linear regression line for the graph above:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;library(tidyverse)
library(HistData)
library(caret)

# Obtain the dataset data and rename the `childHeight` column to `son`
galton_heights &amp;lt;- GaltonFamilies %&amp;gt;%
  filter(childNum == 1 &amp;amp; gender == "male") %&amp;gt;%
  select(father, childHeight) %&amp;gt;%
  rename(son = childHeight)

y &amp;lt;- galton_heights$son
test_index &amp;lt;- createDataPartition(y, times = 1, p = 0.5, list = FALSE)

# Divide the original dataset into train and test sets
train_set &amp;lt;- galton_heights %&amp;gt;% slice(-test_index)
test_set &amp;lt;- galton_heights %&amp;gt;% slice(test_index)


# Fit linear regression model
fit &amp;lt;- lm(son ~ father, data = train_set)

# Plot the graph and the linear regression line
plot(galton_heights, pch = 16, col = "blue")
abline(fit, col="red", lwd=5)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And here is the linear regression line that the above code produces:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--WZxpm-KC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w0h86wjpo883jflcq2bd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--WZxpm-KC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w0h86wjpo883jflcq2bd.png" alt="Figure 2: Linear regression line in graph" width="880" height="525"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Figure 2: Linear regression line in graph&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Ok, that's it for this blog post on what Linear Regression is. I hope you found it useful!&lt;/p&gt;

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

&lt;p&gt;Thanks for reading this blog post!&lt;/p&gt;

&lt;p&gt;If you have any questions or concerns please feel free to post a comment in this post and I will get back to you if I find the time.&lt;/p&gt;

&lt;p&gt;If you found this article helpful please share it and make sure to follow me on &lt;a href="https://twitter.com/SeanAtukorala"&gt;Twitter &lt;/a&gt;and &lt;a href="https://github.com/ShehanAT"&gt;GitHub&lt;/a&gt;, connect with me on &lt;a href="https://www.linkedin.com/in/shehan-atukorala-8631491a5/"&gt;LinkedIn&lt;/a&gt; and subscribe to my &lt;a href="https://www.youtube.com/channel/UCtxed_NljgtAXrQMMdLvhrQ"&gt;YouTube channel&lt;/a&gt;.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Basic Overview of Summary Functions using Pandas</title>
      <dc:creator>Sean Atukorala</dc:creator>
      <pubDate>Sat, 10 Sep 2022 20:41:14 +0000</pubDate>
      <link>https://dev.to/shehanat/how-to-use-summary-functions-using-pandas-40kj</link>
      <guid>https://dev.to/shehanat/how-to-use-summary-functions-using-pandas-40kj</guid>
      <description>&lt;p&gt;Hello everyone, in this blog post I'll cover some Summary Functions that the &lt;a href="https://pandas.pydata.org/"&gt;Pandas Python Data Analysis Library&lt;/a&gt; offers. Let's get started!&lt;/p&gt;

&lt;h3&gt;
  
  
  List of Summary Functions
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Describe Function
&lt;/h4&gt;

&lt;p&gt;The &lt;code&gt;describe()&lt;/code&gt; function is used to obtain a informative statistical summary of a given Pandas DataFrame. The data that is displayed if the DataFrame contains numerical columns include the following(which is shown only the numerical columns):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;count - Amount of not-null values&lt;/li&gt;
&lt;li&gt;mean - Average value of the column values&lt;/li&gt;
&lt;li&gt;std - Standard deviation of the column values&lt;/li&gt;
&lt;li&gt;25% - Shows the value of the 25th percentile&lt;/li&gt;
&lt;li&gt;50% - Shows the value of the 50th percentile&lt;/li&gt;
&lt;li&gt;75% - Shows the value of the 75th percentile&lt;/li&gt;
&lt;li&gt;max- Maximum value contained in the column values&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Note: The percentile value of the column data indicate how many of the values that are less than a given percentile. A percentile is a value on a scale of 100 that indicates the percent of a dataset that is equal to or below it&lt;/p&gt;

&lt;h4&gt;
  
  
  Info Function
&lt;/h4&gt;

&lt;p&gt;The &lt;code&gt;Info()&lt;/code&gt; function is used to display information about the DataFrame that it is used on. The information provided by it include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Number of columns in the DataFrame&lt;/li&gt;
&lt;li&gt;Column labels&lt;/li&gt;
&lt;li&gt;Column data types&lt;/li&gt;
&lt;li&gt;Memory usage&lt;/li&gt;
&lt;li&gt;Range index&lt;/li&gt;
&lt;li&gt;Number of cells in each column&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Note: The &lt;code&gt;info()&lt;/code&gt; function does not have a return value&lt;/p&gt;

&lt;h4&gt;
  
  
  Value Counts Function
&lt;/h4&gt;

&lt;p&gt;The &lt;code&gt;value_counts()&lt;/code&gt; function returns a series containing counts of unique values.&lt;/p&gt;

&lt;p&gt;The output object will be ordered in descending fashion. This means the first element is the most frequently-occurring element.&lt;/p&gt;

&lt;p&gt;Note: this function excludes NA values by default&lt;/p&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;Well that's it for this post! Thanks for following along in this article and if you have any questions or concerns please feel free to post a comment in this post and I will get back to you when I find the time.&lt;/p&gt;

&lt;p&gt;If you found this article helpful please share it and make sure to follow me on &lt;a href="https://twitter.com/SeanAtukorala"&gt;Twitter&lt;/a&gt; and &lt;a href="https://github.com/ShehanAT"&gt;GitHub&lt;/a&gt;, connect with me on &lt;a href="https://www.linkedin.com/in/shehan-atukorala-8631491a5/"&gt;LinkedIn&lt;/a&gt;, subscribe to my &lt;a href="https://www.youtube.com/channel/UCtxed_NljgtAXrQMMdLvhrQ"&gt;YouTube channel&lt;/a&gt;.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How to detect outliers using Pandas, Matplotlib and Python</title>
      <dc:creator>Sean Atukorala</dc:creator>
      <pubDate>Sat, 03 Sep 2022 18:19:54 +0000</pubDate>
      <link>https://dev.to/shehanat/how-to-detect-outliers-using-pandas-matplotlib-and-python-4d59</link>
      <guid>https://dev.to/shehanat/how-to-detect-outliers-using-pandas-matplotlib-and-python-4d59</guid>
      <description>&lt;p&gt;Hello everyone, in this tutorial we’ll cover how to detect and remove outliers in a dataset using the Matplotlib and Pandas Machine Learning libraries.&lt;/p&gt;

&lt;p&gt;Here is the GitHub repo containing the full version of code shown here along with the train.csv data file(from which the data for the below tutorial is used): &lt;a href="https://github.com/ShehanAT/kaggle-titanic-project/tree/master/house_prices_advanced"&gt;House Prices Advanced GitHub Repo&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;First, let’s display all the datapoints in the scatterplot where the two variable being plotted are OverallQual and SalePrice. This can be done using the following code snippet:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;plot, ax = plt.subplots(1, 1, figsize = (12, 5))
sns.scatterplot(data = train_data, x = "OverallQual", y = "SalePrice", c = ["blue"], ax = ax)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here is the resulting graph that is created:&lt;/p&gt;

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

&lt;p&gt;&lt;em&gt;Figure 1: Initial Scatter Plot Graph&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Next, let’s work towards identifying the outliers in the above graph.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;plot, ax = plt.subplots(1, 2, figsize = (12, 5))
outliers = (train_data["OverallQual"] == 10) &amp;amp; (train_data["SalePrice"] &amp;lt;= 250000)
sns.scatterplot(data = train_data, x = "OverallQual", y = "SalePrice", c = ["red" if is_outlier else "blue" for is_outlier in outliers], ax = ax[0])
train_data.drop(train_data[(train_data["OverallQual"] == 10) &amp;amp; (train_data["SalePrice"] &amp;lt;= 250000)].index, inplace = True)
sns.scatterplot(data = train_data, x = "OverallQual", y = "SalePrice", ax = ax[1], c = ["blue"])
plt.show()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here’s an explanation for the code above:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;plt.subplots(1, 2, figsize = (12, 5)): We're creating two subplots inside one Matplotlib graph. The first parameter is the number of rows and the second defines the number of columns&lt;/li&gt;
&lt;li&gt;outliers = ...: Here we are identifying the outliers in the dataset using some specified criteria, namely: (train_data["OverallQual"] == 10) and (train_data["SalePrice"] &amp;lt;= 250000)&lt;/li&gt;
&lt;li&gt;First sns.scatterplot: Here we are defining the first scatterplot that will display the original data with the outliers highlighted in red. The red highlighting is caused by the conditional statement in the c option("red" if is_outlier else "blue" for is_outlier in outliers)&lt;/li&gt;
&lt;li&gt;Next we remove the outliers from our dataset via the pandas.DataFrame.drop() method(more on this method in the official docs)&lt;/li&gt;
&lt;li&gt;Second sns.scatterplot: Here we are defining the second scatterplot that will display the data with the outliers removed&lt;/li&gt;
&lt;li&gt;plt.show(): This method displays the graph that we just specified&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And here’s the resulting graph from running the code snippet above:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--T5iMbH1q--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1s2hf0pntwnom50pmqlc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--T5iMbH1q--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1s2hf0pntwnom50pmqlc.png" alt="First Graph showing the outlier in red, Second Graph shows the data with the outlier removed" width="880" height="368"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Figure 2: First Graph showing the outlier in red, Second Graph shows the data with the outlier removed&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;And that’s one way to remove outliers from a dataset using Matplotlib, Pandas and Python! Thanks for following along.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Well that's it for this post! Thanks for following along in this article and if you have any questions or concerns please feel free to post a comment in this post and I will get back to you when I find the time.&lt;/p&gt;

&lt;p&gt;If you found this article helpful please share it and make sure to follow me on &lt;a href="https://twitter.com/SeanAtukorala"&gt;Twitter&lt;/a&gt; and &lt;a href="https://github.com/ShehanAT"&gt;GitHub&lt;/a&gt;, connect with me on &lt;a href="https://www.linkedin.com/in/shehan-atukorala-8631491a5/"&gt;LinkedIn&lt;/a&gt;, subscribe to my &lt;a href="https://www.youtube.com/channel/UCtxed_NljgtAXrQMMdLvhrQ"&gt;YouTube channel&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;If you found this article helpful please share it and make sure to follow me on Twitter and GitHub, connect with me on LinkedIn, subscribe to my YouTube channel.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Basic Machine Learning and Statistics Concepts Explained</title>
      <dc:creator>Sean Atukorala</dc:creator>
      <pubDate>Sun, 21 Aug 2022 20:41:44 +0000</pubDate>
      <link>https://dev.to/shehanat/basic-machine-learning-and-statistics-concepts-explained-3pho</link>
      <guid>https://dev.to/shehanat/basic-machine-learning-and-statistics-concepts-explained-3pho</guid>
      <description>&lt;p&gt;Hi guys, this blog post is for clarifying and explaining some common machine learning and statistics concepts that can be very helpful to anyone new to the field of data science and machine learning.&lt;/p&gt;

&lt;p&gt;Without further ado, let's get into it!&lt;/p&gt;

&lt;h3&gt;
  
  
  Some Basic Machine Learning Concepts
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Machine Learning model: A Machine Learning model is a program that can make predictions or decisions after being trained on a newly created dataset&lt;/li&gt;
&lt;li&gt;Training set: A training set is a subset to train a model&lt;/li&gt;
&lt;li&gt;Test set: A test set is a subset to test the trained model
The training and test sets are two separate collections of data that are used to measure the accuracy of the Machine Learning model that you want to train&lt;/li&gt;
&lt;li&gt;DataFrame: DataFrame is a data structure that is part of the Pandas library&lt;/li&gt;
&lt;li&gt;Supervised machine learning: This type of machine learning is where some input data is provided to a mapping function in order to obtain a specific output&lt;/li&gt;
&lt;li&gt;Unsupervised machine learning: This type of machine learning is characterized by having no correct output for a provided input. Accordingly, no correct answer exists. The goal of this type of machine learning is to analyze data in its entirety and discover facts about the underlying structure&lt;/li&gt;
&lt;li&gt;Semi-Supervised learning: This type of machine learning is a combination of supervised and unsupervised machine learning. Semi-supervised learning is most useful when the dataset at hand is a mixture of labeled and unlabeled data points.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Some Basic Statistics Concepts
&lt;/h3&gt;

&lt;p&gt;Here are some statistics concepts that are useful to know:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Mean: This is the average value in a set of data points&lt;/li&gt;
&lt;li&gt;Median: This is the middle number in a set of data points&lt;/li&gt;
&lt;li&gt;Mode: This is the most frequent number in a set of data points&lt;/li&gt;
&lt;li&gt;Standard Deviation: This is a measure that tells you how dispersed the data points in a data set are in relation to the mean value(average value)&lt;/li&gt;
&lt;li&gt;Interquartile Range: This is a measure of spread in statistics. Interquartile range is also known as the "middle fifty" and is calculated using the formula:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;IQR(Interquartile Range) = Q3(Third quartile) - Q1(First quartile)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Skewness: This is a measure of asymmetry of the probability distribution of a dataset about its mean&lt;/li&gt;
&lt;li&gt;Variance: This is a measure of the variation among values in a dataset&lt;/li&gt;
&lt;li&gt;Covariance: This is a measure of how two variables in a data set will change together. A positive covariance indicates a positive relation between the two variables and visa versa for the negative.&lt;/li&gt;
&lt;li&gt;Normal Distribution: This is a probability distribution function that looks like a bell. Here is an image of a normal distribution:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--wxQrjNgg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pa1e72y9k055biyhvyss.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--wxQrjNgg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pa1e72y9k055biyhvyss.png" alt="Figure 1: Normal Distribution Graph" width="880" height="544"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Figure 1: Normal Distribution Graph&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;P-value: This is a statistical measurement tool used to measure the probability of obtaining a desired result or outcome from statistical hypothesis testing&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Conclusion
&lt;/h3&gt;

&lt;p&gt;Well that's it for this post! Thanks for following along in this article and if you have any questions or concerns please feel free to post a comment in this post and I will get back to you when I find the time.&lt;/p&gt;

&lt;p&gt;If you found this article helpful please share it and make sure to follow me on &lt;a href="https://twitter.com/SeanAtukorala"&gt;Twitter&lt;/a&gt; and &lt;a href="https://github.com/ShehanAT"&gt;GitHub&lt;/a&gt;, connect with me on &lt;a href="https://www.linkedin.com/in/shehan-atukorala-8631491a5/"&gt;LinkedIn&lt;/a&gt;, subscribe to my &lt;a href="https://www.youtube.com/channel/UCtxed_NljgtAXrQMMdLvhrQ"&gt;YouTube channel&lt;/a&gt;.&lt;/p&gt;

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