<?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 Yashrajvishwakarma on Medium]]></title>
        <description><![CDATA[Stories by Yashrajvishwakarma on Medium]]></description>
        <link>https://medium.com/@yashrajvishwakarma.31?source=rss-a7fae3e99bf7------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*h8dfXa7EW5ETVj8t</url>
            <title>Stories by Yashrajvishwakarma on Medium</title>
            <link>https://medium.com/@yashrajvishwakarma.31?source=rss-a7fae3e99bf7------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 08:58:53 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@yashrajvishwakarma.31/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[Album Review: Plastic Beach (pt. 1)]]></title>
            <link>https://medium.com/@yashrajvishwakarma.31/album-review-plastic-beach-pt-1-4ed73e1e1377?source=rss-a7fae3e99bf7------2</link>
            <guid isPermaLink="false">https://medium.com/p/4ed73e1e1377</guid>
            <category><![CDATA[music]]></category>
            <category><![CDATA[alternative-music]]></category>
            <category><![CDATA[gorillaz]]></category>
            <category><![CDATA[damon-albarn]]></category>
            <category><![CDATA[blur]]></category>
            <dc:creator><![CDATA[Yashrajvishwakarma]]></dc:creator>
            <pubDate>Tue, 22 Oct 2024 05:37:35 GMT</pubDate>
            <atom:updated>2024-10-22T05:37:35.503Z</atom:updated>
            <content:encoded><![CDATA[<h4>Few albums have aged better.</h4><p>When Snoop Dogg rapped “Welcome to the World of the Plastic Beach” on the second track of Gorillaz’s third album, little did listeners know how well the album’s concept would age in the 21st century.</p><h4>Track-by-track discussion and analysis</h4><p><strong>Orchestral Intro &amp; Welcome to the World of the Plastic Beach</strong></p><p>Few albums start off with an orchestral intro accompanied by oceanic sounds (a concept which sounds nonsensical at first thought), but Gorillaz, like always, manage to pull it off. The brief intro smoothly segues into Snoop Dogg (sticking to Gorillaz’s trend of unexpected collaborations) remarking, “The revolution will be televised” on the next track, ominously introducing us to the plastic-dominated world in which the album is set. Overall, while unconventional, the songs effectively set the tone of the album, providing a glimpse into the musical experimentation and motifs that will be referenced throughout the album.</p><p>Score: 8/10</p><p><strong>White Flag</strong></p><p>Even though it wouldn’t be a Gorillaz album if each track sounded the same, this collaboration with the National Orchestra for Arabic Music and Bashy and Kano on the same song simply has no business being this good. The rappers’ smooth flow with lyrics such as “This ain’t Atlantis, are you sure? \ I nearly suffocated when I touched the shore” sandwiched between Middle-eastern instrumentals is classic Gorillaz: making unorthodox yet songs which <strong>always </strong>communicate a powerful message through its lyricism.</p><p>Score: 7.5/10</p><p><strong>Rhinestone Eyes</strong></p><p>It isn’t often that Damon Albarn is by himself on a Gorillaz song, but when he is, he scarcely disappoints as evidenced on this track, which has gradually become a fan favourite, racking up nearly 500 million streams. It’s also a personal favourite of mine from Gorillaz, along with Pirate Jet (the closing track on Plastic Beach) and DARE (from Demon Days). With the noticeable electronic influence on the beat, provocative lyrics like “Nature’s corrupted in factories far away” and the background singers repetitively singing “That’s electric-tric-tric..”, Gorillaz continues to impress by maintaining the theme of widespread pollution due to plastic, while also making each song wildly different from those which preceded it; four songs in, and Plastic Beach has already featured hip-hop, electronic, orchestral and Middle Eastern music on each song.</p><p>Score: 10/10</p><p><strong>Stylo</strong></p><p>A song like Stylo, which mixes electronic and hip-hop to great effect, is the type of song which would normally be a deep cut overshadowed by the more popular songs. However, in classic Gorillaz fashion, Stylo, which features ambiguous lyrics (“Power on the motherboard, yes”) and a distinctly uncommercial sound, has managed to become one of the most well-known songs on the album, accumulating over 130 million streams, serving as a testament to the average listener’s recognition and appreciation of Gorillaz’s unconventional musical style on this album in order to communicate the overarching message of a general overconsumption of plastic.</p><p>Score: 8.5/10</p><p><strong>Superfast Jellyfish</strong></p><p>Now <em>this, </em>ladies and gentlemen, is a deep cut, and a musically potent one at that. Not all songs start out with a microwave sound, and perhaps my favourite Gorillaz lyric, “Throw in a plastic donut, just enjoy the gritty crunch that tastes just like chicken.”. Despite being released in 2010, this lyric (and by extension, the album) acts as a scarily accurate depiction of the general perception of overproduced fast foods as being “artificial” or as Damon Albarn would probably put it as “plastic-like”. Additionally, the chorus’ lyrics, namely “Gotta have it superfast” and “The sea is radioactive” highlight not only humans prioritizing the speed at which food is received (rather than quality), but also hinting at the environmental impact of plastic consumption, which becomes an important idea further explored by Albarn in the latter half of the album, <strong>which I will be discussing in a future article.</strong></p><p>Score: 10/10.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4ed73e1e1377" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Anatomy of a Fall: A Discussion]]></title>
            <link>https://medium.com/@yashrajvishwakarma.31/anatomy-of-a-fall-a-discussion-7a0aa02521b0?source=rss-a7fae3e99bf7------2</link>
            <guid isPermaLink="false">https://medium.com/p/7a0aa02521b0</guid>
            <category><![CDATA[cinema]]></category>
            <category><![CDATA[medium]]></category>
            <category><![CDATA[opinion]]></category>
            <category><![CDATA[movies]]></category>
            <category><![CDATA[film]]></category>
            <dc:creator><![CDATA[Yashrajvishwakarma]]></dc:creator>
            <pubDate>Wed, 06 Mar 2024 19:14:59 GMT</pubDate>
            <atom:updated>2024-03-06T19:14:59.983Z</atom:updated>
            <content:encoded><![CDATA[<h4>Spoiler: It’s not really an anatomy of a fall.</h4><p>Despite its title and billing as a “legal drama”, the film spends astonishingly little time on the facts of the case, and instead provides an unexpected and reflective dive into the very essence of human nature and reality.</p><p>Okay, maybe I’m being a bit dramatic. But the film really was quite something.</p><p>Starting off with a casual conversation between two characters, the film rapidly transitions into periods of prolonged intensity, especially during the (many) courtroom scenes and Sandra and Samuel’s recorded argument.</p><p>The courtroom. Now, while I may not be an expert in law, the Succession-esque cinematography certainly did an apt job of portraying a fine balance between the seriousness and absurdity (see: 50 Cent) of the situation.</p><p>But the <strong>lack </strong>of an actual anatomy of Samuel’s fall throughout shines light on a key fact continually reiterated by Vincent: the reality of whether Sandra killed her husband doesn’t really matter; all that matters is how others perceive it. This is best witnessed towards the end, which features the introduction of excerpts of her book which discuss a minor character’s obsession with murdering her husband. Pivoting from this excerpt (and parallels between Sandra’s life experiences and older novels), the prosecution and media dangerously conflate fiction and reality as one and the same, when that just <strong>isn’t the case. </strong>Fiction is fiction, and reality is reality.</p><p>But in any trial, the outcome almost solely hinges on eyewitness testimony. And Daniel’s unique case demonstrates why witnesses can often be wrong.</p><p>Putting aside his visual impairments, his sudden change in belief in his location at the beginning of the film is the first subtle indicator that Daniel’s unreliability may have major implications for the plot.</p><p>Fast-forward to the end of the film, and said implications are ever-present when he consciously poisons his dog to prove a (flawed) point, and also recalls specific dialogue from his father from years ago. Both facts have their own frightening implications; it’s obvious that Daniel is an intelligent child, yet his choice to feed Snoop aspirin and then draw far-fetched conclusions about his father’s mental state (despite him having suffered from supposed memory loss due to trauma at the beginning of the film) both suggest that, perhaps Daniel hoped to sway the outcome in a particular direction (not guilty) out of a fear of losing both his parents, even if he himself didn’t know the truth.</p><p>But, in the end, it did work, as Sandra was acquitted. The events leading to the outcome serves as a reflection of today’s society as a whole, where the emotive &amp; abstract power of pathos (namely Daniel’s condition and testimony) seemingly trumps any degree of objecitivity provided by ethos (creeibility) and logos (logic).</p><p>Summing it up, Anatomy of a Fall was a surprisingly brilliant film (and certainly deserving of its 5 Oscar nominations), which brilliantly dissected the nuanced nature of perspective and objectivity through the lens of a unique murder case, where the sole eyewitness did not see anything at all, and yet influenced the trial in its entirety.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7a0aa02521b0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Maths of Cryptography #1: Elliptic Curves]]></title>
            <link>https://medium.com/@yashrajvishwakarma.31/the-maths-of-cryptography-1-elliptic-curves-414fb9a4d72b?source=rss-a7fae3e99bf7------2</link>
            <guid isPermaLink="false">https://medium.com/p/414fb9a4d72b</guid>
            <category><![CDATA[elliptic-curve]]></category>
            <category><![CDATA[math]]></category>
            <category><![CDATA[cryptography]]></category>
            <category><![CDATA[mathematics]]></category>
            <category><![CDATA[bitcoin]]></category>
            <dc:creator><![CDATA[Yashrajvishwakarma]]></dc:creator>
            <pubDate>Sun, 12 Nov 2023 09:04:56 GMT</pubDate>
            <atom:updated>2023-11-12T09:04:56.716Z</atom:updated>
            <content:encoded><![CDATA[<h4>All about symmetries.</h4><p>This new series of articles will focus on the underlying mathematics behind the emerging field of cryptography. Today’s article focuses on public-key cryptography, specifically the algorithms used to generate secure public-private key pairs. Traditionally, the Rivest-Shamir-Adleman (RSA) algorithm was used. However, developments in the field have enabled new &amp; more efficient algorithms to be introduced, such as Elliptic Curve Cryptography (ECC), which we will be exploring in this series.</p><h4>What is an elliptic curve?</h4><p>Simply put, an elliptic curve is a curve represented by the equation <em>y² =x³ +ax+b, </em>where <em>4a³+27b² is not equal to zero. </em>This additional condition is known as the elliptic discriminant, which you can learn more about <a href="https://mathworld.wolfram.com/EllipticDiscriminant.html">here</a>.</p><p>An example curve known as secp256k1: <em>y² = x³ +7 </em>is shown below, which is used in Bitcoin’s public-key cryptography system.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/225/0*Xg_2eMXwuII0INE2" /><figcaption>secp256k1</figcaption></figure><p>One of the first things that can be noticed from the image is the symmetrical nature of the curve. For each point <em>(x, y) </em>on the curve, its reflection on the x-axis <em>(x, -y) </em>is also on the curve. This property, coupled with an elliptic curve’s differentiability and continuity, allows us to later define an <strong>abelian group </strong>over a <strong>finite field<em>. </em></strong>These concepts will be discussed in-depth in future articles, but are briefly outlined below.</p><h4>Integral and rational solutions</h4><p>One of the key aims when investigating elliptic curves is to find the set of rational/integral points on the curve. Before discussing that, it’s important to be aware of the definition of a group.</p><p>A group is essentially a special set of numbers generated from a binary operation, which satisfy certain properties known as the <strong>axioms of group theory.</strong></p><p>These axioms are:</p><ul><li>Closure (also known as totality): When two elements from a group are involved in a binary operation, the resulting value is also in the group.</li><li>Associativity: states that for a given binary operation *, (A * B) * C = A * (B * C), where A, B, C are elements of a group. Simply, this states that the order in which the binary operation is executed is not relevant.</li><li>Identity element: A group G must contain an identity element E such that it leaves the value of other elements unchanged; for example, E * A = A * E = A.</li><li>Inverse element: G must also contain an element A^-1 such that A * A^-1 = E, i.e.: it returns the identity element.</li></ul><p>If a set satisfies these four axioms, then it is a group. A fifth axiom known as commutativity (which states A*B = B*A) must be satisfied for the set to be an <strong>abelian group.</strong></p><p>As will be discussed in the next article, the <strong>group law for elliptic curves </strong>allows us to define an abelian group over an elliptic curve, which in turn helps us in asking questions about the integral and rational solutions to the curve. In fact, it was proved by the Mordell-Weil theorem (see <a href="https://en.wikipedia.org/wiki/Mordell%E2%80%93Weil_theorem">here</a>) that the set of rational points on an elliptic curve is finitely generated (i.e.: a finite group).</p><p>This may be a lot to take in at once, but in future articles, we’ll break down these fascinating results alongside the core concepts of group theory &amp; elliptic curves, and how it all links back to cryptography.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=414fb9a4d72b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[An ML-based Approach to Explore Factors Affecting Income]]></title>
            <link>https://medium.com/@yashrajvishwakarma.31/an-ml-based-approach-to-explore-factors-affecting-income-6d9c79905649?source=rss-a7fae3e99bf7------2</link>
            <guid isPermaLink="false">https://medium.com/p/6d9c79905649</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Yashrajvishwakarma]]></dc:creator>
            <pubDate>Thu, 10 Aug 2023 08:12:21 GMT</pubDate>
            <atom:updated>2023-08-10T08:12:21.368Z</atom:updated>
            <content:encoded><![CDATA[<h4>An in-depth exploration.</h4><p>Developing machine learning models seems like an easy enough task once you conduct a few projects of your own. Choose one of the many models available, train it on the dataset and then evaluate its accuracy.</p><p>In reality though, it’s scarcely that easy.</p><p>Most of the time, developers are busy with the steps that come before model selection and training. Specifically, <strong>data cleaning </strong>and <strong>exploratory data analysis (EDA) </strong>are necessities to obtain a clear idea of the trends in the data, and accordingly preparing it for training.</p><p>In this article, I will be demonstrating the entire ML-development process, from loading in the dataset to finally obtaining a model with high accuracy. Here, I’ll be utilizing a dataset which contains 7 features on over 6000 employees from around the world, which will be used to predict the target variable: income.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*d_alLCy8-BsDIRb3" /><figcaption>Photo by <a href="https://unsplash.com/@kmuza?utm_source=medium&amp;utm_medium=referral">Carlos Muza</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>Getting started</h4><p>You can find the dataset used in this article <a href="https://www.kaggle.com/datasets/sudheerp2147234/salary-dataset-based-on-country-and-race">here</a>.</p><p>Upon downloading the dataset, I created a new folder and placed the .csv file in it, after which I booted up a Jupyter notebook in the directory.</p><p>Next, I set up an .ipynb file, where I first imported the necessary libraries.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/1*4NXzYulQy9D9tHauvVGoNA.png" /><figcaption>Essential libraries for data science</figcaption></figure><p>The <strong>pandas </strong>library is a cornerstone of data science in Python, and is often used for its powerful <strong>DataFrame, </strong>which is often used to store data from external sources, such as .csv files (Comma-Separated Values).</p><p>The <strong>numpy </strong>library is known for its speed and optimization, as well as its extensive features, which allow one to work with arrays, matrices and conduct complex mathematical computations quickly.</p><p><strong>Matplotlib </strong>and <strong>seaborn </strong>are libraries used for graphical visualisations of data (both in 2D and 3D), and in the context of AI/ML, are typically used in exploratory data analysis, as well as in neural networks to see the changes in accuracy over large epochs.</p><p><strong>Scikit-learn </strong>(sklearn) in short, is known for its extensive libraries, which support a wide range of useful operations, such as fitting data to a model, evaluating model accuracies, and splitting data into train and test subsets. Scikit-learn also has numerous ML models for both classification and regression tasks.</p><p>Now that we have our libraries set up, it’s time to load in the data. As our dataset is in a .csv file, we can utilize pandas’ read_csv() function to load it into a DataFrame.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5FKgcEumOs03OQ_oiw9Z8g.png" /><figcaption>Loading in dataset</figcaption></figure><p>The read_csv() function loads in the .csv file into the “data” variable, and data.head() is a method which allows you to view the first five rows of a DataFrame. Conversely, data.tail() is a method which allows you to view the last five rows of a DataFrame.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/217/1*w_ZfbDJfgSqC7iuUOegrpw.png" /></figure><p>We can also acquire more information about our dataset by using data.shape, which tells us the number of rows and columns present in our DataFrame.</p><h4>Cleaning up the dataset</h4><p>Instantly, upon first glance of data.head(), we can see that we have a redundant column named “Unnamed: 0”, which is identical to the row counter already provided to us by pandas. As a result, we can drop this column and only retain the columns which are useful to us.</p><p>If one wishes to remove a column from a Pandas DataFrame, you can use the drop() function, as used below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/606/1*K-NGzq8L7MfaqtXokX1LGA.png" /><figcaption>Eliminating redundant columns</figcaption></figure><p>In the code snippet above, we are re-assigning the DataFrame to itself, but with one key difference; by using data.drop(), the column with name “Unnamed: 0” will be removed from the DataFrame <strong>(it is important to specify axis=1, otherwise you may run into issues).</strong></p><p>After removing redundant columns, the next step is to look for any discrepancies in the data itself. To do this, I iterated through each column in the DataFrame and generated all the unique values in each of them.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iifYRHEMg3QpBLB5zgdB5Q.png" /></figure><p>The .unique() method returns each distinct value in that particular column. The output of this code snippet is shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mp2TSfO5BSH8P1n5kh_ydg.png" /></figure><p>Upon seeing this, I noticed a few key details:</p><ul><li>There were NaN (not a number) values in the dataset, which had to be removed.</li><li>The “Job Title” column had too many distinct values, and converting all of these categorical values into numerical ones would just take <strong>too much time. </strong>If you work with this data yourself, what you do with this column is up to you, but I decided to sacrifice a few points of accuracy rather than spending ages on working with this column.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/346/1*fwwdtCM1i3S1Qeon7ClwbA.png" /><figcaption>Removing NaN from dataset</figcaption></figure><p>To resolve the first issue, I decided to use the dropna() function in pandas to remove all rows of data which contained even a single NaN value. Next, I checked the change in the dataset’s size by once again using data.shape:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/214/1*wLP78_Te-3WaDU8Ax5vzUQ.png" /><figcaption>Reduction in no. of rows</figcaption></figure><p>As seen above, the new dataset has 6698 rows of data, a decrease from the initial 6704, indicating that there were only 6 rows with NaN values.</p><p>In this case, simply removing those rows was fine due to the small number. However, if there is a large number of NaN values, then it is best to use an Imputer (found in the sklearn library), which can be used to fill in the missing data points while preserving the inherent patterns present in the dataset.</p><h4>Exploratory Data Analysis</h4><p>Now, it’s time to look for correlations between the features and the target variable.</p><p>First, I created a visualisation of employee age against salary, which yielded the graph below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/838/1*OUhplYRME8kLiiBjMJKBhw.png" /><figcaption>Age against Salary</figcaption></figure><p>As seen above, there is most definitely a positive correlation between age and salary. However, much of the data is skewed towards the younger age bracket (between 20 and 40 years), who typically display lower incomes. While the overall trend is unlikely to change, having more data for older age groups could paint a more vivid picture about the nature of the trend.</p><p>Next, creating a visualization of “Years of Experience” against income yields the following graph:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/875/1*VYrsTrCuuVrvX6LyHjdpQg.png" /><figcaption>YoE against salary</figcaption></figure><p>As one would expect, the trend for YoE and salary is highly similar to the previous graph of age and salary, which is rather obvious, considering age is pretty much directly related to one’s work experience. As a result, there isn’t much to look at here.</p><p>However, the following graphs provide much more interesting insights.</p><h4>Working with categorical variables</h4><p>ML models don’t understand categorical data such as “Male” and “Female”; instead, they only understand numbers. As a result, categorical variables often need to be converted into numerical data.</p><p>First, <strong>for Gender, “0” corresponds to Male, “1” corresponds to Female, and “2” corresponds to Other.</strong></p><p>Using this fact, we will be creating a special type of graph known as a <strong>swarmplot, </strong>which is used when one variable is categorical and one is numeric.</p><p>Coding a swarmplot using the seaborn library yields the graph below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/821/1*fUpTX_a1FJ1ayMT6SzYKyQ.png" /><figcaption>Gender and Salary</figcaption></figure><p>This graph provides us with a fascinating insight into the pre-existing disparity in income present between the genders. For men (shown in blue), the average salary is north of $100000, with a strong concentration of employees with salaries around the $200000 mark. By contrast, women are not only fewer in number, but also are concentrated in the range of &lt;$50000 to ~$125000, with very few female employees earning more than $150000. This is indicative of the lack of opportunity provided to women in higher education, which in turn restricts them from working in higher-paying jobs. Because of this, it is increasingly necessary to increase equality of opportunity all way down to the college admissions process, so that women are also able to earn at those high levels.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/844/1*7IySc0JrMifDPr4njrk0gA.png" /><figcaption>Education Level and Salary</figcaption></figure><p>This graph showcasing the correlation between education level and salary really only highlights the importance of receiving higher-level education in the long-run. People who receive a bachelor’s degree (BS/BA) (shown in blue) are almost entirely bounded within the $50000-$100000 income group. On the other hand, people with a master’s degree (MS) are most commonly found to be earning in the ballpark of $125000. Lastly, those with the highest academic honor, a PhD, almost definitively earn between $150000 and $200000.</p><p>On the flip side, those who drop out, and their highest qualification is a high school education have <strong>much lower </strong>salaries than other college-level qualifications, with high school graduates earning less than $50000 for the most part.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/808/1*nydX5KLenNzwo_Nd9tAaKw.png" /><figcaption>Correlation between nationality and salary</figcaption></figure><p>The graph above looks highly symmetrical across all nations (0 is UK, 1 is USA, 2 is Australia, 3 is Canada, 4 is China), and is representative of the developed nature of all five nations, because of which the degree of opportunity available in these nations is similar across the primary, secondary, tertiary and quaternary sectors.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/818/1*L8H0RPTlQGW8DKYLQUifSA.png" /></figure><p>The swarmplot above, shows a near-identical distribution for all five groups of employees. However, there is one key difference: the density (or the thickness). Race 10 (Asian) people and Race 12 (White) people are much more commonly found in the dataset compared to African-American, Hispanic, or Mixed race people. This serves as an indication of the disparity in the degree of opportunity afforded to different races, because of which some are able to get ahead, while other groups of people are not working in as many jobs. This can have numerous ripple effects on local communities as well as a country’s unemployment, and bringing about greater equality while maintaining a degree of equity is essential.</p><h4>Training &amp; testing models</h4><p>Now that we’ve cleaned up our data and done some EDA to gain a general sense of the patterns in the dataset, it’s time to get to work.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zTK1nPxTVYk1KFT6sA8azg.png" /><figcaption>Splitting dataset into train and test</figcaption></figure><p>This snippet of code is ubiquitous in pretty much every ML model; the train_test_split() function from the scikit-learn library divides X (features) and y (target variable) with a ratio of 70:30.</p><p>This is verified by the values returned by the .shape function, which show that there are 4688 X_train and y_train values (these values will be used to train the model). There are 2010 X_test and y_test values, which will allow us to make predictions with the model and evaluate its performance.</p><p><strong>As our target variable (income) does not belong to a pre-determined set of numbers, I decided to use a regression-based model over a classification one.</strong></p><p>The simplest (and often most effective) model is the LinearRegression() model in scikit-learn, which is why I used it first.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/1*YXuEZBzeqAsezTbdHr3HNA.png" /></figure><p>In the above code snippet, I first initialized the regression model as ‘reg’ and then fitted it on the training set. After this, I predicted values on the X_test set using the .predict() function. Lastly, I used the R² score method to evaluate the accuracy of the model by comparing the predicted values to the true values. Unfortunately, the accuracy was quite low, at only ~66.4%.</p><h4>Switching to XGBoost</h4><p>I had prior experience with the XGBoost model, which relies on the gradient boosting algorithm, and having heard of its adaptability and performance, decided to give it a try.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/553/1*qKVnTmsef-P5fMFkzXNvxQ.png" /><figcaption>Utilizing the XGBoost model</figcaption></figure><p>Following the same procedure as before, I found the R² score of the XGBoostRegressor(), which yielded an accuracy of ~90.6%, substantially higher than before. Of course, I could try optimizing the hyperparameters of the model, but was content with the accuracy I received.</p><h4>Concluding remarks</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ZyzXyM0wFz0aNtga" /><figcaption>Photo by <a href="https://unsplash.com/@homajob?utm_source=medium&amp;utm_medium=referral">Scott Graham</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>While the article provides an insight into the correlations between various factors and how they influence one’s salary, the larger purpose of this one was to subtly teach you about the ML development process, and how (contrary to popular belief), there is more to the process than just choosing and evaluating a model.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6d9c79905649" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Everything You Need to Know to Get Started in Python: A Brief Introduction]]></title>
            <link>https://medium.com/@yashrajvishwakarma.31/everything-you-need-to-know-to-get-started-in-python-a-brief-introduction-dd3b33ebe3c8?source=rss-a7fae3e99bf7------2</link>
            <guid isPermaLink="false">https://medium.com/p/dd3b33ebe3c8</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Yashrajvishwakarma]]></dc:creator>
            <pubDate>Sat, 05 Aug 2023 05:51:45 GMT</pubDate>
            <atom:updated>2023-08-05T05:51:45.405Z</atom:updated>
            <content:encoded><![CDATA[<h4>Really brief.</h4><p>This article is going to be as “to the point” as one can be, especially when it comes to programming.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*TJBu4NLkzGCoHaUj" /><figcaption>Photo by <a href="https://unsplash.com/@cdr6934?utm_source=medium&amp;utm_medium=referral">Chris Ried</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>The basics</h4><p>The most essential function in Python is to “print” a statement; i.e.: giving back a specific text to the user.</p><p>This is accomplished by the following code snippet:</p><pre>print(&quot;insert your text here&quot;)</pre><p>But, by themselves, print statements aren’t remotely interesting. Which is why f-strings exist.</p><p>F-strings, or formatted strings, allow you to create <strong>dynamic print statements</strong>, where the printed text varies depending on user output.</p><p>The following code snippet showcases the power of f-strings:</p><pre>name = &quot;Yashraj&quot;<br>print(f&quot;Hi there, {name}&quot;)</pre><p>Here, we first define a variable called “name” (more on variables later), and then print out a statement, but by placing an “f” before the “” (known as a string, more on that later as well), we can place variables inside the “”, because of which the output will change depending on the value of the variable.</p><p>The output of this program would be <strong>Hi there, Yashraj.</strong></p><p>But instead, let’s consider the following code snippet:</p><pre>name = &quot;John&quot;<br>print(f&quot;Hi there, {name}&quot;)</pre><p>As the variable’s value has changed from “Yashraj” to “John”, the print statement will now return <strong>Hi there, John </strong>instead. This is just the tip of the iceberg, and showcases how we can take varying input from users and execute dynamic actions with the input.</p><h4>Variables &amp; data types</h4><p>A variable is just something that, changes its value. It’s never constant.</p><p>The code snippet below shows how one can assign data to variables:</p><pre>x = 2<br>y = 3</pre><p>You can also declare variables in the same line, as follows:</p><pre>x, y = 2, 3</pre><p>In most languages, you need to specify the <strong>data type </strong>of a variable before naming it; such as <strong>int x = 2;. </strong>But in Python, the language automatically assigns the data type based on the value you have assigned to it.</p><p>Each variable can only be one of a finite type, which are known as <strong>data types </strong>(essentially categories of data). The most commonly used data types are:</p><ul><li><strong>int — </strong>stores integral values ( … -2, -1, 0, 1, 2, … )</li><li><strong>float — </strong>stores decimal values ( … 0.1, 0.2, 0.123, -5.142 … )</li><li><strong>str — </strong>stores string literals; any text placed within “” will be stored as it is in the variable</li><li><strong>bool — </strong>short for boolean, can be either one of two values; True or False</li><li><strong>list — </strong>stores a sequence of values <strong>of any type (i.e.: you can store both an int and str in the same list; </strong>these are highly useful and have properties such as indexing and slicing</li></ul><p>There are also other data types in Python, such as <strong>set() and dict()</strong> but those have specific use-cases and are typically not used as commonly as lists; you can learn more about them <a href="https://www.programiz.com/python-programming/variables-datatypes">here</a>.</p><h4>Working with lists: indexing and slicing</h4><p>To initialize a list, you do the following:</p><pre>arr = [9, 8, 75, 23, 22]</pre><p>After defining a list (typically named arr — short for array), one will typically need to fetch values from it.</p><p>In order to do this, you must know about the powerful method of <strong>indexing.</strong></p><p>An “index” is an integer value assigned to each position in an array. <strong>It starts from 0 and goes till n-1, where n is the number of values in the list. </strong>For the above list, you can write the following code snippet:</p><pre>val = arr[0]</pre><p>arr[0] will be the first element of the list, therefore the value for the variable “val” is 9.</p><p>Following this pattern, the outputs for each index are given below:</p><pre>arr[1] # equals 8<br>arr[2] # equals 75<br>aarr[3] # equals 23<br>arr[4] # equals 22</pre><p>You can also index with negative values, as demonstrated below:</p><pre>arr[-1] # equals 22<br>arr[-2] # equals 23<br>arr[-3] # equals 75<br>arr[-4] # equals 8<br>arr[-5] # equals 9</pre><h4>Commenting code</h4><p>All the green text above preceded by a hashtag is known as a <em>comment. </em>Comments are a useful tool to keep track of code in larger projects, and are a piece of typed text which typically indicates the purpose of that line of code.</p><h4>Conditionals &amp; for-loops</h4><p>Conditionals are an essential method in programming, and often emulate real-world logic.</p><p>An example is provided below:</p><pre>x = int(input(&quot;Enter a number&quot;))<br><br>if x &gt; 0:<br>  print(f&quot;{x} is a positive number&quot;)<br>elif x &lt; 0:<br>  print(f&quot;{x} is a negative number&quot;)<br>else:<br>  print(f&quot;{x} is zero&quot;)</pre><p>The first line may seem daunting, but all it does is take a numeric input from the user; the text within the “” will be used to prompt the user for an input, in this case, the user enters a number.</p><p>Then, the program uses simple inequalities to compare the value of x.</p><p>It reads like English: if it’s more than 0, print that it’s positive (here we’re using our f-strings). If it’s less than 0, print that it’s negative, and otherwise, print that it’s zero.</p><p>In the code snippet above, <strong>elif </strong>is short for “else if” and is used to build multiple conditions in a program.</p><p><strong>An important note: code blocks after the if, elif, else, for &amp; def keywords (</strong>more on def later), must be indented in a similar manner as shown above, otherwise the code will return an error.</p><p>Now, onto for-loops.</p><pre>for i in range(1, 10):<br>  print(i * i)</pre><p>A for-loop is also straightforward to understand. First, we’re using a placeholder variable “i”, which only works in this particular loop’s code block. After that, we print out the number times itself (i.e.: its square).</p><p>Then, we repeat this for i = 2, i = 3, i = 4 …</p><p>This will continue till i = 9; a for-loop always stops one value before the stop value provided (in this case, 10).</p><p>You can also add a <em>step </em>to the for-loop as shown below:</p><pre>for i in range(1, 10, 2):<br>  print(i * i)</pre><p>Here, the code will work the same way as before, but for i = 1, i = 3, i = 5 … Basically, it’ll work for every alternate number, which in this case translates to just odd numbers.</p><p>You also don’t have to use “i” as your placeholder variable; you can use any valid variable name, but the letter <em>i </em>and <em>x </em>are most commonly used.</p><p>You can also loop through lists in the same manner:</p><pre>numbers = [1, 8, 27, 64, 125]<br>for number in numbers:<br>  # do something</pre><h4>User-defined functions</h4><p>So far, you’ve worked with functions which are already present in Python, such as print(), which outputs text on the command line.</p><p>But in Python (and most other languages), you can also define your own functions. An example is shown below:</p><pre>def square(a):<br>  return a * a<br><br>print(square(5))</pre><p>Okay, so there’s a lot to unpack here. The word “def” is short for “define” and is used to create your own functions in Python. Followed by “def” is the function’s name, which I have called “square”.</p><p>The function is followed by a variable called <em>a </em>inside parentheses. This variable is known as a <strong>parameter; </strong>parameters are values passed into functions so that they can be used to perform calculations and accordingly return a result.</p><p>In this case, the value provided by the user, known as an <strong>argument</strong>, is taken in and multiplied by itself, and then given back to the user.</p><p>After defining our brand-new function, rather than having to type NUMBER * NUMBER each time, I can simply call the function square() and insert a number inside the parentheses.</p><p>In the example above, square(5) first assigns the value 5 to the variable <em>a, </em>after which a * a is computed, which in this case is 25. This value is then given back to the user.</p><h4>Moving forward from here..</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wfNe8hbgxvYRFbgN" /><figcaption>Photo by <a href="https://unsplash.com/@emilegt?utm_source=medium&amp;utm_medium=referral">Emile Guillemot</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>That’s it for this article. With enough practice of these core concepts, you can already make some pretty useful programs, and can continue to expand the functionality of those programs by including more advanced features such as error handling, and using special libraries such as numpy, pandas and matplotlib.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dd3b33ebe3c8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How I (accidentally) created a test for primes]]></title>
            <link>https://medium.com/@yashrajvishwakarma.31/how-i-accidentally-created-a-test-for-primes-8b1e92e88c1a?source=rss-a7fae3e99bf7------2</link>
            <guid isPermaLink="false">https://medium.com/p/8b1e92e88c1a</guid>
            <category><![CDATA[computer-science]]></category>
            <category><![CDATA[mathematics]]></category>
            <category><![CDATA[interesting]]></category>
            <category><![CDATA[research]]></category>
            <category><![CDATA[news]]></category>
            <dc:creator><![CDATA[Yashrajvishwakarma]]></dc:creator>
            <pubDate>Sun, 23 Jul 2023 17:24:02 GMT</pubDate>
            <atom:updated>2023-09-09T17:57:56.634Z</atom:updated>
            <content:encoded><![CDATA[<h3>How I discovered a test for primes</h3><h4>As in prime numbers.</h4><p>Firstly, I just want to say that this isn’t some groundbreaking test which is superior to all others; it utilizes a lot of ideas previously known in mathematics. However, I’ve used them in conjunction with my knowledge of computer science to develop a simple-to-understand and (somewhat) efficient test for primality.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*9sJBlVKx3Ko0NaDM" /><figcaption>Photo by <a href="https://unsplash.com/@saadahmad_umn?utm_source=medium&amp;utm_medium=referral">Saad Ahmad</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>Inspiration for the test</h4><p>I like maths. A lot. So I’m constantly thinking about numbers.</p><p>One day, a thought spontaneously struck me: <em>(287–7) (mod 70) = 0, </em>but <em>(277–7) (mod 70) != 0. </em>Based on this, I made a (rather foolish) statement that if a number <em>k </em>ended in 7, and (<em>k-70) (mod 70) != 0, </em>then it was prime; later I would also add <em>(k-30) (mod 30) != 0 </em>as a condition.</p><p>Upon taking this to my IB Maths teacher, he remarked that I should try using taking the number modulo a prime (like 7 &amp; 3) rather than using 70 and 30.</p><p>Next, I wrote a program to test the accuracy of this naive approach to primality testing, and it was surprisingly accurate until around 1100; only ~10% of numbers were falsely returned as prime despite being composite.</p><p>I then collated the “pseudoprimes” and learned about their connection to the Dirichlet theorem on arithmetic progressions, which states:</p><p>For a sequence S = <em>an + b, </em>if <em>a </em>and <em>b </em>are coprime (i.e.: their HCF is 1), then S contains infinitely many primes. In turn, I concluded that all primes ending in 7 (of the form <em>k = 10n + 7</em>) can be written as either</p><p><em>(10a + 1)(10b + 7), </em>or <em>(10c + 3)(10d +9).</em></p><p>Initially, I thought that all four of these numbers had to be prime numbers, but eventually realised that this was not true, because of the existence of numbers with prime factors having a <strong>multiplicity </strong>greater than 1. This means that one factor occurs multiple times, such as <em>1419857=17⁵. </em>As such numbers can’t be expressed with two distinct prime factors, I soon realized that my approach with Dirichlet’s theorem wouldn’t work out.</p><p>Next, I turned my focus to abstract algebra, particularly ring theory. I decided to take the following approach: construct a multiplicative table for the ring of integers modulo <em>k (</em>from 1 to k-1), where <em>k </em>is the number tested for primality. Then, if any cell in the table contained a zero, output COMPOSITE, else output PRIME.</p><p>This approach works because in a multiplicative table, if the product of any two numbers <em>a </em>and <em>b </em>is equal to <em>k, </em>then <em>k (</em>mod <em>k) = </em>0. Thus, no zeroes must be present in the table.</p><p>However, there is one <strong>major </strong>drawback with this approach: it’s very slow. Emphasis on <strong>very. </strong>And that’s because of two reasons: first, the time taken to construct a 2D array of size <em>k * k </em>is not efficient at all, as it is an operation of time O(<em>n²). </em>Additionally, as <em>k </em>becomes larger, computing the product of larger and larger numbers becomes a much slower operation.</p><p>I tried various optimizations on this algorithm, but it either failed from the computational perspective or the math-logic perspective.</p><h4>The final algorithm</h4><p>At this point, I was on the verge of giving up, but remembered about one of the things I learnt when self-tutoring myself on data structures &amp; algorithms: hash tables.</p><p>Essentially, hash tables are a type of <strong>unordered </strong>data structure which use a <strong>hash function </strong>to insert, delete and search for elements in O(1) time. Sounds like the perfect data structure right?</p><p>Well, not quite.</p><p>To achieve the O(1) time complexity, the table must avoid <strong>hash collisions, </strong>which occur if one key corresponds to multiple values in the table. To avoid them, one must create a <strong>dynamically perfect hash function </strong>(I know this is confusing, stay with me here; I wrote a paper on this and still barely understand it :). This is a type of hash function that continually updates each time a value is inserted or deleted from the hash table, thus avoiding any collisions. While this is efficient from the time complexity point of view, in the worst-case it can have a space complexity of O(n).</p><p>Despite this, I chose to use a hash table in my primality testing algorithm, which I also believe is a new application of hash tables; I am yet to find any other algorithm related to primality which uses hash tables in this manner.</p><p>Additionally, through some research I found a few useful approximations (which become more and more accurate especially as <em>k </em>increases); my entire algorithm is shown in the image below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/836/1*5kMMCIb40BgtXZLG7PXhAA.png" /></figure><p>Yeah, it’s quite long. But I’ll try summarizing it in a few simple words.</p><p>Take a number <em>k </em>to test, and approximate the number of primes till <em>sqrt(k) </em>using the well-known approximation for <em>pi(x), </em>the prime-counting function, which returns the number of primes less than or equal to <em>x</em>.</p><p>Next, conduct the “<em>base cases”</em>, shown in steps 3 and 4. They’re quite simple to understand.</p><p>From step 5, it gets a bit interesting. I utilize a sieve-like approach, where I store the primes found so far in a hash table A, and keep iterating. If I come across a number which isn’t in A, it must be prime, so I compute <strong>all of its multiples till <em>sqrt(k), </em></strong>and add them to A. The beauty here is that no matter how many numbers I’m adding, the insertion process takes O(1) as I’m using a hash table. Additionally, each time I come across a prime, I store it in a different hash table called “P”. I also increment one to a counter that keeps track of how many primes I’ve found so far.</p><p>I repeat this process until one of two conditions is satisfied: either the number of primes found = <em>pi(x) </em>(here, <em>pi(x) </em>is the approximation we’re using for the prime-counting function), or we’ve iterated till <em>sqrt(k).</em></p><p>Once this is completed, we arrive at the last step. As a hash table is unordered, you fetch a number <em>i </em>from the hash table and see if <em>k (mod i) = 0. </em>If it does, then output COMPOSITE. Otherwise, repeat this process <em>log(n)/log(log(n)) </em>times, which is the upper bound approximation for the prime-omega function, which returns the number of distinct prime factors a number has.</p><h4>Is it any good?</h4><p>Well, not really?</p><p>On one hand, the overall time complexity of the algorithm in terms of the input integer <em>n </em>is O(<em>n * log(n) * log(log(n)))</em>, which certainly isn’t bad, considering the original time complexity for the AKS primality test was O((<em>log(n))¹²), </em>later cut down to O((<em>log(n))⁶)</em>. However, there’s tests such as the probabilistic Miller-Rabin test, which is commonly used and runs in time O((<em>log(n))³)</em>. When looking at the general trend over larger inputs, my algorithm appears to be much slower.</p><p>But there’s one thing to keep in mind.</p><p>The time complexity can most definitely be cut down; while I have made a number of assumptions (such as using the Harvey-Hoeven algorithm for multiplication &amp; assuming that a dynamically perfect hash function is being used), the core logic behind the algorithm is quite elementary in the grand scheme of things, and people much more qualified than me can certainly use more advanced ideas to make the algorithm more efficient).</p><p>Here’s the link to my paper: <a href="https://zenodo.org/record/8279987">https://zenodo.org/record/8279987</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8b1e92e88c1a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How I built a programming language: The (difficult) Path to Success]]></title>
            <link>https://medium.com/data-science/how-i-built-a-programming-language-the-difficult-path-to-success-38aefa2bb69e?source=rss-a7fae3e99bf7------2</link>
            <guid isPermaLink="false">https://medium.com/p/38aefa2bb69e</guid>
            <category><![CDATA[programming-languages]]></category>
            <category><![CDATA[mathematics]]></category>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[education]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Yashrajvishwakarma]]></dc:creator>
            <pubDate>Thu, 20 Jul 2023 15:55:12 GMT</pubDate>
            <atom:updated>2023-08-02T23:35:17.592Z</atom:updated>
            <content:encoded><![CDATA[<h4>Frankly, difficult is an understatement.</h4><p>My <a href="https://medium.com/@yashrajvishwakarma.31/how-i-built-a-programming-language-acd144f3867f">previous article</a> about my programming language outlined its syntax and provided a general idea of how I built it.</p><p>But I decided to write another one devoted to my journey towards the final outcome, because if I’m being honest, the journey certainly had a lot more downs than ups, and the challenges I had to overcome were really intimidating. Hopefully, this article also serves as motivation for anyone undertaking a similar project and facing similar difficulties, to not give up and instead know that someone else was once in the same position as them, and ended up fulfilling their goal.</p><h4>But why should you care?</h4><p>After all, all of you are from varied backgrounds, whether it be data science, or just good old Python &amp; Java.</p><p>Well, even if you aren’t interested in building your own programming language, many of the soft skills I improved on during this experience will certainly be relatable (and hopefully motivational) to all of you, especially if you’re interested in programming.</p><p>How many times do you write a program, where every line looks correct, and you’re instead given a cryptic error that seems near-impossible to debug, at which point you begin losing your motivation and think of giving up.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*5FYzq5TSdtHy7VNO" /><figcaption>Photo by <a href="https://unsplash.com/@punttim?utm_source=medium&amp;utm_medium=referral">Tim Gouw</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Well, I faced those all-too-common issues way too many times while building the language, and the manner in which I eventually overcame them and persevered hopefully communicates a memorable message as you progress through the article!</p><h4>Getting started</h4><p>The original idea for this came when I was in Grade 8 (or Grade 9, can’t quite remember), but back then I barely understood conditionals and iterative loops, so I forgot about it.</p><p>But years later, the same idea reignited itself in my mind, except I had no clue how to even start with it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ljclWtkuFwvsd5UT" /><figcaption>Photo by <a href="https://unsplash.com/@towfiqu999999?utm_source=medium&amp;utm_medium=referral">Towfiqu barbhuiya</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>So like all other things I didn’t know how to do, I Googled</p><p>“How to make your own programming language”.</p><p>And well, the results were quite promising. I spent a long time going through each of them line-by-line, and picked up on the gist of it:</p><p>There’s two types of languages: interpreted and compiled. Interpreted languages tend to be more simple to build, but are slower. On the other hand, compiled languages convert your code to machine code, and then execute it (compiled languages are generally faster).</p><p>The general process to building a language is:</p><ul><li><strong>Define the purpose and syntax of the language:</strong> This was quite easy for me (I knew I wanted to build a math-related language), and to save myself some work and also make the language as high-level as possible, I decided to only keep a few (essential &amp; useful) functions and just two variables, a function and a floating-point number.</li><li><strong>Build a lexer &amp; parser:</strong> A lexer is the first component of any language, and places every word/phrase of your code into different categories (such as keywords, operators, comments etc.). But by itself, these <strong>lexemes </strong>are meaningless, and to make sense of them, one needs to build a parser. The parser ensures that the lexemes follow the language’s syntax, and places them into an AST (abstract syntax tree).</li><li><strong>Executing code:</strong> Each node in the AST represents one of the tokens collected by our original lexer, and this includes function names as well. Thus, running our AST allows us to execute the written code line-by-line; this is the general basis for an interpreted programming language.</li></ul><p>But a compiler requires a few extra steps; you need to use popular libraries such as <a href="https://llvm.org/docs/tutorial/MyFirstLanguageFrontend/index.html">LLVM </a>and <a href="https://gcc.gnu.org/onlinedocs/jit/">libgccjit</a>, which convert the code to a compiled executable file.</p><h4>Compiled or interpreted?</h4><p>On the one hand, I could create an interpreted language, which is quite challenging and requires me to devote a large amount of time and effort. On the other hand, I could create a compiled language, which is <strong>even more challenging, </strong>and requires me to devote even more time and effort.</p><p>But the idea of building my own compiled language just seemed far too appealing, and I fell into the trap.</p><p><strong><em>Advice: don’t do it.</em></strong></p><p>While there are resources available on building a compiler using LLVM (definitely recommend watching the 100-second video on LLVM, both entertaining and somewhat educational), I quickly got lost in their documentation because of how complex it was.</p><p>I’d hedge a guess and say that you could probably learn the basics of Java faster than learning the basics of building a compiler with LLVM.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*PLLMUx0I5lfVcxHO" /><figcaption>Photo by <a href="https://unsplash.com/@emilep?utm_source=medium&amp;utm_medium=referral">Emile Perron</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>A colossal waste of time (or was it)?</h4><p>Unfortunately for me, I spent over two months trying to hustle my way through first LLVM, and then libgccjit. The latter proved more promising and I even wrote code for the compiler, however I then faced a plethora of issues relating to setting up the libgccjit package; I went as far as to downloading the entire source code for it from GitHub and placing it in the same directory as my compiler code. But still, nothing seemed to work. I scrolled through countless Reddit and StackOverflow threads on it, but to no avail.</p><p>When StackOverflow can’t help you, you know something’s very wrong.</p><h4>On the verge of giving up</h4><p>At this point, I had really hit a new low, because I hadn’t made an iota of progress in so long, I began devaluing all the work I’d done, such as building a lexer &amp; parser from scratch, without the popular lex/yacc &amp; flex/Bison tools. At this point, I asked myself “Should I throw it all in the (virtual) garbage can?”. I was tempted to say yes, but I don’t quit that easily, especially when it comes to coding-related projects.</p><p>And so I went for a walk, cleared my head, and went back to the drawing board, this time with a different aim: Building an interpreted language.</p><h4>Finally completing it.</h4><p>Once I decided that I would build an interpreter, I also made the difficult decision of ditching C and returning to Python. Under normal circumstances, it’s best to use lower-level languages to build interpreted languages, as their speed compensates for the slow interpreter.</p><p>But I was in a desperate time, and those call for desperate measures.</p><p>After returning to India, I spent the next week in a state of sleeplessness, and quite literally worked 24 hours a day (around 21 if you don’t count breakfast, lunch and dinner — I’m a slow eater).</p><p>And what happened next is something that happened to me for the first time, and will likely never happen again — my code worked on the first attempt! No debugging, no more confusion.</p><p>When I ran my source code, every single component: from the lexer, to the parser &amp; the AST worked properly, and correctly executed each line of the code as it should have.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4CDc3lgV1fIzH4hX" /><figcaption>Photo by <a href="https://unsplash.com/@theblowup?utm_source=medium&amp;utm_medium=referral">the blowup</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>Reflection &amp; a final note</h4><p>The quote above may sound cliche, but that doesn’t detract from its validity; I faced far more failures than successes while building AdvAnalysis, but yet, I ended up on top.</p><p>While you could learn about things to be cognizant of when building your own programming language (such as compiled vs interpreted, the process to follow), the main takeaway I had (and hope you had as well), is that no matter how discouraging it may be to constantly encounter a cryptic error in your program, in the end, it always works as you expect it to, if only you have the ability to be patient &amp; return to square one and follow a different approach.</p><p>To be honest, as a fellow programming enthusiast, you probably already knew that. :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=38aefa2bb69e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/how-i-built-a-programming-language-the-difficult-path-to-success-38aefa2bb69e">How I built a programming language: The (difficult) Path to Success</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How I built a programming language: The Outcome]]></title>
            <link>https://medium.com/@yashrajvishwakarma.31/how-i-built-a-programming-language-acd144f3867f?source=rss-a7fae3e99bf7------2</link>
            <guid isPermaLink="false">https://medium.com/p/acd144f3867f</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[programming-languages]]></category>
            <category><![CDATA[mathematics]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[science]]></category>
            <dc:creator><![CDATA[Yashrajvishwakarma]]></dc:creator>
            <pubDate>Tue, 18 Jul 2023 07:32:20 GMT</pubDate>
            <atom:updated>2023-09-09T17:54:50.541Z</atom:updated>
            <content:encoded><![CDATA[<p>I mean, it’s not as elaborate or fancy as what one uses, like Python, C or Java. It’s what one would call a <strong>tiny programming language, </strong>one which has limited functionality, but works nonetheless.</p><p>But it works (pretty decently), handles errors, and serves a purpose.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*IP-80kf3k4s8IA8y" /><figcaption>Photo by <a href="https://unsplash.com/@markusspiske?utm_source=medium&amp;utm_medium=referral">Markus Spiske</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>What does it do?</h4><p>I’m a big maths person. But in terms of programming languages specifically for maths, I couldn’t find much aside from MATLAB and Mathematica, both of which are paid software. And even in the popular languages, such as Java &amp; Python, you need to go through the learning curve and learn all the basic syntax before getting to the libraries which you can use for math operations.</p><p>While GNU Octave is a language which is maths-oriented and free-to-use, the syntax can seem a little daunting at first. As a result, I envisioned a free-to-use programming language which is <strong>as simple as possible</strong> to the point where anyone could determine what each line of code does.</p><h4>Getting started (not quite)</h4><p>I soon realized that everyone doesn’t just cook up a programming language because well, it’s hard.</p><p>For one, you need to define the syntax of the language; variable names, literals, data types and functions.</p><p>Once you get past that barrier, you need to do the following:</p><ul><li>Develop a lexer: A lexer is a simple tool that reads the code you’ve written and splits it up into <em>tokens, </em>which are the parts of your syntax mentioned above.</li><li>Develop a parser: A parser is the tool which takes the tokenized data, and utilizes it in a logical manner by inserting them into an abstract syntax tree (AST). (I’m not going to explain every single concept that went into making this, because 1. I don’t have the time or energy for it and 2. I’m not qualified enough to).</li></ul><p>Because I chose to build an interpreted language rather than a compiled one (because building a compiler using LLVM or libgccjit is <strong>not </strong>easy), the rest was rather straightforward. However, the three steps above were quite the challenge.</p><p>I chose to use Python because of my experience in it, but in the future I’ll hopefully port the source code over to a language such as C or C++, which is ideal for interpreted languages.</p><h4>About my language</h4><p>Based on inspiration from a friend, I chose to name it MANGO (Mathematical and Analytical Nucleus for Global Operations).</p><p>You can define upto two variables; one is a function named <em>func</em>, and the other is a floating-point number called <em>a </em>(for the latter, the name is arbitrary).</p><p>In the language, there’s some predefined functions for both types of variables, which I’ve outlined below:</p><pre>differentiate(func) %% returns the derivative of the function</pre><p>Oh yeah, in MANGO, comments are given by using a %%.</p><p>The function <em>differentiate(func) </em>does what you expect; it gives you the derivative of the function. For now, it’s restricted to only polynomials, but in the future, I aim to expand it to all types of function (logarithmic, exponential, and with multiple variables).</p><p>Next up is:</p><pre>integrate(func, A, B) %% return integral</pre><p>Once again, the above function’s purpose is rather obvious: it computes the integral of the function “<em>func</em>” from <em>x = A </em>to <em>x = B. </em>However, unlike the previous one, this function works for all single-variable functions (i.e.: greater usability).</p><pre>det(A, B, C, D) %% return determinant</pre><p>Out of all the functions in this language, det() is probably the least interesting one, as for a 2x2 matrix, it computes the determinant, which as you all know is just <em>ad — bc. </em>In the future, however, I’ll be looking to add an extra parameter relating to the dimensions of the matrix, so that one can easily compute the determinant of matrices of any size.</p><pre>graph(func, A, B)</pre><p>This function <em>graph() </em>allows you to sketch any function between the intervals A and B. Pretty straightforward, really. If you were to do this in Python for example, you’d need to first learn Python then learn matplotlib to do this. On the other hand, MANGO makes graphing functions a trivial activity.</p><p>That’s it for now for the functions related to the analytical side of maths. I’ve also added some functions with operate on a single numerical variable <em>a.</em></p><pre>double(a) %% return 2 * a<br>square(a) %% return a * a<br>cube(a) %% return a * a * a<br>exp(a) %% return e ^ a<br>log(a) %% return ln(a)</pre><p>Once again, this is quite trivial, and accentuates the purpose of the language as a whole: simplicity, but taken to the next level.</p><h4>Error handling</h4><p>One of many limitations of the language is the lack of error handling, whether it be a logical one or syntax-related. However, it is there to an extent. For one, you must close all functions with correct parentheses, otherwise an error message will be returned. Also, the language returns appropriate messages for incorrect spelling of functions, as well as an incorrect number of parameters (this one is still under development).</p><h4>Using the language</h4><p>In the foreseeable future, I’ll be releasing the documentation and installation process for MANGO.</p><p>All MANGO program files end with the .mgo extension. In order to run a program, you need to ensure that the .exe file installed is in the same directory as the program file(s), and then use the command line to run the executable file. In a matter of moments, the output for your .mgo programs will be returned to you.</p><h4>Moving forward from here</h4><p>This has been one of the most challenging, yet rewarding things I’ve ever worked on. In the next months (and maybe even years), I hope to extend the features of the language by including more advanced logical operators &amp; mathematical functions while maintaining its ethos. Additionally, I’ll look to resolve any prominent bugs in the language’s syntax and maybe even bring on some more people to help in developing it further.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=acd144f3867f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Inflation, Deflation and Purchasing Power]]></title>
            <link>https://medium.com/@yashrajvishwakarma.31/inflation-deflation-and-purchasing-power-4844a5bc765e?source=rss-a7fae3e99bf7------2</link>
            <guid isPermaLink="false">https://medium.com/p/4844a5bc765e</guid>
            <category><![CDATA[finance]]></category>
            <category><![CDATA[inflation]]></category>
            <category><![CDATA[economics]]></category>
            <category><![CDATA[entrepreneurship]]></category>
            <category><![CDATA[business]]></category>
            <dc:creator><![CDATA[Yashrajvishwakarma]]></dc:creator>
            <pubDate>Wed, 12 Jul 2023 18:44:01 GMT</pubDate>
            <atom:updated>2023-07-12T18:44:01.432Z</atom:updated>
            <content:encoded><![CDATA[<h4>(with an anecdote)</h4><p>I’m still only 17 years old, but have travelled around the world (20-something countries, but who’s keeping track?). Deliberately travelling to underrated tourist attractions was one of my favorite activities before the pandemic; while everyone I knew went to London or New York, I was enjoying the peace and beauty of Svalbard and feeding swans at Lake Lucerne.</p><p>The point is, while doing all this travelling, I became obsessed with currencies and how the exchange rate worked. Every day, I used to see the value of the pound change, never really understanding what it meant.</p><p>But during my recent trip to Switzerland, it finally began to make sense.</p><p>When buying tickets for the train back to Zurich, I saw that the total price was CHF 95, almost 9000 rupees. I remember coming here a few years ago when it was almost half that.</p><p>So I wondered, what’s going on here?</p><p>Applying the things I learned in my economics class, I made an educated guess, and later learnt my belief was true: the culprit was inflation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*_x8tVBQIjjYRAJ7y" /><figcaption>Photo by <a href="https://unsplash.com/de/@enginakyurt?utm_source=medium&amp;utm_medium=referral">engin akyurt</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>Breaking it down in simple terms</h4><p>Formally speaking, inflation is the sustained rise in price levels of goods &amp; services in an economy over a fixed period of time.</p><p>How does it matter to the general consumer though?</p><p>Okay, let’s say you have INR 1000 with you right now, and you want to buy an apple, which is INR 200/unit. So you get five apples.</p><p>But now, due to inflation, the price level of goods has increased, so an apple is now INR 500/unit. Because of this, that same INR 1000 you had in the beginning can now only buy two apples, not five.</p><p>And this is what is commonly known as purchasing power; It’s defined as the quantity of goods one can buy with a unit of currency.</p><p>Let’s get back to foreign currencies to really make the idea as astute as possible.</p><p>The last time I went to Switzerland with my family in 2017, 1 CHF = 66.40 INR, i.e.: 66.4 rupees was equivalent to 1 franc. So if a bottle of water in Switzerland cost 1 franc, it would be worth 66.4 in Indian currency.</p><p>But in 2023, 1 CHF = 91.39 INR. So while in Switzerland, a bottle of water still cost 1 franc, it’s now 30 rupees more for the Indian consumer. Because of inflation, the purchasing power of the Indian rupee has decreased, and those 66.4 rupees I had before do not buy as much water today.</p><p>The series of paragraphs above can be explained away in a simple sentence: <strong>Inflation reduces the purchasing power of a currency, and weakens it relative to other currencies.</strong></p><h4>The converse: deflation</h4><p>Once you know the definition of inflation, deflation is quite trivial to decipher: it’s the sustained decrease in the price levels of goods &amp; services in an economy over a fixed period of time.</p><p>Let’s return to the apple example.</p><p>As before, we have INR 1000 and an apple costs INR 200/unit. So you get five apples.</p><p>But now, deflation has occurred, and the general price level of G&amp;S has decreased, so now an apple costs INR 100/unit. Now with that same INR 1000, you can buy ten apples.</p><p>Because the consumer is now able to buy greater quantities of a good with the same amount of currency, one can say that the <em>purchasing power has increased</em>.</p><p>Returning back to Switzerland. If 1 CHF = 91.39 INR today, but in a few months, it drops to 1 CHF = 85 INR, this can be attributed to deflation, as it caused the purchasing power to increase, so you can now buy a greater quantity of goods with the same amount of money you had before.</p><h4>Conclusion</h4><p>Of course, the real world is scarcely this straightforward. Inflation, deflation and the purchasing power are all immensely tricky and theoretical concepts to grasp, with fancy terminology such as the Consumer Price Index, which can confuse rather than inform. The purpose of this article was to provide a gentle introduction into the real-world impacts of the concepts of inflation &amp; deflation through the lens of foreign exchange rates, which has an impact on anyone who ever travels and spends in a foreign country. I certainly hope that this article was able to accomplish that!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4844a5bc765e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Heisenberg uncertainty principle]]></title>
            <link>https://medium.com/@yashrajvishwakarma.31/the-heisenberg-uncertainty-principle-9da797e086e5?source=rss-a7fae3e99bf7------2</link>
            <guid isPermaLink="false">https://medium.com/p/9da797e086e5</guid>
            <category><![CDATA[stem]]></category>
            <category><![CDATA[mathematics]]></category>
            <category><![CDATA[physics]]></category>
            <category><![CDATA[science]]></category>
            <category><![CDATA[quantum-physics]]></category>
            <dc:creator><![CDATA[Yashrajvishwakarma]]></dc:creator>
            <pubDate>Fri, 26 May 2023 09:31:36 GMT</pubDate>
            <atom:updated>2023-05-26T09:31:36.686Z</atom:updated>
            <content:encoded><![CDATA[<h4>Things work differently down there.</h4><p>When we learn about classical mechanics in a typical physics class, we’re taught some formulae relating an object’s velocity, displacement, momentum etc. such as:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/490/1*zLtWtq5OltVv-evTzoh7QQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/497/1*YvAvMF_6MTXjY2EmSrO50Q.png" /></figure><p>These formulae, which relate the displacement (vertical or horizontal) of an object to its velocity, have a rather trivial, but important property: if we know the displacement of an object at a given time, we can find its velocity, and if we know the velocity of an object, we can find its displacement. <strong>So the more we know about an object’s position, the more we know about its velocity as well (and vice versa).</strong></p><p>However, these formulas are applicable in classical mechanics, and <strong>not in quantum mechanics.</strong></p><h4>The uncertainty principle</h4><p>In 1927, the scientist Werner Heisenberg proposed the following inequality:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/438/1*rboPzY7j7ZR40D1jMKrNBQ.png" /></figure><p>Here, delta x and delta p are the uncertainties in position and momentum respectively, and h is Planck’s constant (~6.63 x 10^-34 J/Hz). This inequality has a very important implication: t<strong>he more precisely one knows about the position of a particle, the less precisely they know about the momentum of the particle (and vice versa).</strong></p><h4>Why does the uncertainty principle hold?</h4><p>Keeping it simple, the principle exists due to the dual nature of particles: every particle also exhibits the properties of a wave (known as the de Broglie hypothesis). de Broglie also found a formula relating a particle’s momentum to its wavelength:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/213/1*PkGG9CP53zgxXLV7Le81_A.png" /></figure><p>As a wave is a disturbance created in a medium, so it does not have a fixed position. This idea is the basis of the uncertainty principle, as if we knew the exact position of a particle, its uncertainty would be zero, because of which the uncertainty in the momentum is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/876/1*DnSMhx7nhlpc3Cgy2hAlCQ.png" /></figure><p>Summing it up, Heisenberg’s uncertainty principle states that it is impossible to know both the precise momentum and position of a particle at the same time in a quantum system.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9da797e086e5" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>