<?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: Tanveer Shahriar Arnob</title>
    <description>The latest articles on DEV Community by Tanveer Shahriar Arnob (@tanveershahriar).</description>
    <link>https://dev.to/tanveershahriar</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%2F925572%2Fe738cc68-8756-4617-8336-d66739aa1bee.jpg</url>
      <title>DEV Community: Tanveer Shahriar Arnob</title>
      <link>https://dev.to/tanveershahriar</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/tanveershahriar"/>
    <language>en</language>
    <item>
      <title>Azure Virtual Machine</title>
      <dc:creator>Tanveer Shahriar Arnob</dc:creator>
      <pubDate>Thu, 16 Mar 2023 14:05:25 +0000</pubDate>
      <link>https://dev.to/tanveershahriar/azure-virtual-machine-5fo</link>
      <guid>https://dev.to/tanveershahriar/azure-virtual-machine-5fo</guid>
      <description>&lt;p&gt;Microsoft Azure is a cloud computing platform that provides a wide variety of services. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Create Azure Virtual Machine&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Search for Virtual Machines&lt;/li&gt;
&lt;/ul&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%2Fjglcm04t905bisq9gdo6.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%2Fjglcm04t905bisq9gdo6.png" alt="Search Virtual Machines"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Clink on create and select Azure virtual machine&lt;/li&gt;
&lt;/ul&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%2Feww99kc4ts4eb54eheyt.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%2Feww99kc4ts4eb54eheyt.png" alt="Create"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Select resource group, give virtual machine a name and select region, availability option, image etc. as your need. Then click review + create.&lt;/li&gt;
&lt;/ul&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%2Fzghzqk6klhb6t1na2n5f.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%2Fzghzqk6klhb6t1na2n5f.png" alt="Configure Virtual Machine"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Finally this page will show if everything is ok for the virtual machine and also the cost per hour for using that virtual machine. After that press create.&lt;/li&gt;
&lt;/ul&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%2F993m19lqb1hmxtmjbyga.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%2F993m19lqb1hmxtmjbyga.png" alt="Final Create"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Then like the below picture you have to download private key for SSH connection. So press download private key and create resource.&lt;/li&gt;
&lt;/ul&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%2Fkur9j8h3i3mb4bbplsx7.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%2Fkur9j8h3i3mb4bbplsx7.png" alt="Download Private Key"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Finally your virtual machine will be created and you will get the dashboard. From here you can configure, stop or delete the virtual machine.&lt;/li&gt;
&lt;/ul&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%2Fduzysct2lr0iesas97bc.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%2Fduzysct2lr0iesas97bc.png" alt="Virtual Machine Dashboard"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Then if you want to connect via SSH with client search for connect and something like the image below will appear. There you will find commands for connecting. You have to run those commands in the cloud shell.&lt;/li&gt;
&lt;/ul&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%2Ftpn337n3645lmejz484b.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%2Ftpn337n3645lmejz484b.png" alt="SSH connect"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;After that to update your software or install anything (for demo let's install nginx) run below command.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo su
apt-get -y update
apt-get -y install nginx
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Also if you know that what you will install before creating virtual machine, then you can configure a cloud init while creating the VM which will automatically run all your commands. For configuring cloud init you have to go to advance tab and write the commands in the custom data and cloud init section like the image below.&lt;/li&gt;
&lt;/ul&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%2Foi4fxvzkwdgh5fsiwemi.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%2Foi4fxvzkwdgh5fsiwemi.png" alt="Cloud init"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And that's how you create a VM. But you have to know two things --&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;While creating VM it automatically creates a disk which is the storage for the image or operating system.&lt;/li&gt;
&lt;li&gt;People may think that, if we stop the VM then it will not cost anything. But the truth is, as it has a default disk connected with it, even if we don't have to pay for the VM, we have to pay for the disk. So simply stopping the VM will cost less but it's not going to be 0. &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Thank you everyone. That's it for today. Feel free to ask any question in the comment.&lt;/p&gt;

</description>
      <category>cloud</category>
      <category>azure</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>NumPy Arrays</title>
      <dc:creator>Tanveer Shahriar Arnob</dc:creator>
      <pubDate>Sat, 19 Nov 2022 20:26:32 +0000</pubDate>
      <link>https://dev.to/tanveershahriar/numpy-arrays-3pmo</link>
      <guid>https://dev.to/tanveershahriar/numpy-arrays-3pmo</guid>
      <description>&lt;p&gt;NumPy is a Python library used for working with arrays. It also has functions for working in domain of linear algebra, fourier transform, and matrices. NumPy was created in 2005 by Travis Oliphant. It is an open source project and you can use it freely. This module is mainly used for Data Science and Machine Learning.&lt;/p&gt;

&lt;h2&gt;
  
  
  Installation
&lt;/h2&gt;

&lt;p&gt;We can install NumPy using pip [pip is a python package manager]. Go to your terminal and type:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;h2&gt;
  
  
  Using NumPy
&lt;/h2&gt;

&lt;p&gt;To use the built in function from NumPy we have to import it first.&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;But after that if we want to use any function we have to write numpy every time to use that. That's why it is convention to import numpy as np.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import numpy as np
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  NumPy Arrays
&lt;/h2&gt;

&lt;p&gt;NumPy arrays essentially come in two flavors: vectors and matrices. Vectors are strictly 1-d arrays and matrices are 2-d (but you should note a matrix can still have only one row or one column).&lt;/p&gt;

&lt;h2&gt;
  
  
  Creating Numpy Arrays
&lt;/h2&gt;

&lt;p&gt;We can create an array by directly converting a list or list of lists:&lt;/p&gt;

&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%2Foj720u93pwm0udg8sfma.png" 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%2Foj720u93pwm0udg8sfma.png" alt="NumPy Array" width="356" height="165"&gt;&lt;/a&gt;&lt;/p&gt;

&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%2Fluwlcgj6uic53e4t49k0.png" 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%2Fluwlcgj6uic53e4t49k0.png" alt="NumPy Matrix" width="548" height="160"&gt;&lt;/a&gt;&lt;/p&gt;

&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%2Ffpcb8e7tih23153fy9mf.png" 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%2Ffpcb8e7tih23153fy9mf.png" alt="NumPy Array Data Type" width="487" height="144"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There are also some built in functions to generate arrays. &lt;/p&gt;

&lt;h2&gt;
  
  
  arange
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;numpy.arange([start, ]stop, [step, ])&lt;/code&gt;&lt;br&gt;
arange is like the range function of python. It returns evenly spaced values within a given interval. Here start and step is optional if we need it but stop is mandatory.&lt;/p&gt;

&lt;p&gt;arange can be called with a varying number of positional arguments:&lt;/p&gt;

&lt;p&gt;arange(stop): Values are generated within the half-open interval [0, stop) (in other words, the interval including start but excluding stop).&lt;/p&gt;

&lt;p&gt;arange(start, stop): Values are generated within the half-open interval [start, stop).&lt;/p&gt;

&lt;p&gt;arange(start, stop, step) Values are generated within the half-open interval [start, stop), with spacing between values given by step.&lt;/p&gt;

&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%2Frxh3gz7qfzfzm56ib0sa.png" 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%2Frxh3gz7qfzfzm56ib0sa.png" alt="NumPy arange" width="649" height="285"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  zeros
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;numpy.zeros(shape, dtype=float)&lt;/code&gt;&lt;br&gt;
It generates a array of given shape and type, filled with zeroes. Here shape can be a int which will generate 1D array or a tuple of ints which will generate matrices. Instead of tuple we can use list of ints also. And dtype is by default float but we can change it into int.&lt;/p&gt;

&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%2Froen466q6w6kcx0bxhrf.png" 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%2Froen466q6w6kcx0bxhrf.png" alt="NumPy zeros" width="614" height="493"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  ones
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;numpy.ones(shape, dtype=float)&lt;/code&gt;&lt;br&gt;
It is same as the zeros function but instead of zeroes all of the elements are one. &lt;/p&gt;

&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%2F5ojo9nkffsy9j9dzrre4.png" 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%2F5ojo9nkffsy9j9dzrre4.png" alt="NumPy ones" width="691" height="498"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  linspace
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;numpy.linspace(start, stop, num=50)&lt;/code&gt;&lt;br&gt;
Returns num evenly spaced samples, calculated over the interval [start, stop]. And num is by default 50.&lt;/p&gt;

&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%2F9hebgepdsy3ziuu5lymx.png" 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%2F9hebgepdsy3ziuu5lymx.png" alt="NumPy linspace" width="800" height="390"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  eye
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;numpy.eye(n)&lt;/code&gt;&lt;br&gt;
Return a 2-D array with ones on the diagonal and zeros elsewhere. Simply it generates a nxn identity matrix.&lt;/p&gt;

&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%2F1xbzygyjseashas6e5i8.png" 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%2F1xbzygyjseashas6e5i8.png" alt="NumPy eye" width="364" height="135"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Random
&lt;/h2&gt;

&lt;p&gt;NumPy also has lots of ways to create arrays with random numbers. &lt;/p&gt;

&lt;h2&gt;
  
  
  rand
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;numpy.random.rand(d0, d1, ..., dn)&lt;/code&gt;&lt;br&gt;
Create an array of the given shape and populate it with random samples from a uniform distribution over [0, 1).&lt;/p&gt;

&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%2Fcc8mvjdlu3ai9cu03sfo.png" 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%2Fcc8mvjdlu3ai9cu03sfo.png" alt="NumPy Random rand" width="603" height="531"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  randn
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;numpy.random.randn(d0, d1, ..., dn)&lt;/code&gt;&lt;br&gt;
Return a sample (or samples) from the "standard normal" distribution. Unlike rand which is uniform. Also rand cannot generate negative values but randn can.&lt;/p&gt;

&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%2F6om4bwfqrwrow04c32e9.png" 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%2F6om4bwfqrwrow04c32e9.png" alt="NumPy Random randn" width="697" height="539"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  randint
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;random.randint(low, high=None, size=None)&lt;/code&gt;&lt;br&gt;
Return random integers from low (inclusive) to high (exclusive). If we don't mention size then it will return one value. For size we can pass an int or a tuple of ints or a list of ints. &lt;/p&gt;

&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%2Fnovbj1g8qc2svt5ysedy.png" 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%2Fnovbj1g8qc2svt5ysedy.png" alt="NumPy Random randint" width="471" height="746"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Array Attributes and Methods
&lt;/h2&gt;

&lt;h2&gt;
  
  
  reshape
&lt;/h2&gt;

&lt;p&gt;Returns an array containing the same data with a new shape. But we have to declare the shape such that we have the proper amount of elements. Suppose we have a array of 25 elements. We can transform it into a 5x5 matrix but we can not reshape into a 3x4 matrix as it can not contain 25 element.&lt;/p&gt;

&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%2Fm9cw4g981prhbpuxvr5n.png" 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%2Fm9cw4g981prhbpuxvr5n.png" alt="NumPy reshape" width="800" height="467"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  max
&lt;/h2&gt;

&lt;p&gt;It will return the max value of the array.&lt;/p&gt;

&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%2Fyu4xnygjx6ecgybh1svj.png" 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%2Fyu4xnygjx6ecgybh1svj.png" alt="NumPy max" width="623" height="207"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  argmax
&lt;/h2&gt;

&lt;p&gt;It will return the index of the max value of the array.&lt;/p&gt;

&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%2Fycfkmwcvi3vgr0zcfcm7.png" 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%2Fycfkmwcvi3vgr0zcfcm7.png" alt="NumPy argmax" width="610" height="208"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  min
&lt;/h2&gt;

&lt;p&gt;It will return the min value of the array.&lt;/p&gt;

&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%2Fs4k2ud1x7pqf5l7swg0r.png" 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%2Fs4k2ud1x7pqf5l7swg0r.png" alt="NumPy min" width="618" height="205"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  argmin
&lt;/h2&gt;

&lt;p&gt;It will return the index of the min value of the array.&lt;/p&gt;

&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%2Fbfteg6bnbppo193ygkuo.png" 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%2Fbfteg6bnbppo193ygkuo.png" alt="NumPy argmin" width="683" height="207"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Shape
&lt;/h2&gt;

&lt;p&gt;Shape is an attribute that arrays have which returns the shape of the array.&lt;/p&gt;

&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%2Fuw21ttzgyejii8lustn0.png" 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%2Fuw21ttzgyejii8lustn0.png" alt="NumPy shape" width="800" height="474"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  dtype
&lt;/h2&gt;

&lt;p&gt;You can also grab the data type of the object in the array.&lt;/p&gt;

&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%2Fyezl8toh6r101g1qwlks.png" 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%2Fyezl8toh6r101g1qwlks.png" alt="NumPy dtype" width="800" height="407"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That's it for today. Feel free to ask any question in the comment.&lt;/p&gt;

</description>
      <category>api</category>
      <category>unsplash</category>
    </item>
    <item>
      <title>Basic Python</title>
      <dc:creator>Tanveer Shahriar Arnob</dc:creator>
      <pubDate>Fri, 21 Oct 2022 05:36:09 +0000</pubDate>
      <link>https://dev.to/tanveershahriar/basic-python-jmj</link>
      <guid>https://dev.to/tanveershahriar/basic-python-jmj</guid>
      <description>&lt;p&gt;Python is a high-level, interpreted, object-oriented, general purpose programming language. It was created by Guido van Rossum, and released in 1991.Python has a simple syntax similar to the English language. Python runs on an interpreter system, meaning that code can be executed as soon as it is written. This means that prototyping can be very quick.&lt;/p&gt;

&lt;p&gt;Python was designed for readability, and has some similarities to the English language with influence from mathematics.&lt;/p&gt;

&lt;p&gt;Python uses new lines to complete a command, as opposed to other programming languages which often use semicolons or parentheses.&lt;/p&gt;

&lt;p&gt;Python relies on indentation, using whitespace, to define scope; such as the scope of loops, functions and classes. Other programming languages often use curly-brackets for this purpose.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Data Types&lt;/strong&gt;&lt;br&gt;
Python mainly has 4 data types --&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Integer -- All the whole number is integer&lt;/li&gt;
&lt;li&gt;Float -- The numbers with the decimal part is float&lt;/li&gt;
&lt;li&gt;String -- String is a series of character&lt;/li&gt;
&lt;li&gt;Boolean -- For this data type we only have two values - True and False.&lt;/li&gt;
&lt;/ol&gt;

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

&lt;p&gt;&lt;strong&gt;Variable Assignment&lt;/strong&gt;&lt;br&gt;
Variables in programming means a memory location where we can store our data. For python syntax for variable assignment is &lt;br&gt;
var_name = data. Here var_name will be the label of that memory location and by using that we will be able to retrieve the data from the memory location.&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;Variable Naming Convention&lt;/strong&gt;&lt;br&gt;
There are some rules for naming variable. Some of them are mandatory otherwise it will give error and some of them are for readability. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A variable must start with a letter or the underscore (_) character. It cannot start with a number.&lt;/li&gt;
&lt;li&gt;Variable names are case sensitive. Means "age", "Age", "aGe" are not the same variable. &lt;/li&gt;
&lt;li&gt;If the name has more than one word than to separate those words we have to use underscore, we cannot use space&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Let's print "HELLO WORLD"&lt;/strong&gt;&lt;br&gt;
Printing means showing something in the console. For that python has a built-in function print().&lt;/p&gt;

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

&lt;p&gt;So print function literally takes anything you want to show in the console and shows it.&lt;/p&gt;

&lt;p&gt;It can take variables also which will print the value of the variables.&lt;/p&gt;

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

&lt;p&gt;Here we can see if we use comma to print two variables then it prints a space between the variables. We can change that using the "sep" argument of print.&lt;/p&gt;

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

&lt;p&gt;Again if you notice, every print function creates a new line. Means after the first print, the next one will be in the new line. We can change that also with "end" argument.&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;Comments&lt;/strong&gt;&lt;br&gt;
Sometimes we have to write some notes on our code, so that we can figure out later for which purpose we wrote this piece of code. There are two types of comment:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Single Line Comment&lt;/li&gt;
&lt;li&gt;Multi-line Comment&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;For single line comment we just need write "#" before the note.&lt;/p&gt;

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

&lt;p&gt;For multi-line comments we use triple quotes (""" """ or ''' '''). But one thing to remember, by convention triple quotes are used as a docstring in python. That is why this is not recommended. So if we have to comment multiple lines, we should comment every line with Single Line Comment. To do so, just select every line and press ctrl + /.&lt;/p&gt;

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

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

&lt;p&gt;Feel free to ask anything if you don't understand.&lt;/p&gt;

</description>
      <category>python</category>
      <category>programming</category>
      <category>beginners</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Univariate Linear Regression</title>
      <dc:creator>Tanveer Shahriar Arnob</dc:creator>
      <pubDate>Sat, 24 Sep 2022 18:28:41 +0000</pubDate>
      <link>https://dev.to/tanveershahriar/univariate-linear-regression-1anl</link>
      <guid>https://dev.to/tanveershahriar/univariate-linear-regression-1anl</guid>
      <description>&lt;p&gt;&lt;strong&gt;Regression&lt;/strong&gt;&lt;br&gt;
A regression is a statistical technique that relates a dependent variable to one or more independent (explanatory) variables. A regression model is able to show whether changes observed in the dependent variable are associated with changes in one or more of the explanatory variables.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Linear Regression&lt;/strong&gt;&lt;br&gt;
In general, the computer try to draw a graph in regression from where it can predict the result. The graph can be any one but when it is an linear equation it is called Linear Regression.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Univariate Linear Regression&lt;/strong&gt;&lt;br&gt;
Univariate linear regression focuses on determining relationship between one independent variable and one dependent variable.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Formula:&lt;/strong&gt;&lt;/p&gt;

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

&lt;p&gt;The w and b are called the parameters of the model. In machine learning parameters of the model are the variables which can be adjusted during training in order to improve the model.&lt;/p&gt;

&lt;p&gt;Basically the model will try to find the best w and b for the model while training.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Cost Function&lt;/strong&gt;&lt;br&gt;
This is literally an "Standard Deviation" which helps the model to measure if it is efficient enough. &lt;/p&gt;

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

&lt;p&gt;There are other formula of cost function. But we will be using this one. &lt;br&gt;
Cost function helps us to find the difference of the predicted result and real result from the dataset. Target of the model will be reducing the cost function which will reduce the difference and gives us more accurate result.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Gradient Descent&lt;/strong&gt;&lt;br&gt;
It is an algorithm which is used to minimize any function and we will use that to minimize the cost function. At first start off with some initial guesses for w and b which generally 0. Then it will keep on changing the parameters w and b a bit every time to to reduce the cost function. Normally there might be more than one local minima but in linear regression there will be only one minima. So, for now we don't have to think about that. &lt;/p&gt;

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

&lt;p&gt;Here alpha is the learning rate which is a small positive number between 0 to 1. We can consider it as how big steps we are taking to reach the minimum.&lt;/p&gt;

&lt;p&gt;If the learning rate is too small, gradient descent will work but it will be slow. &lt;/p&gt;

&lt;p&gt;If the learning rate is too big, it may always skip the minimum because of the big steps. So it may fail to converge and may even diverge.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#Importing modules
import numpy as np

#Function for computing cost
def compute_cost(x_train, y_train, w, b):
  m = len(x_train)
  cost = 0
  for i in range(m):
    f_wb = w * x_train[i] + b
    cost += (f_wb - y_train[i]) ** 2
  return cost / (2 * m)

#Function for computing gradient
def compute_gradient(x_train, y_train, w, b):
  m = len(x_train)
  dj_dw = 0
  dj_db = 0
  for i in range(m):
    f_wb = w * x_train[i] + b
    dj_dw += (f_wb - y_train[i]) * x_train[i]
    dj_db += (f_wb - y_train[i])
  return dj_dw/m, dj_db/m

#Function for gradient descent
def gradient_descent(x_train, y_train, w_init, b_init, alpha, num_iters):
  w = w_init
  b = b_init
  for i in range(num_iters):
    dj_dw, dj_db = compute_gradient(x_train, y_train, w, b)
    w -= alpha * dj_dw
    b -= alpha * dj_db
  return w, b

#Data sets
x_train = np.array([1.0, 2.0])
y_train = np.array([300.0, 500.0])

#Initial w and b
w_init = 0
b_init = 0

#Some values for gradient descents
alpha = 0.01
num_iters = 100000

print(gradient_descent(x_train, y_train, w_init, b_init, alpha, num_iters))
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Above is the python implementation of gradient descent for univariate linear regression where we have only 2 data in the dataset. But larger dataset are always better for training.&lt;/p&gt;

</description>
      <category>machinelearning</category>
      <category>python</category>
      <category>linearregression</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Machine Learning Basic</title>
      <dc:creator>Tanveer Shahriar Arnob</dc:creator>
      <pubDate>Fri, 23 Sep 2022 18:25:54 +0000</pubDate>
      <link>https://dev.to/tanveershahriar/machine-learning-basic-2lp1</link>
      <guid>https://dev.to/tanveershahriar/machine-learning-basic-2lp1</guid>
      <description>&lt;p&gt;&lt;strong&gt;Machine Learning&lt;/strong&gt;&lt;br&gt;
Machine Learning is the field of study that gives computers the ability to learn and adapt without following explicit instructions, by using algorithms and statistical models.&lt;/p&gt;

&lt;p&gt;The two main types of machine learning are&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Supervised Learning.&lt;/li&gt;
&lt;li&gt;Unsupervised Learning.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;(1) Supervised Learning&lt;/strong&gt;&lt;br&gt;
In supervised learning, we provide a dataset where we have the result for certain inputs. Then the computer analyze and train itself to predict the result for any given inputs.&lt;/p&gt;

&lt;p&gt;The two major types of supervised learning are&lt;/p&gt;

&lt;p&gt;a. Regression &lt;br&gt;
b. Classification&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;(a) Regression&lt;/strong&gt;&lt;br&gt;
A regression is a statistical technique that relates a dependent variable to one or more independent (explanatory) variables. A regression model is able to show whether changes observed in the dependent variable are associated with changes in one or more of the explanatory variables.&lt;/p&gt;

&lt;p&gt;Basically, from the dataset, the computer tries to draw a graph which helps to predict the result.&lt;/p&gt;

&lt;p&gt;Predicting house prices depending on the location and size is the example of regression.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;(b) Classification&lt;/strong&gt;&lt;br&gt;
Classification refers to a predictive modeling problem where a class label is predicted for a given example of input data.&lt;/p&gt;

&lt;p&gt;Basically, from the dataset, the computer tries to find some class and differentiate them. Then it tries to predict the class from the given inputs.&lt;/p&gt;

&lt;p&gt;Predicting if a email is spam or not is the example of classification.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Difference Between Regression and Classification&lt;/strong&gt;&lt;br&gt;
In regression, the model has to predict result from infinitely many possible output numbers. On the other hand, classification has to the category which has a small set of possible outputs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;(2) Unsupervised Learning&lt;/strong&gt;&lt;br&gt;
In unsupervised learning, the dataset only has some values without any result. Then the model tries to group them or find some pattern. Based on the pattern the model tries to give result for any given inputs.&lt;/p&gt;

&lt;p&gt;Anomaly detection, which is used to detect unusual events is done by unsupervised learning.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Difference Between Supervised and Unsupervised Learning&lt;/strong&gt;&lt;br&gt;
In supervised learning, the data comes with both inputs x and input labels y, and the algorithm tries to find a graph from where it can predict result. On the other hand, in unsupervised learning, the data comes only with inputs x but not output labels y, and the algorithm has to find some structure or some pattern or something interesting in the data.&lt;/p&gt;

</description>
      <category>machinelearning</category>
      <category>beginners</category>
      <category>programming</category>
      <category>python</category>
    </item>
  </channel>
</rss>
