<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Ishita Gupta on Medium]]></title>
        <description><![CDATA[Stories by Ishita Gupta on Medium]]></description>
        <link>https://medium.com/@ishitagupta8720?source=rss-787d553e8301------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*EQFxMAlN6oKjv17-.jpg</url>
            <title>Stories by Ishita Gupta on Medium</title>
            <link>https://medium.com/@ishitagupta8720?source=rss-787d553e8301------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 03:51:50 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ishitagupta8720/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Gender Inequality In AI]]></title>
            <link>https://ishitagupta8720.medium.com/gender-inequality-in-ai-6fb60c953c7?source=rss-787d553e8301------2</link>
            <guid isPermaLink="false">https://medium.com/p/6fb60c953c7</guid>
            <category><![CDATA[gender-equality]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[gender]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Ishita Gupta]]></dc:creator>
            <pubDate>Tue, 23 Nov 2021 06:11:38 GMT</pubDate>
            <atom:updated>2021-11-23T06:11:38.716Z</atom:updated>
            <content:encoded><![CDATA[<p>Gender inequality has been prevalent in our society from a long time and continues to do so. Be it voting rights or right to work, women always have had to fight for themselves. We also face the problem of pay gap, lack of women representation and other deeply ingrained stereotypes. While fighting for complete gender equality, hopes were placed that artificial intelligence will identify and close these gaps through claims of a more objective and data driven approach but ironically this just turned out to be another barrier for women. It is also found to carry the same old stereotypes.</p><p><strong>Where AI Gender Bias Comes from?</strong></p><p>These biases enter Artificial intelligence through humans only. Firstly, Algorithms, that is a set of rules is what AI essentially functions on. These algorithms take in large data sets and use them to recognize patterns, make predictions and output the course of action to be followed. With time and experience, AI improves automatically which makes it seem like it has a mind of its own but at the granular level humans have collected the data that goes into datasets and these creators have their inherent gender assumptions and biases. So, the data used to train AI is just the representation of our experiences, behaviors, and decisions as humans. Developers tell the algorithm the variables that need to be considered in decision making and those in turn lead to penalization of certain communities and gender. Hence this would lead AI to make a biased decision about certain genders.</p><p>Second aspect of inequality is how artificial intelligence is reinforcing some gender stereotypes. It’s fairly noticeable that women’s voices are used for most of the virtual assistants powered by AI. This action further stigmatizes women on a global scale.</p><p><strong>In what ways is this AI bias affecting women?</strong></p><p>For example, imagine that there is a women owned small business and they apply for a loan to scale up. But soon they find out that they are rejected while a similar business where owners were men got approved. Both businesses had had similar assets and savings, but the only difference was the gender. The credit application was not evaluated by a human but by a machine which is often the case with banks. Historically more men have received approval for their applications than women so the algorithm decided to reject the women application and found men’s application to be more worthy. Sadly, this is not hypothetical. There are now such popular incidents.</p><p>Automated resume screeners reject women in hiring drives and facial recognition disproportionately fails for women. Among the systems which were identified as having gender biases, in 61.5%, unfair allocation of information, opportunities and resources for women existed. These systems included ad systems and hiring software that deprioritized women’s applications. Health industry is a major space where this bias can be seen. Lack of women bodies in medicine trials have led to exclusion of women and leads to AI struggling to detect diseases in women. Health apps tracking everything to do with health omitted menstruation. Another example is Translation software, learning from huge quantities of online available text, has taken gender neutral English terms like nurse and doctor and returned gendered translations, reinforcing the natural stereotype of men being doctors and females being nurses. We also find that AI systems engage in derogatory behavior towards marginalized genders and only recognizes the gender binary. AI has also shown a negative impact on economic stand of women. On average, compared to the 9 percent of men, women face 11 % risk of losing their job due to automation.</p><p><strong>Solutions</strong></p><p>This brings us to consider what can be done to rectify this. Gender diversity and inclusion among development and management teams is the most important step. Social biases are expected given that humans create these systems. In order to avoid that, more women should be included in the development process which will increase the diversity of thought. Action should be taken to make sure diversity is priority and policies and practices need to formed to support inclusion. The voices of women and non-binary individuals should actively instead of passively, be centralized in the development team.</p><p>Universities and Companies can take steps to ensure smooth transition of women into AI. This would include investment in training and technical programs educating women about artificial intelligence and need to eradicate the gender bias.</p><p>In addition to driven and active hiring of more women at all levels, companies in Artificial intelligence and automation industry should engage and collaborate with women’s organizations and gender experts from the beginning. To fill data gaps, feminist data can be used. Feminist data practices include going in depth of how power works and using data to counter unequal power structures. It also includes inclusion of other genders other than the gender binary, and harmonizing diverse perspectives with prioritizing indigenous and local knowledge. This data can help include and centre the experiences and voices of marginalized individuals</p><p>Apart from this, recognition is needed that algorithms and data is not gender neutral and we need to act upon it. Datasets should go under assessment for under-representation of varying gender identities and problematic underlying inequities. Tackle the gender gaps by partnering up with social leaders. Diagnose the issues and incorporate feminist data practices.</p><p>Lastly, for responsible artificial intelligence, gender sensitive governance approaches should be established. AI ethics governance structure should be developed keeping gender diversity in mind.</p><p><strong>Conclusion</strong></p><p>Gender Bias in AI systems is a grave problem affecting lives of women and non-binary people in massive ways. This needs to be acknowledged immediately. Gender equity is extremely important to reach AI fairness. The suggested solutions and not exhaustive but they provide a good start to build upon and ultimately reach a gender-neutral AI world.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6fb60c953c7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Performance Evaluation Metrics in Machine Learning]]></title>
            <link>https://ishitagupta8720.medium.com/performance-evaluation-metrics-in-machine-learning-3837e22fa676?source=rss-787d553e8301------2</link>
            <guid isPermaLink="false">https://medium.com/p/3837e22fa676</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[evaluation-metric]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Ishita Gupta]]></dc:creator>
            <pubDate>Sun, 11 Apr 2021 10:08:15 GMT</pubDate>
            <atom:updated>2021-04-11T10:08:15.401Z</atom:updated>
            <content:encoded><![CDATA[<p>Evaluation of a machine learning algorithm is an extremely essential process. The whole idea of building a machine learning model works on the principle that you build one, get the feedback, and improve till you get the desired accuracy and results. The motive of a good analyst or a data scientist would not be to just build a model but to create one which gives the best results and to achieve the best, it’s important to work on the robustness of the model. Receiving appropriate feedback and working on it decides the growth curve of the model and that’s where evaluation comes in hand. It describes the performance of the model.</p><p>Evaluation metrics are defined simply as ways of evaluation. There are various metrics that can be used. They must be carefully understood and chosen because the performance of the algorithm and the weightage given to different features in the result is completely dependent on your choice. Now you may wonder why are there so many different metrics available and the answer to that would be, each metric measures the performance in a different way, and your model may give a great answer to one of them but might perform poorly in terms of another. Also, some metrics evaluate a classification problem better and others evaluate a regression problem better. Every single one of them has a different significance and understanding all of them together and applying them accordingly is what would make your model perfect.</p><p>Here we will talk about 12 such evaluation metrics:</p><ol><li>Confusion Matrix</li></ol><p>2. Classification Accuracy</p><p>3. Precision</p><p>4. Recall</p><p>5. Specificity</p><p>6. F1 Score</p><p>7. ROC</p><p>8. AUC</p><p>9. Log Loss</p><p>10. Mean Absolute Error</p><p>11. Mean Square Error</p><p>12. Root Mean Squared Error</p><h3>1. Confusion Matrix</h3><p>As the name suggests, a confusion matrix is a matrix that describes the performance of a model. Its size is n*n where n is the number of classes. Usually, a confusion matrix is used for classification problems. It has two dimensions, actual and predicted. Along with that, it has 4 categories:</p><p>True positive: The case where the algorithm predicted true and the actual result was also true</p><p>True negative: The case where the algorithm predicted false and the actual result was also false.</p><p>False-positive: The case where the algorithm predicted true but the actual result was false</p><p>False-negative: The case where the algorithm predicted false but the actual result was true</p><h3><strong>2. Classification Accuracy</strong></h3><p>It is defined as the number of correct predictions made as a ratio of a total number of input samples. It is most popular for classification problems.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/373/1*0TNZIR7SnrorfzLHAZ-64g.png" /></figure><h3><strong>3. Precision</strong></h3><p>Precision is defined as the actual number of correct positive results divided by the number of positive results predicted by our model that is if we are building the predictive model of cancer then precision tells what proportion of predicted cancer patients actually have cancer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/312/1*lcP1PS78sY7bv7K2CiGqsg.png" /></figure><h3><strong>4. Recall</strong></h3><p>The recall is defined as the number of correct positive results divided by the number of all relevant samples that are in a cancer predictive model recall would tell what proportion of cases that should have been predicted as cancer positive are actually predicted positively by the model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*Rhb7cnCkw2-snZMiO0005Q.png" /></figure><h3><strong>5. Specificity</strong></h3><p>Specificity is defined as the true negative rate or basically the actual number of negative cases to everything that should have been predicted as negative by the model.</p><h3><strong>6. F1 Score</strong></h3><p>F1 score is basically a score made out of both precision and recall. It is defined as the harmonic mean of both for a classification problem. It judges both the precision and robustness of our model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/403/1*MKECUPyw2XSopVv5tgP8eA.png" /></figure><h3>7. ROC (Receiver operating characteristic) curve</h3><p>The ROC curve is created by plotting the <a href="https://en.wikipedia.org/wiki/True_positive_rate">true positive rate</a> (TPR) against the <a href="https://en.wikipedia.org/wiki/False_positive_rate">false positive rate</a> (FPR) at various threshold settings. The true positive rate is also known as <a href="https://en.wikipedia.org/wiki/Sensitivity_(tests)">sensitivity</a>, <a href="https://en.wikipedia.org/wiki/Precision_and_recall#Definition_(classification_context)">recall</a>, or probability of detection in machine learning. The false-positive rate is also known as the <a href="https://en.wikipedia.org/wiki/Information_retrieval#Fall-out">fall-out</a>, 1-specificity, or probability of false alarm.</p><p>Roc curves have the benefit that even if the proportion of positive to negative instances differ, the Roc curve won’t be affected.</p><h3>8. AUC (Area Under the ROC Curve)</h3><p>As the name suggests, AUC is the area under the ROC curve. AUC-ROC metric basically tells us about the capability of the model in distinguishing the classes. It is based on varying threshold values for classification problems. It lies between [0,1] and the higher the AUC, the better is the model. It is best used for binary classification problems.</p><h3>9. LOGLOSS (Logarithmic Loss)</h3><p>This metric is also called logistic regression loss or cross-entropy loss. It is nothing but a negative average of the log of corrected predicted probabilities for each instance. It is basically defined on probability estimates and measures the performance of a classification model where the input is a probability value between 0 and 1. Log Loss gradually declines as the predicted probability improves. So, lower the log loss, better the model. However, there is no absolute measure on a good log loss and it is use-case/application dependent.</p><h3>10. Mean Absolute Error (MAE)</h3><p>It is the simplest error metric used in regression problems. It is basically the sum of the average of the absolute difference between the predicted and actual values. In simple words, with MAE, we can get an idea of how wrong the predictions were. Mathematically it is represented as</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/303/1*dpp1yxQVJsT7ieiN7qhYfA.png" /></figure><h3>11. Mean Square Error (MSE)</h3><p>Mean square error is similar to MAE, the only difference being that MSE takes the average of the <strong>square </strong>of the difference between the original values and the predicted values. The advantage of MSE being that it is easier to compute the gradient, whereas Mean Absolute Error requires complicated linear programming tools to compute the gradient. As we take a square of the error, the effect of larger errors become more pronounced then smaller error, hence the model can now focus more on the larger errors.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/312/1*kPAXD3T2FV83C8wXEWVMvg.png" /></figure><h3>12. Root mean squared error(RMSE)</h3><p>RMSE is the most popular method of evaluation for regression problems. It is a standard way to measure the error of a model in predicting quantitative data. It follows an assumption that errors are unbiased and follow a normal distribution. RMSE metric is given by:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/358/1*Of_nzgkTkq0GQxfuiIPR7w.png" /></figure><p>where, N is the Total Number of Observations.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3837e22fa676" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A review of ‘To Kill a Mockingbird’]]></title>
            <link>https://ishitagupta8720.medium.com/a-review-of-to-kill-a-mockingbird-d09c435e8f7b?source=rss-787d553e8301------2</link>
            <guid isPermaLink="false">https://medium.com/p/d09c435e8f7b</guid>
            <category><![CDATA[reading]]></category>
            <category><![CDATA[books]]></category>
            <category><![CDATA[book-review]]></category>
            <category><![CDATA[review]]></category>
            <category><![CDATA[literature]]></category>
            <dc:creator><![CDATA[Ishita Gupta]]></dc:creator>
            <pubDate>Fri, 10 Jul 2020 07:28:25 GMT</pubDate>
            <atom:updated>2020-07-10T07:28:25.809Z</atom:updated>
            <content:encoded><![CDATA[<p>If you are someone who knows me, then you certainly must have heard me mention how much I love this book because it is absolutely amazing.</p><p>To kill a Mockingbird is a story from the point of view of young girl Jean scout who shares her life with her older brother Jem Finch and her father Atticus Finch. Life is simple for her. She is about to begin school and spends summer vacation with her brother Jem and her neighbor Dill. Its church day on Sunday and life discussions with Atticus are regular.</p><p>Things are good until Atticus takes up a case of a black man falsely accused of raping a white girl. The whole town is swept in the case and while he solely defends the man, Scout and Jim are forced to face the dark side of their society which includes racism, prejudice, and hostility</p><p>To kill a mockingbird is a classic, the term which carries the notion of being tough with words but you’ll be surprised at how easy and fun it is to read this one, which leaves a profound impact on you at the same time. Along the journey, one tends to get lost in the childish innocence of the way Scout tries to perceive all the aspects of her life, from school to her town.</p><p>It maintains the humor of the story at times like when her teacher had to make her stop reading because first graders were not supposed to read or when she judges her brother’s adolescence period and comments on his annoying self. On the other hand, when she questions different situations like the social outcast boo Radley and racism related to her father’s case, it makes us rethink our own beliefs and prejudices which we carry as a society and the loss of empathy towards others which a child could not understand.</p><p>One of the major characters of the story and my favorite is Atticus. He is the person to whom Scout goes with her questions. Atticus Finch showed me the courage to stand up for what’s right, even against the whole world and the story shows it’s not easy. Life isn’t fair, your right will not be shared with others and you will face consequences for it, but to stand in the face of it and still hold your opinion is your duty.</p><p>The book is way ahead in time as during a period when racism was prevalent, Atticus took an action. He knew before taking the case that he does not stand a chance but the idea of making people consider the possibility was a victory in itself for him. As he tells scout “It’s when you know you’re licked before you begin but you begin anyway and you see it through no matter what. You rarely win, but sometimes you do.”</p><p>Apart from his professional life, in his personal life, he is a great father too. With Jean wondering about everything around her, Atticus directs her in the right direction. He tells her about understanding others and their perspectives, and that judgment is not justified on any basis because you have not lived their life. He tells her about empathy, about its never okay to hate anyone and life should be lived in peace. He does not control his children but let them grow and guide them whenever necessary.</p><p>Living a household surrounded by conflicts, Scout and Jem still have a positive impact on them. They are called nigga lovers, verbally abused by neighbors, left friendless and without any support but despite all, showing the same courage as their father, just in simpler ways, they kept their head high. They were brave and despite being young, knew what was right, believed in it, and fought for it in their manner.</p><p>Reading To Kill a Mockingbird is an amazing journey in itself. It left me with a new set of thoughts and perspectives to look the world with. Every time I read it, I learn something different. Scout, Jem, and Atticus are characters that don’t leave you even after the book. You will carry Scout’s innocence and Atticus’ morale with you and this one will surely earn a spot on your keeper shelf.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d09c435e8f7b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Bellman-Ford Algorithm]]></title>
            <link>https://medium.com/analytics-vidhya/the-bellman-ford-algorithm-a0801afc333f?source=rss-787d553e8301------2</link>
            <guid isPermaLink="false">https://medium.com/p/a0801afc333f</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[tutorial]]></category>
            <category><![CDATA[data-structures]]></category>
            <category><![CDATA[computer-science]]></category>
            <dc:creator><![CDATA[Ishita Gupta]]></dc:creator>
            <pubDate>Sun, 03 May 2020 08:29:54 GMT</pubDate>
            <atom:updated>2020-05-14T13:51:31.471Z</atom:updated>
            <content:encoded><![CDATA[<p>You’re Given a Weighted Graph. You know the source and need to reach all the other vertices through the shortest path. What do you do to solve this problem? You choose Dijkstra’s Algorithm. But what if there are negative weights included? Dijkstra’s can’t work on this problem then. We now need a new algorithm.</p><p>The Bellman-Ford algorithm is an algorithm similar to Dijkstra that is it finds the shortest path in a graph from a single source vertex to all other vertices in a weighted graph but it works even when there are negative weights.</p><p><strong>THE GLOOMY GRAPH</strong></p><p>A gloomy graph is what I call a graph with negative weights. It’s not actually called this, but the name kind of suits, doesn’t it? A negative weight is just like a positive weight, a value on the top of an edge. Now, why would anyone have a graph with negative weights? Because they are not as useless as they may seem. Negative weights can explain a lot of phenomena, like your savings where a positive edge can represent money spent but a negative edge will be the one you would want to take as it will represent cash gained, or heat reactions, where each positive weight will stand for heat dissipation, each negative weight will show heat absorption and the set of reaction where minimum energy is found has to be calculated.</p><p>But then what about the gloomy part? Here it comes. Make way for <strong>negative cycles</strong>. This is something to be careful of. A cycle is a path where the first and the last vertex is the same, that is, it is a closed path. So a Negative cycle becomes a cycle that sums up to a negative value. Shortest path algorithms are not able to detect such cycles and give incorrect results. This is something that even the Bellman ford algorithm can’t defeat. Look at this illustration below to get a better idea.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/371/0*DgSEF91j8TZspKWF.jpg" /></figure><p>In this image, the vertices B, C, and D form a cycle where the starting node is B which is also the ending node. Also, this cycle acts as a negative cycle because the total value sums up to a negative value -1.</p><p><strong>THE ALGORITHM</strong></p><p>The first point to know about the algorithm would be that is doesn’t work on a greedy algorithm like Dijkstra. Yes, they are similar but not the same, duh! A dynamic programming approach is taken to implement this program. Moving on to understanding this algorithm more.</p><pre>function bellmanFord(G, S)<br>	for each vertex V in G<br>			D[V] &lt;- infinite<br>			<br>	D[S] &lt;- 0<br>	for each vertex V in G				<br>		for each edge (U,V) in G<br>		  tempDistance &lt;- D[U] + edge_weight(U,V)<br>			if tempDistance &lt; D[V]<br>			   D[V] &lt;- tempDistance<br>			   </pre><pre>	for each edge (U,V) in G<br>		If D[U] + edge_weight(U, V) &lt; D[V]<br>			Error: Negative Cycle Exists<br>                        return</pre><pre>	print D[]</pre><p>Don’t get into panic mode just yet. We’ll discuss every bit.</p><p>Telling the definition first, the Bellman-Ford algorithm works by first <strong>overestimating the length</strong> of the path from the starting vertex to all other vertices. Then it iteratively <strong>relaxes those estimates</strong> by finding new paths that are shorter than the previously overestimated paths. Finally, it <strong>checks for negative cycles</strong></p><p>In simpler terms, let V be the number of vertices, E be the number of edges, S be the starting node, and D be an array which tracks the best distance between the source node and rest vertices. Okay?</p><p>Following the step of overestimation, we set each entry in the array to +infinity, similar to Dijkstra. This is because the distance to each node initially is unknown so we assign the highest value possible. Now we assign D[S]=0 for obvious reasons, as the minimum distance from source to source is, take a guess? obviously 0. So we have reached the state shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/355/1*N0SMJtyDlvV5MR3hyuHVWw.png" /></figure><pre>for each vertex V in G<br>			D[V] &lt;- infinite<br>			previous[V] &lt;- NULL<br>	distance[S] &lt;- 0</pre><p>Now, infinite levels are too high for us, stress is building up. So its time to relaaaaax! In this step, we aim to find what we have been looking for altogether, the shortest path to each vertex. We start a loop that will run V times for each edge because in the worst case, a vertex’s path length might need adjustment V times. In the loop, for each edge, we take the value of the vertex from where the edge is starting (D[U]) and add it to the edge cost. This added value is them compared to the value of the vertex where the edge is ending (D[V]). If the sum value is found to be less, the end vertex value (D[V]) becomes equal to the sum.</p><pre>for each vertex V in G				<br>		for each edge (U,V) in G<br>		  tempDistance &lt;- D[U] + edge_weight(U,V)<br>			if tempDistance &lt; D[V]<br>			   D[V] &lt;- tempDistance<br>			   </pre><p>Taking an example, we are gonna go through a few steps to understand the functioning.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*qo6RkqhS1077NIwnkp8zGg.png" /></figure><p>In this graph, 0 is considered as the source vertex. Starting the loop, the first edge we take is 0 →1, after which 1 is assigned the value 5. Next, the edges 1→2, 1 →5 and 1 →6 are taken, due to which the value of 6 becomes (5+60 i.e the cost of source vertex 1 added to the cost of the edge,60)= 65, 2 becomes (5+20)= 25 and 5 becomes (5+30)= 35. Similarly, the value of 3 becomes 35.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/615/1*1XOL4lqcQAqESSJmkxe_TQ.png" /></figure><p>After determining the cost of 3, we take the next edges, which are 3 →2 and 2→4. <strong>This makes the value of 2 as ( 35 -15)=20</strong> and the value of 4 as 100. 20 is a reduced value from the earlier 25.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/583/1*KPjnLVcJ4hsmIaUNQyZtxQ.png" /></figure><p>Continuing in the loop, the edge 4 →9 makes the value of 9 as 200. <strong>Now another point of optimization to notice carefully.</strong> We take the edge 5→6 which makes the value of 6 (35+5)=40. Similarly, taking the edge 5→4 totals the value of 4 to 60. These values are less or more optimized than the previous values.</p><p>So that is how the step of relaxation works</p><p>Moving on the third and the last step, Spotting our enemy, <strong>the negative cycles. </strong>Now, why does our algorithm fail in front of negative cycles? Its because Bellman ford Relaxes all the edges. It finds a global optimum solution and so if there is a negative cycle, the algorithm will keep ongoing indefinitely. It will always keep finding a more optimized, that is, a more negative value than before. So it&#39;s necessary to identify these cycles. But how?</p><p>We run the same loop again, taking edges and relaxing them. As we have already reached an optimized value already, so if we can relax an edge again that means we have encountered a negative cycle. As soon as that happens, the IF condition becomes true and the return statement is executed, ending the function else the array D is printed.</p><pre>for each edge (U,V) in G<br>		If D[U] + edge_weight(U, V) &lt; D[V]<br>			Error: Negative Cycle Exists<br>                        return</pre><pre>print D[]</pre><p>We have now successfully completed the Bellman-Ford algorithm. Yay!</p><p><strong>COMPARING DJIKSTRA AND BELLMAN-FORD</strong></p><p>We have already gone through the main differences that are</p><ul><li>Both are the shortest path algorithms but Djikstra lowers its weapons against negative weights whereas Bellman-Ford wins the war.</li><li>Djikstra uses the greedy approach whereas Bellman-Ford uses dynamic programming.</li></ul><p>The difference that we haven’t touched so far is</p><ul><li>Djikstra is fast. The time complexity of Bellman ford is higher than that of Djikstra. But if optimal time is not the highest priority then no doubt Bellman Ford is a better shortest path algorithm.</li></ul><p>This completes our journey of the Bellman-Ford algorithm. I’m sure Richard Bellman and Lester Ford Jr would be proud of you, just sleeping and smiling in their graves. ( Yes I sneaked in a little history fact there!).</p><p>I hope you guys liked this blog. Do leave some feedback, I am really looking forward to it. Enjoy!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a0801afc333f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/the-bellman-ford-algorithm-a0801afc333f">The Bellman-Ford Algorithm</a> was originally published in <a href="https://medium.com/analytics-vidhya">Analytics Vidhya</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>