<?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: Zarin Saima Roza</title>
    <description>The latest articles on DEV Community by Zarin Saima Roza (@zarinsaima333).</description>
    <link>https://dev.to/zarinsaima333</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%2F978813%2Faa795c77-f41b-4ef4-a50f-2037d663b7ae.jpg</url>
      <title>DEV Community: Zarin Saima Roza</title>
      <link>https://dev.to/zarinsaima333</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/zarinsaima333"/>
    <language>en</language>
    <item>
      <title>Feature Scaling in ML</title>
      <dc:creator>Zarin Saima Roza</dc:creator>
      <pubDate>Sun, 18 Feb 2024 15:49:23 +0000</pubDate>
      <link>https://dev.to/zarinsaima333/feature-scaling-in-ml-a4o</link>
      <guid>https://dev.to/zarinsaima333/feature-scaling-in-ml-a4o</guid>
      <description>&lt;p&gt;Imagine you're making a dessert and following a recipe that lists ingredients in different units—some in grams, some in tablespoons. Now, you want to ensure each ingredient plays a fair role in the final dish. If you don't scale them properly, one ingredient might overpower the others because it's measured in larger units. Let's say you unintentionally put a lot of cocoa powder in your dessert than the actual amount required so your dessert now tastes bitter. We don't want it right? &lt;/p&gt;

&lt;p&gt;In the world of data and machine learning, our "ingredients" are features or variables in a dataset. Feature scaling is like ensuring each of these "ingredients" gets a fair portion in the analysis so that we don't end up with a dessert that tastes too bitter, or we can say end up making a wrong model. We want to avoid letting one feature overshadow others just because it's naturally on a different scale.&lt;/p&gt;

&lt;p&gt;Common methods for feature scaling include:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Min-Max Scaling (Normalization) &lt;/li&gt;
&lt;li&gt;standardization (Z-score normalization)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;(these methods are applied column-wise, which means we will normalize all the values of one column, we won't be doing it row-wise)&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fphtx1tlns9b60ttfsehy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fphtx1tlns9b60ttfsehy.png" alt="Image description" width="800" height="359"&gt;&lt;/a&gt;&lt;br&gt;
 Let's understand with an example:&lt;/p&gt;

&lt;p&gt;Think, we have a dataset that contains age and salary. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl8zisolxg9rd96mzi8sg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl8zisolxg9rd96mzi8sg.png" alt="Image description" width="800" height="400"&gt;&lt;/a&gt;&lt;br&gt;
The differences in values of salaries are way bigger than the differences in values of ages, we can't put them in the same position. On one side the difference is 10K another side we have 1. Now if I want to group them I would surely group red and purple together as their difference is 8k; 2k lesser than blue and purple.  But it may give us wrong ans. So we have to bring them down to a position where we can compare them. If Normalizing is used we'll get-&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fygg16uw2vnh9k8f6ble0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fygg16uw2vnh9k8f6ble0.png" alt="Image description" width="800" height="417"&gt;&lt;/a&gt;&lt;br&gt;
Now, you can easily say that the purple person is closer to the blue person. And we would group blue and purple.&lt;/p&gt;

&lt;p&gt;​&lt;/p&gt;

</description>
      <category>machinelearning</category>
      <category>datascience</category>
      <category>beginners</category>
    </item>
    <item>
      <title>The Great Showdown: Python list Vs. NumPy Array. Who wins?</title>
      <dc:creator>Zarin Saima Roza</dc:creator>
      <pubDate>Fri, 24 Nov 2023 22:24:41 +0000</pubDate>
      <link>https://dev.to/zarinsaima333/the-great-showdown-python-list-vs-numpy-array-who-wins-2hi0</link>
      <guid>https://dev.to/zarinsaima333/the-great-showdown-python-list-vs-numpy-array-who-wins-2hi0</guid>
      <description>&lt;p&gt;In Python, a list is a built-in data type used to store a collection of items. It is a mutable, ordered sequence that can contain elements of different data types, including numbers, strings, and even other lists. On the other hand, NumPy is a Python library that helps with dealing with n-dimensional arrays. It's used in hard mathematical operations. We can efficiently use it as a fundamental tool for scientific computing and data analysis in Python.&lt;/p&gt;

&lt;p&gt;Now, in 3 different scales, we will judge which one is better to use.&lt;br&gt;
The ultimate battle round begins 🥁!&lt;/p&gt;

&lt;p&gt;**&lt;/p&gt;

&lt;h2&gt;
  
  
  Round1:storage efficiency
&lt;/h2&gt;

&lt;p&gt;**&lt;/p&gt;

&lt;pre&gt;
&lt;code&gt;lis=range(1000) #a list of 1000 element

#print(lis) #range(0, 1000)
#print(sys.getsizeof(5)) #any num would give 28
#print(len(lis))#1000
print(sys.getsizeof(1)*len(lis))# 5 denotes element num

arr=np.arange(1000)#same as range func, gonna create an array
print(arr.size*arr.itemsize)
# print(arr.itemsize)

# 28000 bytes -taken by lis
# 8000 bytes -taken by arr(numpy)

#Byte size of elements varies with Operating system
&lt;/code&gt;
&lt;/pre&gt; 

&lt;ul&gt;
&lt;li&gt;In the above code, it's evident that numpy takes less space to store. We created a list of 1000 elements. Where each element takes 28 bytes in Python conventional list,numpy stores each element in 8 bytes. So, clearly, numpy wins!&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;**&lt;/p&gt;

&lt;h2&gt;
  
  
  Round 2:Time taken to execute
&lt;/h2&gt;

&lt;p&gt;**&lt;br&gt;
   When the dataset is very small it doesn't really matter. But let's say you are working with a very large amount of data then who'll be ahead in the race?&lt;/p&gt;

&lt;p&gt;In Python everything is an object. The objects of Python list are not stored in a contiguous manner. Rather it stores the location of the object. Then pointers point towards the object located in its given memory location.So it takes while to execute. &lt;/p&gt;

&lt;p&gt;On Numpy's case it has contiguous memory location. So takes less time to execute.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--pWJQYwJV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d3oxi3a7yfj7c481mxtz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pWJQYwJV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d3oxi3a7yfj7c481mxtz.png" alt="Image description" width="773" height="387"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--wD2p7-BL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/44cgd1l51dg6q3qgosw7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--wD2p7-BL--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/44cgd1l51dg6q3qgosw7.png" alt="Image description" width="800" height="446"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let's see it in the code-&lt;/p&gt;

&lt;pre&gt;
&lt;code&gt;
sz=1000000

lis1=range(sz)
lis2=range(sz)

arr1=np.arange(sz)
arr2=np.arange(sz)

#python list

start=time.time()
print(time.time()-start)
res= [(i+j)for i,j in zip(lis1,lis2)]
#it will take 1st ele from lis1 and lis2 and add them togrther in ele1 of res
print("Time taken by python list",(time.time()-start)*1000) #sec


#numpy array

start=time.time()
result=arr1+arr2
print("Time taken by nparray",(time.time()-start)*1000)
&lt;/code&gt;
&lt;/pre&gt;

&lt;p&gt;we see,&lt;br&gt;
   Time taken by python list 113.46936225891113 mili seconds&lt;br&gt;
   Time taken by nparray 4.576921463012695 mili seconds&lt;/p&gt;

&lt;p&gt;python list takes a lot more time than numpy to work. So, clearly numpy again takes a lead.&lt;/p&gt;

&lt;p&gt;**&lt;/p&gt;

&lt;h2&gt;
  
  
  Round3: Conveniency
&lt;/h2&gt;

&lt;p&gt;**&lt;br&gt;
   We are already familiar with the usage of numpy. But as numpy and List do a lot of similar jobs. In which basis numpy is convenient. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;It's very easy to add, subtract,multiply, and divide two matrices in numpy. In python, we don't get to do these.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;NumPy offers a rich set of mathematical functions for linear algebra, Fourier analysis, random number generation, and more. This makes it a powerful tool for scientific computing.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;pre&gt;
&lt;code&gt;
#numpy why convenient
arr1=np.array([1,2,3])
arr2=np.array([6,90,5])
print(arr1+arr2,arr1-arr2,arr1*arr2,arr1/arr2)
&lt;/code&gt;
&lt;/pre&gt;
    

&lt;p&gt;Undoubtedly, numpy aces this round too!&lt;/p&gt;

&lt;p&gt;To conclude, when it comes to fast computation, memory efficiency and convenience numpy without a say beats Python convenient List!💪&lt;/p&gt;

&lt;p&gt;To know more functions of numpy, Check out this ipynb file-&lt;br&gt;
[(&lt;a href="https://colab.research.google.com/drive/1-WoYuFd_iZiTZ8gcRuzrbvjx6D1Mq4Rh?usp=sharing"&gt;https://colab.research.google.com/drive/1-WoYuFd_iZiTZ8gcRuzrbvjx6D1Mq4Rh?usp=sharing&lt;/a&gt;)&lt;br&gt;
]&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>datascience</category>
      <category>python</category>
    </item>
    <item>
      <title>Optimization of log loss</title>
      <dc:creator>Zarin Saima Roza</dc:creator>
      <pubDate>Tue, 21 Nov 2023 22:08:37 +0000</pubDate>
      <link>https://dev.to/zarinsaima333/optimization-of-log-loss-4p6d</link>
      <guid>https://dev.to/zarinsaima333/optimization-of-log-loss-4p6d</guid>
      <description>&lt;p&gt;Let's think of a scene where to win you need 7 H and 3 T in 10 times of tosses. And, three are 3 different coins has different possibilities of having H and T. Which coin has the probability of winning?  &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--M-sxhFY3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yz701kgc4q27w5ahutjv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--M-sxhFY3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yz701kgc4q27w5ahutjv.png" alt="Image description" width="800" height="411"&gt;&lt;/a&gt;&lt;br&gt;
Surely, number 1 wins!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--VzmmrK0v--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ecqitxjzqamcxwxy0xa4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--VzmmrK0v--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ecqitxjzqamcxwxy0xa4.png" alt="Image description" width="800" height="391"&gt;&lt;/a&gt;&lt;br&gt;
Let's see how we can solve this,&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--H9O9fR5I--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fpog1eaelabvqxkhyx0h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--H9O9fR5I--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fpog1eaelabvqxkhyx0h.png" alt="Image description" width="800" height="378"&gt;&lt;/a&gt;&lt;br&gt;
This can be used using the chain rule, But then it will be lengthy. So, using the log function on g(p)(the chances of winning) is the wisest decision. Then finding the derivative of the log loss will give the correct answer.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--BVQFSbOM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mfjcxhgec651f0wh2dno.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--BVQFSbOM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mfjcxhgec651f0wh2dno.png" alt="Image description" width="800" height="385"&gt;&lt;/a&gt;&lt;br&gt;
So what is the log loss?&lt;br&gt;
According to a data scientist, log-loss is indicative of how close the prediction probability is to the corresponding actual/true value (0 or 1 in the case of binary classification). The more the predicted probability diverges from the actual value, the higher the log-loss value.&lt;/p&gt;

&lt;p&gt;The relationship of log loss with ml is shown below-&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--p9GWmVMg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v83lhtbjpg4iwxsskw5t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--p9GWmVMg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v83lhtbjpg4iwxsskw5t.png" alt="Image description" width="771" height="355"&gt;&lt;/a&gt;&lt;br&gt;
Here, we minimize the log loss and get that the optimal p is 0.7.&lt;br&gt;
:D&lt;/p&gt;

</description>
      <category>probability</category>
      <category>machinelearning</category>
    </item>
    <item>
      <title>Optimization of The Square Loss</title>
      <dc:creator>Zarin Saima Roza</dc:creator>
      <pubDate>Tue, 21 Nov 2023 21:22:12 +0000</pubDate>
      <link>https://dev.to/zarinsaima333/optimization-of-the-square-loss-520c</link>
      <guid>https://dev.to/zarinsaima333/optimization-of-the-square-loss-520c</guid>
      <description>&lt;p&gt;The square loss function is the average of squared differences between the actual and the predicted values. the squared error is one of the most important functions in machine learning. It is used to train linear regression problems and certain neural networks.&lt;/p&gt;

&lt;p&gt;In this problem, there are 3 power lines and our task is to place the house at a point where it is the most cost-effective.&lt;/p&gt;

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

&lt;p&gt;Firstly, let's take the first power line. Where the house be situated to get the least cost? Obviously, where the distance is zero, so that we get zero cost.&lt;/p&gt;

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

&lt;p&gt;Now, let's bring another power line to the discussion. &lt;/p&gt;

&lt;p&gt;Let, a= the distance of pl1 from origin&lt;br&gt;
     b= the distance of pl2 from origin&lt;br&gt;
     x= the distance of the house from origin&lt;/p&gt;

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

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

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

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

&lt;p&gt;So, we can see the cost of connecting both of the powerlines is quite the same when the house is placed in the middle.&lt;/p&gt;

&lt;p&gt;We don't want any of these above situations cause the cost area is very big.&lt;/p&gt;

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

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

&lt;p&gt;We see that the tangent is zero in the lowest point. (x-a)^2 +(x-b)^2 is the cost function here, the derivate of this function is- &lt;/p&gt;

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

&lt;p&gt;So, if the house is placed between two poles the cost will be minimized.&lt;/p&gt;

&lt;p&gt;Now, let's see what happens if a 3rd powerline is in the scene,&lt;br&gt;
Again, if we repeat the same procedure,&lt;/p&gt;

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

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

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

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

&lt;p&gt;If we sum the heights of the three parabolas, we get the black parabola.&lt;/p&gt;

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

&lt;p&gt;finding the derivative of the cost function-&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ilbQ09mz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3juokm6ao15jh49433ur.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ilbQ09mz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3juokm6ao15jh49433ur.png" alt="Image description" width="719" height="344"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So, the generalized solution is-&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--P52WrUKb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nwz6g2azf4r3jdl6vq1c.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--P52WrUKb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nwz6g2azf4r3jdl6vq1c.png" alt="Image description" width="681" height="283"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Finally, the solution would be to put the house in the average of the coordinates of all the power lines. And this is the square loss function. &lt;/p&gt;

&lt;p&gt;**The pictures are taken from different source.&lt;/p&gt;

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