<?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 Jyoti Yadav on Medium]]></title>
        <description><![CDATA[Stories by Jyoti Yadav on Medium]]></description>
        <link>https://medium.com/@jyotiyadav99111?source=rss-f8266fc86ce7------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*wrNq88uPB8jgy-HyE-H4Lw@2x.jpeg</url>
            <title>Stories by Jyoti Yadav on Medium</title>
            <link>https://medium.com/@jyotiyadav99111?source=rss-f8266fc86ce7------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 09:28:03 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jyotiyadav99111/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[The Art of Quantum Tech: Why Origins Matter More Than Hype]]></title>
            <link>https://jyotiyadav99111.medium.com/the-art-of-quantum-tech-why-origins-matter-more-than-hype-b362bc19a85f?source=rss-f8266fc86ce7------2</link>
            <guid isPermaLink="false">https://medium.com/p/b362bc19a85f</guid>
            <category><![CDATA[quantum]]></category>
            <category><![CDATA[double-slit-experiment]]></category>
            <dc:creator><![CDATA[Jyoti Yadav]]></dc:creator>
            <pubDate>Sat, 06 Sep 2025 12:57:08 GMT</pubDate>
            <atom:updated>2025-09-06T12:57:08.634Z</atom:updated>
            <content:encoded><![CDATA[<p>With so much happening in the technology domain, it becomes very difficult to keep up with it. With the introduction of blockchain, chatbots, LLMs and other complex topics, we are no longer at the privilege of getting to know the field. We are generally caught up in the race of being the first one to master the topic or build something out of it. However, this makes us keep on switching from one topic to another and we end up being a master of none.</p><p>To pursue a field it becomes essential to resonate with the topic or the phenomenon it is trying to understand. After all it’s a long term commitment. That being said, it becomes essential to understand the origin of the technology before looking into applications of it. It helps you connect with the cause and lead you to a greater path. This not only helps you answer question like — origin of the technology, basic nature, what are we trying to solve or what evolution in the field looks like, however it brings one closer to the essence of technology. It will tell you why this is a top worth learning about (if you find it fascinating), is it worth putting efforts into to or most importantly “Is this for me?”.</p><p>Quantum computing is a complex topic and diving straight into the application makes it more complicated. However, looking at the origin of it takes you much more closer to the cause. This is where the “<strong>Double Slit Experiment</strong>” comes into picture. Its an example of what made physicists so interested into this topic and how mesmerising it could be to visualise what the possibilities are and we do not know to what extend the unknowns exist in the universe that are not yet pinned by out laws or axioms or mathematics.</p><h3>History of the Double Slit Experiment</h3><p>The debate over whether light is a particle or wave goes back centuries. Double Slit experiment was first conducted by Thomas Young in 1801 at The Royal Institute. Yes, it goes back ~40 years. The basic idea was based on the fact that if two sounds interact with each other they create a beat and similar can be true for optical equivalents as well. While pondering over Newton’s corpuscular theory, he also observed that the air and water interaction sometimes leads to light reflection and at some places its refracted. For answering a few questions like this, he came up with the double slit experiment.</p><p>Let’s look at what the experiment is all about. I will be taking you one by one and help understand the logic of it and why it matters or an essential discovery for quantum mechanics.</p><h3>Double Slit Experiment</h3><p>The basic idea behind double slit experiment is that electrons are passed thought a board that has two slits in it (as depicted in the coverage of the story) and observe the corresponding results on the screen that is being the board. Let’s understand how it works for balls 🥎 to start with.</p><h3>Round 1 (Balls)</h3><p><strong>1 slit</strong></p><p>A very simple depiction where first we start with small balls being thrown from just one slit. and this is how the output should look like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7CuOUFQPqxg8wnJS" /><figcaption><strong>AI generated Image: One slit experiment with small balls</strong></figcaption></figure><p>Now, this looks alright that some of the balls will bounce of the screen and the ones that pass will form a structure like that on the wall.</p><p><strong>2 Slits</strong></p><p>Similarly here now as there are two slits, there will be two lines on the wall</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*VExKDUwPsUfK8XG3" /><figcaption><strong>Ai Generated Image: Two slits with small balls</strong></figcaption></figure><h3>Round 2 (light)</h3><p>Let’s repeat the experiment with a monochrome light and check how the pattern will look like when its two slits.</p><p>The result shows a wave length of light where the light from two slits interacts and at someplace it cancels it effect (dark patches on wall) and other it combines thereby enhancing the light and you should be able to see that on the screen itself. However, the quantum physics has a letdown from there however lets look at how electrons behave and this will be a step towards understanding basics of quantum physics and how the qubits come into picture.</p><h3>Round 3 (electrons)</h3><p>It was quite understandable how light behaves in this manner however, while doing this experiment with electron says this:</p><p>hypothesis: It behaves like small balls and will leave two lines similar to slit on the wall</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*SmBDqf5RLntUynfQ" /><figcaption><strong>AI Generated Image: Electron in double slit experiment</strong></figcaption></figure><p>Above results are totally astounding, instead of behaving like small balls and creating two lines on the wall it depicts a light like behaviour. but that doesn’t seem logical. If the electron is thrown though the slits either they go though slit 1 or slit 2, it should not be behaving like that.</p><p><strong>Adding an observer</strong></p><p>To make sense out of this, it was decided that the electrons will be observed to check how this pattern is being created what electron goes through what slit and check if how they refract. Therefore, an observer was added need the split screen to observe this and the results were as follows:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*5vjAa5NxKR2J_I3M" /><figcaption><strong>AI Generated Image: Adding an observer leading to change in final state</strong></figcaption></figure><p>This is another mystery, that if the electrons are observed they behave differently. This is where the concept of qubit can be related to. The moment one observes the states, they are irreversible. It’s like Schrödinger’s cat experiment, once you open the box the output is irreversible.</p><h3>Conclusion</h3><p>I do not want to add any conclusions here I want to keep your thoughts fuelling. This is a phenomenon that can not be concluded easily. However, I would like to leave you with this famous quote for quantum mechanics:</p><blockquote><strong>If quantum mechanics has not profoundly shocked you, you have not understood it yet </strong>— Niels Bohr</blockquote><p>Please feel free to contact if you would like to talk more about it.</p><h3>References</h3><ol><li>May 1801: Thomas Young and the Nature of Light: <a href="https://www.aps.org/archives/publications/apsnews/200805/physicshistory.cfm?ref=hackernoon.com">https://www.aps.org/archives/publications/apsnews/200805/physicshistory.cfm</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b362bc19a85f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Basics of Generative AI]]></title>
            <link>https://jyotiyadav99111.medium.com/basics-of-generative-ai-1159c5e3275e?source=rss-f8266fc86ce7------2</link>
            <guid isPermaLink="false">https://medium.com/p/1159c5e3275e</guid>
            <category><![CDATA[chatgpt]]></category>
            <category><![CDATA[generative-ai]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[latent-space]]></category>
            <dc:creator><![CDATA[Jyoti Yadav]]></dc:creator>
            <pubDate>Mon, 01 May 2023 20:52:18 GMT</pubDate>
            <atom:updated>2023-05-01T20:52:18.800Z</atom:updated>
            <content:encoded><![CDATA[<p>Generative AI has become widely discussed topic now-a-days primarily due to the release of ChatGPT. It is fascinating to witness the development of programs that can generate text, pictures, and audio that closely resemble human behavior. It has the potential to revolutionize many industries, including art, entertainment, and marketing, by providing new ways to create and engage with audiences.</p><p>Given the advancement of the technology, it has become a necessity to know the basics terminologies of Generative AI and its use cases. Thefore, the intent of this blog is to familiarise with the basic concpets of generative AI. Next time if someone asks you what generative AI is, you will be able to brag…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7QNZA3An79rqnwbq" /><figcaption>Photo by <a href="https://unsplash.com/@santesson89?utm_source=medium&amp;utm_medium=referral">Andrea De Santis</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h4>Discriminative Models VS Generative Models</h4><p>It is important to learn about the other counterpart of the Generative Models. Traditionally, Data Scientists have been working with the D<strong>iscriminative Models</strong> where the task is to identify if an observation belongs to class 1 or 2 or 3 or any other. One of the very simple example would be to identify if a picture is of cat or dog.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4AZUQnXXb3bAKy4Zvn8xNA.png" /><figcaption>Example of Discriminative Model</figcaption></figure><p>On the other hand, <strong>Generative Model </strong>is an advancement to the field of AI. It has the potential of creating new information based on the input information. For example, if a set of cat images are supplied to it, it can generate a new image of cat that is different from the supplied images.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s1gdz9MZIGhGlFjQ3ra67g.png" /><figcaption>Example of Generative Model</figcaption></figure><p>Though there are a lot of differences between the two types of models, highlighting a few below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1j0DwqYzAfIopGjb08y4ag.png" /><figcaption>Generative VS Discriminative Models</figcaption></figure><p>The next question is how are these generative models able to perform the task of generating something new out of the old images. As the traditional models are quite simple and are clearly based on the past data and labels. The answer to this question lies in <strong>latent spaces.</strong></p><h4>Latent Space</h4><p>Latent spaces are a very important concept of the deep learning and majority of the users of the domain are unaware of its usage and the concept itself.</p><p>Word “Latent” has been derivd from the Latin word latēre which means “to lie hidden”. It is the process of simple dimensionality reduction by keeping the maximum information intact.</p><p>A very simple example is how we describe our people to others. For example, if one of the friends has pink hair, we tend to describe her as the one with pink hair. If more than two of the friends have different hair color, they will be often confused with each other.</p><p>Considering another example of cat and dog images, depending on the size of the image there are thousands of data points to capture. These points are required to be reduced in a way that they are still representative for the original images. In latent space, objects that are similar to each other will remain closer to each other. An illustration has been presented below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CYHv7EhfsQ3wnm_NUKQ2gg.png" /><figcaption>Latent Space Example</figcaption></figure><p>The idea of latent space is used in the case of auto-encoders as well. Here, information is reduced to a smaller dimention representation which is thereby capable of regenerating the original image. A small representation of auto-encoders is presented below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/718/1*zwuEd2rRfyjG71MvsfYuDQ.png" /><figcaption>Auto-encoders; Source: <a href="https://www.educba.com/autoencoders/">https://www.educba.com/autoencoders/</a></figcaption></figure><p><strong>But how is latent space used for new image generation?</strong></p><p>The answer is intuitive, my manipulation of the latent space. Small manipulations in the latent spaces lead to different images. The manipulation should be optimal enough to keep data point closer to its alike and father away from the other types.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*zUgx5cy9P7nyfiqsiy47Ew.png" /><figcaption>Source: <a href="https://www.researchgate.net/figure/Random-samples-encoded-and-conditioned-on-three-different-attributes-The-used-networks_fig19_324057819">https://www.researchgate.net/figure/Random-samples-encoded-and-conditioned-on-three-different-attributes-The-used-networks_fig19_324057819</a></figcaption></figure><p>In the above image, different images have been generated by doing manipulations with the latent space. Let’s look at an examples of how this can be done.</p><p>Considering a transformations from no beard to beard. As per the explanation of the projections in the latent space above, it is understandable that people with no beard and people with beard can be represented as two points in the space, as depicted below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Tk10Ki4Y5xeiiV-fpB-gGw.png" /><figcaption>Latent Space Transformation</figcaption></figure><p>Mean of these two types can be calculated and is depicted by the black dots in the respective clusters. Now, if we subtract mean of beard from the mean of no-beard, it gives us a vector that points from no-beard to beard.</p><p>In the process of converting “no-beard face” to a “face with beard” would mean a transfomation towards “face with beard”. This requires following manipulation:</p><p>x_new = x_old + f * vector_beard</p><p>where,<br>x_old -&gt; latent space representation of the image with “no-beard face”<br>x_new -&gt; new transformed point in the latent space<br>f -&gt; intensity of transaformation<br>vector_hair -&gt; vector pointing from “no-beard face” to “face with beard”</p><p>Depending on transformation intensity, intensity of beard on face will increase.</p><p>That is it for today, I will talk about more concepts related to Generative AI in the upcoming posts. Stay Tuned!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1159c5e3275e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AWS Sagemaker demonstration for machine learning model deployment]]></title>
            <link>https://jyotiyadav99111.medium.com/aws-sagemaker-demonstration-for-machine-learning-model-deployment-fbb26aac127c?source=rss-f8266fc86ce7------2</link>
            <guid isPermaLink="false">https://medium.com/p/fbb26aac127c</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[deep-learning]]></category>
            <category><![CDATA[model]]></category>
            <category><![CDATA[sagemaker]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Jyoti Yadav]]></dc:creator>
            <pubDate>Sun, 25 Jul 2021 05:00:50 GMT</pubDate>
            <atom:updated>2021-08-04T09:23:56.413Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/967/1*ARy7V5aktZ1uM56veDOhyg.jpeg" /></figure><p>Nowadays, every company is reliant on cloud infrastructures. Therefore, it becomes essential for a data scientist to move into that domain as well. The article represents a demonstration of the XGBoost model. The example dataset chosen over here is related to bank products and the target variable depicts if the customers buy it or not</p><p>The code defines the way in which any model can be deployed over the AWS for production purposes. Each and every instruction has been provided in the sheet.</p><h3><strong>AWS Instance Creation</strong></h3><p>Before we begin with the process let&#39;s take care of a few steps which are required to be completed. Please follow the following steps to create the instance in AWS:</p><ol><li>Create AWS Account (No money required)</li><li>Login into AWS Management console</li><li>Search for AWS Sagemaker</li><li>Left-hand side panel navigation → Notebook &gt; Notebook Instances &gt; Create Notebook Instances</li><li>Create IAM Role while creating the notebook instance (This is an essential part of the process because it helps manage the access of the notebook)</li><li>The instance creation will take some time. Once done, please open it and start writing the below code</li></ol><h3>Article Sections</h3><ol><li>Set up environment</li><li>Download and split dataset</li><li>Model</li><li>Deployment</li><li>Predictions</li><li>Delete endpoint</li></ol><h3>1. Set up environment</h3><p>There are some libraries that are required to be installed before we begin the entire process.</p><ol><li><strong>sagemaker </strong>— inbuilt engine to perform modeling and deployment</li><li><strong>boto3 </strong>— help in connecting server with this machine instance</li></ol><p>Specific functions import:</p><ol><li><strong>get_image_uri </strong>— As AWS inbuilt model will be used, it is required to be fetched as a container through this function</li><li><strong>csv_serializer </strong>— This will be used for prediction purposes, as the input will be supplied in the form of the CSV (serialization of the input)</li></ol><pre><strong>import</strong> <strong>urllib</strong><br><strong>import</strong> <strong>os</strong><br><strong>import</strong> <strong>pandas</strong> <strong>as</strong> <strong>pd</strong><br><strong>import</strong> <strong>numpy</strong> <strong>as</strong> <strong>np</strong><br><strong>import</strong> <strong>sagemaker</strong> <br><strong>import</strong> <strong>boto3</strong><br><strong>from</strong> <strong>sagemaker.amazon.amazon_estimator</strong> <strong>import</strong> get_image_uri <br><strong>from</strong> <strong>sagemaker.session</strong> <strong>import</strong> s3_input, Session<br><strong>from</strong> <strong>sagemaker.predictor</strong> <strong>import</strong> csv_serializer</pre><p>This step is to automatically create the S3 bucket in the AWS</p><ol><li>specify the bucket name as per availability</li><li>fetch the region-name (Note: S3 buckets are free of region specification)</li></ol><p>(Note: S3 (Simple storage service) bucket is a data storage platform that provides scalability as well. Region name: location of the operation performed (Eg: N. Virginia))</p><pre>bucket_name = &#39;ba-data-112233&#39;<br><em>#get region name</em><br>my_region = boto3.session.Session().region_name<br>print(my_region)</pre><p>The below code is to connect to S3 (using boto3) and create a bucket for the project</p><pre><em>#get access of the s3 bucket</em><br>s3 = boto3.resource(&#39;s3&#39;)<br><em>#create bucket</em><br><strong>try</strong>:<br>    <strong>if</strong>  my_region == &#39;us-east-1&#39;:<br>        s3.create_bucket(Bucket=bucket_name)<br>    print(&#39;S3 bucket created successfully&#39;)<br><strong>except</strong> <strong>Exception</strong> <strong>as</strong> e:<br>    print(&#39;S3 error: &#39;,e)</pre><p>The bucket will be used for storing everything produced by the entire model. It involves:</p><ol><li>Original data file</li><li>train and test data (created by splitting function)</li><li>model file</li><li>predictions</li></ol><pre><em># set an output path where the trained model will be saved</em><br>prefix = &#39;xgboost_model&#39;<br>output_path =&#39;s3://<strong>{}</strong>/<strong>{}</strong>/output&#39;.format(bucket_name, prefix)<br>print(output_path)</pre><h3>2. Download and split the dataset</h3><p>The data is downloaded from the Github page through urllib library. and then finally converted to the data frame.</p><pre><em># Download data in s3 bucket</em><br><strong>try</strong>:<br>    urllib.request.urlretrieve(&#39;https://raw.githubusercontent.com/jyotiyadav99111/AWS_Bank_Applkication-/main/bank_data.csv&#39;, &#39;bank_data.csv&#39;)<br>    print(&#39;Data Downloaded successfully&#39;)<br><strong>except</strong> <strong>Exception</strong> <strong>as</strong> e:<br>    print(&#39;Downloading error: &#39;,e)</pre><pre><em># load dataset in pandas dataframe</em><br><strong>try</strong>:<br>    df = pd.read_csv(&#39;./bank_data.csv&#39;)   <em># provide relative path in s3 bucket</em><br>    print(&#39;Datafame created successfully&#39;)<br><strong>except</strong> <strong>Exception</strong> <strong>as</strong> e:<br>    print(&#39;Dataframe creation error: &#39;,e)</pre><p>The dataset has been split into training and testing files using NumPy library instead of splitting it into x_train, y_train, x_test, and y_test.</p><pre><em># Train and test data split</em><br>train_data, test_data = np.split(df.sample(frac=1, random_state=1729), [int(0.8 * len(df))])<br>print(train_data.shape, test_data.shape)</pre><p>It is advisable to have the first column of the data as the target variable. The first line of code performs that task. The training and testing set has to be stored in the S3 bucket so that they could be fetched easily every time.</p><pre><em># as per some documentations in AWS the target variable should be the first column</em><br><em># training data saved as csv</em><br>pd.concat([train_data[&#39;y_yes&#39;], train_data.drop([&#39;y_no&#39;, &#39;y_yes&#39;], axis=1)], axis=1).to_csv(&#39;train.csv&#39;, index=<strong>False</strong>, header=<strong>False</strong>)<br><em># upload data to s3 bucket under the &#39;train&#39; folder</em><br>boto3.Session().resource(&#39;s3&#39;).Bucket(bucket_name).Object(os.path.join(prefix, &#39;train/train.csv&#39;)).upload_file(&#39;train.csv&#39;)<br><em># for general upload of the we will reuire path of the data next time </em><br>s3_input_train = sagemaker.TrainingInput(s3_data=&#39;s3://<strong>{}</strong>/<strong>{}</strong>/train&#39;.format(bucket_name, prefix), content_type=&#39;csv&#39;)</pre><p>Repeat it for the testing dataset</p><pre>pd.concat([test_data[&#39;y_yes&#39;], test_data.drop([&#39;y_no&#39;, &#39;y_yes&#39;], axis=1)], axis=1).to_csv(&#39;test.csv&#39;, index=<strong>False</strong>, header=<strong>False</strong>)<br>boto3.Session().resource(&#39;s3&#39;).Bucket(bucket_name).Object(os.path.join(prefix, &#39;test/test.csv&#39;)).upload_file(&#39;test.csv&#39;)<br>s3_input_test = sagemaker.TrainingInput(s3_data=&#39;s3://<strong>{}</strong>/<strong>{}</strong>/test&#39;.format(bucket_name, prefix), content_type=&#39;csv&#39;)</pre><h3>3. Model</h3><p>The AWS inbuilt models are built-in forms of containers or images. These are required to be pulled off and loaded in the instance for use. One can replace ‘xgboost’ with other models to create a corresponding image.</p><pre><em># any algo can be called using this method (not necessarily the xgboost)</em><br>xgboost_container = get_image_uri(boto3.Session().region_name,&#39;xgboost&#39;, repo_version=&#39;latest&#39;)</pre><p>These hyperparameters have been decided base on the pre-training of the dataset on the local machine. As doing it on the cloud with a free tier could be a little slow.</p><pre><em># These hyperparameter have been tuned already on local machine as on AWS it will be alittle slow and costly</em><br>hyperparameters = {<br>        &quot;max_depth&quot;:&quot;5&quot;,<br>        &quot;eta&quot;:&quot;0.2&quot;,<br>        &quot;gamma&quot;:&quot;4&quot;,<br>        &quot;min_child_weight&quot;:&quot;6&quot;,<br>        &quot;subsample&quot;:&quot;0.7&quot;,<br>        &quot;objective&quot;:&quot;binary:logistic&quot;,<br>        &quot;num_round&quot;:50<br>        }</pre><p>Once the parameters have been specified, feed them into the estimator function to create the model architecture. The estimator will remain the same for most of the machine learning algorithms. The last three arguments in ‘Estimator’ function are for controlling the consumption of the cloud and reduce it by ~50%.</p><pre><em># This is a gernal method can be used for any ML algorithms, you just need to specify it in the container itslef</em><br>estimator = sagemaker.estimator.Estimator(image_uri=xgboost_container,<br>                              hyperparameters=hyperparameters,<br>                              role=sagemaker.get_execution_role(),<br>                              train_instance_count=1, <br>                              train_instance_type=&#39;ml.m5.2xlarge&#39;, <br>                              train_volume_size=5, <em># in GBs</em><br>                              output_path=output_path,<br>                              train_use_spot_instances=<strong>True</strong>,<br>                              train_max_run=300,<br>                              train_max_wait=600)</pre><p>Once the basic architecture is in place, training and validation data can be entered into the model. The argument provided thereby takes the storage path to the train and test data which is stored at ‘s3_input_train’ and ‘s3_input_test’.</p><pre><em># final training of the model given the chosen paramters</em><br>estimator.fit({&#39;train&#39;: s3_input_train,&#39;validation&#39;: s3_input_test})</pre><h3>4. Deployment</h3><p>The entire model that has been built is required to make predictions which can be done by making the endpoints.</p><pre>xgb_predictor = estimator.deploy(initial_instance_count=1,instance_type=&#39;ml.m4.xlarge&#39;)</pre><h3>5. Prediction</h3><p>After building the endpoint, predictions can be made through the following code. The first line of the code extracts only the features out of the test dataset. As the data input format will be CSV, therefore it is required to be a serializer. The last line is to convert prediction into an array.</p><pre>test_data_array = test_data.drop([&#39;y_no&#39;, &#39;y_yes&#39;], axis=1).values <em>#load the data into an array</em><br>xgb_predictor.serializer = csv_serializer <em># set the serializer type</em><br>predictions = xgb_predictor.predict(test_data_array).decode(&#39;utf-8&#39;) <em># predict!</em><br>predictions_array = np.fromstring(predictions[1:], sep=&#39;,&#39;) <em># and turn the prediction into an array</em></pre><p>The below code has been taken from the AWS documentation. It is to create the confusion metric.</p><pre>cm = pd.crosstab(index=test_data[&#39;y_yes&#39;], columns=np.round(predictions_array), rownames=[&#39;Observed&#39;], colnames=[&#39;Predicted&#39;])<br>tn = cm.iloc[0,0]; fn = cm.iloc[1,0]; tp = cm.iloc[1,1]; fp = cm.iloc[0,1]; p = (tp+tn)/(tp+tn+fp+fn)*100<br>print(&quot;<strong>\n{0:&lt;20}{1:&lt;4.1f}</strong>%<strong>\n</strong>&quot;.format(&quot;Overall Classification Rate: &quot;, p))<br>print(&quot;<strong>{0:&lt;15}{1:&lt;15}{2:&gt;8}</strong>&quot;.format(&quot;Predicted&quot;, &quot;No Purchase&quot;, &quot;Purchase&quot;))<br>print(&quot;Observed&quot;)<br>print(&quot;<strong>{0:&lt;15}{1:&lt;2.0f}</strong>% (<strong>{2:&lt;}</strong>)<strong>{3:&gt;6.0f}</strong>% (<strong>{4:&lt;}</strong>)&quot;.format(&quot;No Purchase&quot;, tn/(tn+fn)*100,tn, fp/(tp+fp)*100, fp))<br>print(&quot;<strong>{0:&lt;16}{1:&lt;1.0f}</strong>% (<strong>{2:&lt;}</strong>)<strong>{3:&gt;7.0f}</strong>% (<strong>{4:&lt;}</strong>) <strong>\n</strong>&quot;.format(&quot;Purchase&quot;, fn/(tn+fn)*100,fn, tp/(tp+fp)*100, tp))</pre><h4>6. Delete the endpoint</h4><p>Once the model has been created and everything has been accomplished it is a good idea to delete the data and other files.</p><pre>sagemaker.Session().delete_endpoint(xgb_predictor.endpoint)<br>bucket_to_delete = boto3.resource(&#39;s3&#39;).Bucket(bucket_name)<br>bucket_to_delete.objects.all().delete()</pre><p>For full code please refer to the <a href="https://github.com/jyotiyadav99111/AWS_XGBoost_Bank_Application/blob/main/aws_bank_application.ipynb">link</a></p><h4>Conclusion</h4><p>The entire process contains a lot of steps and each step has its own significance in the process. This was a simple example of how a model can be deployed on AWS. Other deep learning models can also be deployed in a similar manner with a bit of advancement of methods.</p><h4>References:</h4><p><a href="https://docs.aws.amazon.com/sagemaker/latest/dg/how-it-works-deployment.html">Deploy a Model in Amazon SageMaker</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fbb26aac127c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Data Science and Blockchain: A Bright future ahead]]></title>
            <link>https://medium.com/thecitadel/data-science-and-blockchain-a-bright-future-ahead-29bfe4fb2b56?source=rss-f8266fc86ce7------2</link>
            <guid isPermaLink="false">https://medium.com/p/29bfe4fb2b56</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[cryptocurrency]]></category>
            <category><![CDATA[future-of-work]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Jyoti Yadav]]></dc:creator>
            <pubDate>Tue, 11 May 2021 07:35:01 GMT</pubDate>
            <atom:updated>2021-05-11T07:35:01.162Z</atom:updated>
            <content:encoded><![CDATA[<p>Recently, blockchain has attracted a lot of attention from Data Scientists. There are chances that it will either become a partner just like other databases or could overtake Data Science to become the most wanted job profile.</p><p>In order to understand the relationship between blockchain and data science, a basic knowledge about the block chain is required. Being a part of the data science community we already know what Data Science is and in which areas it operates.</p><h3>What is Blockchain?</h3><p>It is a type of database, but designed in the form of blocks of information connected with each other through links. Starting from very primitive data storing medium: Excel. It is limited to usually the creator. Then server based databases, which are centralized. Any change in the data will be visible to everyone. But, anyone having access can change the entry in cell. Unlike the other data bases, it is not centralized.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/521/1*xlkgIADNZJ_-3O6fUzBctA.png" /><figcaption>Blockchain Architecture</figcaption></figure><p>It is a distributed ledger completely open to anyone. It helps maintain integrity of blockchains. Once the data is entered to the block, it becomes very difficult to change it. Each block contains three broad elements:</p><p>1) <strong>Data</strong>: In case of bitcoins, it contains transaction details (namely from, to, amount)</p><p>2) <strong>Hash</strong>: Based the information in the block, a hash is created. Think of it as a fingerprint(unique corresponding to information)</p><p>3) <strong>Previous block’s hash</strong>: Hash of previous block is stored in order to maintain integrity and thereby creating a chain.</p><h3>How does it prevent tempering with data?</h3><p>There are three aspects of blockchains that prevent it from being tempered:</p><p>1) <strong>Link to the previous block(hash stored)</strong>: As explained before, hash pertaining to a block is always unique based on the information present in the block. In case, somebody tries to change that information, the hash corresponding to it also changes.</p><p><strong>But how do they validate if its the right hash, as nobody tends to remember it even if its unique?</strong></p><p>Answer to this question is the storage of the previous hash in the block. In case the information of block 1 has been changed, the hash of this block will not match the one stored in the block 2. In order to be successful in tempering data, one need to change the hash of the block 2 as well. If that happens, then the hash of the Block 2 will also change and this continues. Therefore, one needs to change hash of all the subsequent blocks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/514/1*p4IyhdRg6rlxR8ajsGxQDw.png" /><figcaption>Link to previous block explained</figcaption></figure><p><strong>Now-a-days, computers are super fast, it shouldn’t take time. Why not do it?</strong></p><p>2) <strong>Proof-of-work: </strong>A block in the chain is added by miners, they must provide data whose hash matches certain conditions. But, it required heavy computing power as a single digit change in the data will generate the entirely different hash. Its a guess work. It on average takes 10 minutes per block. Thereby answering the above question, this 10 min will delay the entire update time.</p><p><strong>But it is to be done only once for former blocks, if they are less in number this shouldn’t be an issue?</strong></p><p><strong>3) Peer to Peer Network: </strong>As mentioned earlier, it is available with every member. A lock is added only when it has same information as the other peers have. So, in order to temper information, atleast 50% of the peer to peer network. Which is actually A LOT!</p><h3>Application of Data Science in Blockchain Arena</h3><p>Blockchain contains data whereas data science is to get insights from the data. Now-a-days, cyber security has become the first concern for most of the companies. Companies not only lose their data or money, it ends up damaging reputation as well. This can create a lot of impact on machine learning solutions as well. In the underlying data of the model changes, the solutions to the business problem will also get tempered. For example, in case of a pricing model, a change in data might lead to a lose to the company. The situation can be dangerous when it comes to the health industries. Therefore, blockchain provides the following features to avoid above scenarios.</p><p>1) Data Integrity</p><p>2) Preventing malicious intentions</p><p>3) Real-time prediction/analysis</p><p>4) Improved data quality</p><p>Elaborating more on the last two points. Most of the banks are looking into the option of implementing blockchain for money transaction purpose. Irrespective of any geographical boundations, its very fast and built in a way that will make fraudulent activities like money laundering impossible to do. This fast processing makes real time analysis possible. One doesn’t need to wait for data to be entered into the system and go through a lot of validation processes before analysis.</p><p>Coming to the last point, it will have the following advantages:</p><p>1) No missing values</p><p>2) Outliers cant be due to human error but will be telling a different story or a caution for any crisis(which we failed to predict in past)</p><p>3) Human error approaching zero</p><p>Another application could be to analyze data and <strong>predict the “Proof-of-work” hash</strong> which requires a lot to computation till date. We data scientists could be the future miners!</p><p>Once a lot of applications come up through its usage, further opportunities will arise for data scientists. Therefore, dive into the pool of Blockchain and open gates for your future self!</p><p><strong>Final Note:</strong></p><p>Thanks for reading this blog, it requires a lot of patience to learn about new technologies. Kudos to you!</p><p>Please let me know of any questions/doubts you have regarding or anything related to machine learning. Share your feedback/views in the comments below.</p><p>You can reach out to me on <a href="https://in.linkedin.com/in/jyoti-yadav-b8232969">LinkedIn </a>as well :)</p><blockquote>This article uses “Icon made by <a href="https://www.flaticon.com/authors/freepik">Freepik</a> from <a href="http://www.flaticon.com/">www.flaticon.com</a>&quot; to design the above showcased image.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=29bfe4fb2b56" width="1" height="1" alt=""><hr><p><a href="https://medium.com/thecitadel/data-science-and-blockchain-a-bright-future-ahead-29bfe4fb2b56">Data Science and Blockchain: A Bright future ahead</a> was originally published in <a href="https://medium.com/thecitadel">The Citadel</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Tensorflow: Multiple Linear Regression model from scratch with calculations explained]]></title>
            <link>https://jyotiyadav99111.medium.com/tensorflow-multiple-linear-regression-model-from-scratch-with-calculations-explained-e75d6dec820d?source=rss-f8266fc86ce7------2</link>
            <guid isPermaLink="false">https://medium.com/p/e75d6dec820d</guid>
            <category><![CDATA[google]]></category>
            <category><![CDATA[tensorflow]]></category>
            <category><![CDATA[multiple-linearregression]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Jyoti Yadav]]></dc:creator>
            <pubDate>Sun, 11 Apr 2021 19:28:59 GMT</pubDate>
            <atom:updated>2021-04-11T19:28:59.729Z</atom:updated>
            <content:encoded><![CDATA[<p>For a beginner, given the pool of resources available over internet, it becomes very difficult to understand even the basics of Tensorflow. This sometimes ends up getting demotivated. Once something is left, its hard to pick it up again with the fear of losing again. Then another defeat makes the next try exponentially tough :( . So, in order to break this vicious cycle, I am writing this very easy and understandable approach for a first time learner :) .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/740/1*FPGjaiCnZ2vPkLHj8gnB_A.png" /><figcaption>Source: <a href="https://xkcd.com/1831/">https://xkcd.com/1831/</a></figcaption></figure><p>In this section, we will be converting linear regression equations into a tensorflow code. I hope all of us are familiar with basics of matrix multiplication :P . ARE WE READYYYY?????</p><p><em>(In case you are new to metrix operations, please refer to this link for full explanation: </em><a href="https://online.stat.psu.edu/stat462/node/132/"><em>https://online.stat.psu.edu/stat462/node/132/</em></a><em>)</em></p><p>Let’s start!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/461/1*_qoaFqMVgjstmtJNp-zNrw.png" /><figcaption>Source: <a href="https://xkcd.com/605/">https://xkcd.com/605/</a></figcaption></figure><p>The matrix representation for linear regression looks like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/393/1*HCTaYdJvGpg-7YqGLwjhJA.png" /><figcaption>Equation 1: <a href="https://online.stat.psu.edu/stat462/node/132/">https://online.stat.psu.edu/stat462/node/132/</a></figcaption></figure><p>After a bit of struggle with the above matrices, spits out the following formula for least square estimates:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/422/1*QF4emjEZmj1L0_SjykbSRA.png" /><figcaption>Equation 2: <a href="https://online.stat.psu.edu/stat462/node/132/">https://online.stat.psu.edu/stat462/node/132/</a></figcaption></figure><p>Our task is to convert these equations into a code involving tensorflow library. Sounds easy?</p><p>There are two sections to this article:</p><ol><li>Multiple Linear Regression</li><li>Multiple Linear Regression with manual computation of gradients</li></ol><h3>Multiple Linear Regression</h3><ol><li>Import useful libraries</li></ol><pre>import numpy as np<br>import tensorflow as tf<br>from sklearn.datasets import fetch_california_housing<br>from sklearn.preprocessing import StandardScaler</pre><p>2. Download data</p><pre>fetched_data = fetch_california_housing()<br>m, n = fetched_data.data.shape<br>data_with_bias = np.c_[np.ones((m,1)), fetched_data.data]</pre><p>Data snapshot:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/783/1*Rcmqt15-TNTzLGZeiBjyBg.png" /></figure><p>The first line in the code pulls up the inbuilt dataset in scikit-learn library. The data is divided into two parts: features and target. In order to call features use <strong>“fetched_data.data”</strong> and for target use <strong>“fetched_data.target”</strong>. In order to pull the column names use <strong>“fetched_data.feature_names”</strong>. The last line of the code adds a bias term(a column containing 1s) in the feature set(as depicted in the matrix equation 1).</p><p>3. Create Tensors for feature and target variable</p><pre>X = tf.constant(data_with_bias , dtype = tf.float32, name = &quot;features&quot;)</pre><pre>y = tf.constant(fetched_data.target.reshape(-1,1), dtype = tf.float32, name = &quot;target&quot;)</pre><p>X and y are the features and targets respectively. Since they are going to remain same for the entire analysis(Non-stochastic), they have been considered as constants.</p><p>4. Calculate b(or theta)(formula used in second equation)</p><pre>XT = tf.transpose(X)</pre><pre>theta = tf.matmul(tf.matmul(tf.linalg.inv(tf.matmul(XT, X)), XT), y)</pre><pre>print(theta)</pre><p>XT is the transpose of matrix X and tf.matmul is for matrix multiplication. tf.linalg.inv takes the inverse of the matrices added inside it. Try matching it with the matrix equation 2.</p><h3>2. Multiple Linear Regression with manual computation of gradients</h3><p>This section will help you understand how the above calculated theta can be optimized through the loss function as it is updated as a fraction of loss function. This is based on “<a href="https://en.wikipedia.org/wiki/Gradient_descent#:~:text=Gradient%20descent%20is%20a%20first,the%20direction%20of%20steepest%20descent.">Gradient Descent</a>” approach. In short, the coefficients(theta) are updated in the direction of negative slope.</p><p>The formula for coefficient(theta) update function is :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/466/1*erQuvxZrV_1Nx2QV1elrTQ.png" /><figcaption>Equation 3</figcaption></figure><p>lets standardize the variables, as it will reduce the computation time for every epoch(through there are other mathematical reasons behind standardization, but lets consider this one here).</p><pre>scaler = StandardScaler()</pre><pre>scaled_data = scaler.fit_transform(data_with_bias)</pre><ol><li>Decide on the number of epochs and learning rate:</li></ol><pre>n_epoch = 1000</pre><pre>learning_rate = 0.0000001</pre><p>n_epochs refers to the number of iterations, in case the saturation point in loss is not reached, try increasing it. Whereas, learning rate is the fraction by which theta will update. A higher value of learning rate will create “Exploding gradient issue” whereas a very small value will lead to long training time. CHOOSE IT WISELY, AS IF YOUR LIFE DEPENDS ON IT!</p><p>2. Create Tensors for Scaled feature</p><pre>X = tf.constant(scaled_data, dtype = tf.float32, name = &quot;Scaled Features&quot;)</pre><p>3. Initialise the theta using uniform distribution</p><pre>theta = tf.Variable(tf.random.uniform([n+1, 1], -1.0, 1.0), name = &quot;theta&quot;)</pre><p>The uniform distribution has a range of [-1,1] so that both negative &amp; positive values are considered to be the starting point. Theta is considered as variable here as its value is going to update over time. “n” is the number of features her(calculated earlier), there will be n+1(features + bias term) coefficients there. Therefore theta will have n+1 rows and 1 column.</p><p>4. Start the loop</p><pre>for epoch in range(n_epoch):</pre><pre>   y_pred = tf.matmul(X, theta, name = &quot;predictions&quot;)</pre><pre>   error = y_pred - y</pre><pre>   mse = tf.reduce_mean(tf.square(error), name = &quot;mse&quot;)</pre><pre>   gradients = 2/m * tf.matmul(tf.transpose(X), error)</pre><pre>   theta = theta - learning_rate * gradients</pre><pre>  <br>   if epoch % 100 == 0:</pre><pre>      print(&quot;Epoch: &quot;, epoch, &quot;MSE: &quot;, mse)</pre><p>The process inside a loop will be repeated n_epoch times. The first line inside the loop calculates the prediction which is simply coefficients * features. The second line calculated the deviation between the predicted value and the actual value(target variable). Third line makes use of the error to calculate loss. Higher the deviation higher will be the loss and thereby the adjustment in the theta. forth line calculates the gradient. Fifth line finally uses gradient to update theta in every epoch(try matching it with equation 3).</p><p>If the epochs are a multiple of 100, the code will print out the epoch number and corresponding loss.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/560/1*N6kHdemWVzN59CNOAIWP3A.png" /></figure><p>As you can see the loss is decreasing by every epoch. SUCCESS!!!!</p><p>I will be adding more posts on tensorflow and Neural Networks. STAY TUNED!!!!</p><p>Ending with a funny comic strip! Thanks!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/405/1*PrTxATSZI7gXu8kseYvkOw.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e75d6dec820d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Is Google BigBird gonna be the new leader in NLP domain?]]></title>
            <link>https://jyotiyadav99111.medium.com/is-google-bigbird-gonna-be-the-new-leader-in-nlp-domain-8c95cecc30f8?source=rss-f8266fc86ce7------2</link>
            <guid isPermaLink="false">https://medium.com/p/8c95cecc30f8</guid>
            <category><![CDATA[bert]]></category>
            <category><![CDATA[google]]></category>
            <category><![CDATA[nlp]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[big-bird]]></category>
            <dc:creator><![CDATA[Jyoti Yadav]]></dc:creator>
            <pubDate>Sat, 12 Sep 2020 12:28:27 GMT</pubDate>
            <atom:updated>2020-11-02T15:58:52.346Z</atom:updated>
            <content:encoded><![CDATA[<h3>Understanding BigBird | Is Google BigBird gonna be the new leader in the NLP domain?</h3><p>In 2018, Google released a big fish in the market termed <strong>BERT</strong>(Bidirectional Encoder Representations from Transformers). It brought state-of-the-art accuracy on NLP and NLU tasks. The distinguishing factor was “Bidirectional Training” which was proved to be holding great potential in giving a deeper sense of language context. Before BERT, models used to analyze text sequences either from left to right or combined left-to-right and right-to-left training.</p><p>Recently, Google has released another breakthrough in the domain by introducing BigBird.</p><h3>What is new?</h3><p>BigBird has eradicated the problem of the “quadratic resource requirement” of attention mechanism which was the main roadblock in scaling up the transformers to long sequences.</p><p>It replaces the full quadratic attention mechanism with a mix of random attention, window attention, and global attention. Thereby proposing a linear memory requirement instead of a quadratic memory requirement. Not only does this allow the processing of longer sequences unlike BERT. But, the paper also shows that BigBird comes with theoretical guarantees of <a href="https://en.wikipedia.org/wiki/Universal_approximation_theorem">universal approximation</a> and <a href="https://en.wikipedia.org/wiki/Turing_completeness">turing completeness</a>.</p><h3>What is the Quadratic memory requirement?</h3><p>It was proved that the models using the transformer perform much better than the alternatives. BERT is essentially based on the full attention mechanism. Let&#39;s assume, ‘n’ tokens are required to be processed by the model. As per the full attention model, the result of the node should be better than the corresponding token. Therefore, ’n’ nodes are required to be fully connected to the ‘n’ tokens which are to be processed. This leads to n² amount of computation and memory requirements.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/846/1*VHNnJnrfLDVjzN5HCNQtKQ.png" /><figcaption>Full attention mechanism small illustration</figcaption></figure><p>Therefore, this leads to a limitation on the tokens. BERT can analyze 512 tokens at a time. BigBird reduces these quadratic dependencies by the introduction to a combination of random attention, window attention, and global attention which thereby leads to linear memory requirement.</p><h3>What are the different forms of attention mechanisms used in BigBird?</h3><p>BigBird uses a combination of the following three types of attention mechanisms:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/607/1*I7bQ06VeNuYyz8wiqGgO7Q.png" /><figcaption>Building blocks of the attention mechanism used in BigBird. White color indicates the absence of attention. (a) random attention with r = 2, (b) sliding window attention with w = 3 ( c) global attention with g = 2. (d) the combined BigBird model (<a href="https://arxiv.org/abs/2007.14062">https://arxiv.org/abs/2007.14062</a>)</figcaption></figure><ol><li><strong>Random Mechanism(Path lengths are logarithmic): </strong>With random parameter(r) equal to 2, every token is connected with randomly chosen 2 nodes. which reduces the computation complexity to O(r*n). In case of full attention, information can flow from each node to every other node as they are fully connected. But under random attention, then it will take more steps to go from one node to another as all are not connected.</li><li><strong>Window Mechanism(Neighbors are important): </strong>With a given window parameter(w) = 2, every node is connected to itself but also connected to its neighbors. The number of neighbors it will be connected on each side is w/2. Since w is a constant, the complexity reduces to w*n.</li><li><strong>Global Mechanism(star shape network): </strong>It involves the addition of a node to each layer where each new node receives input from the previous layer and sends output to all the nodes in the next layer.</li></ol><p>Window and global attention are used in the “long former” as well but BigBird incorporates random attention along with the “long former”. Random attention adds more connection to the overall mechanism which will improve the results of the model(More attention is better).</p><h3>Increase in input sequence length</h3><p>In order to make this sparse attention more effective, the model requires more number of layers as compared to full attention.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/396/1*l28djkSStWbPGjKmbHRN5Q.png" /><figcaption>Hyperparameters for the two BigBird base models for MLM (<a href="https://arxiv.org/abs/2007.14062">https://arxiv.org/abs/2007.14062</a>)</figcaption></figure><p>Here, analyzing the hyperparameters of the BIGBIRD-ITC,</p><p>block length, b = 64</p><p>Number of global tokens, g = 2*b</p><p>Window length, w = 3*b</p><p>Number of random tokens, r = 3*b</p><p>therefore, the total is 8*b = <strong>512</strong></p><p>Whereas, the number of hidden layers = 12, Hidden layers size(number of nodes within each hidden layer) = 768</p><p>And finally this <strong>huge architecture is able to</strong> <strong>process a maximum of 4096 </strong>token sequences.</p><p>Whereas, in the case of BIGBIRD-ETC, they have used 0 random tokens and are utilizing global tokens more. But, the random attention is the key component that makes BigBird different from the Long Former.</p><h3><strong>Results</strong></h3><p>BigBird has overpowered Longformer and BERT as depicted below. Whereas, out of 7 cases, BIGBIRD-ETC(where the random token is 0) has performed better for 5 cases.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/566/1*Wl5SUUDCeBOLidKRs4J9Uw.png" /><figcaption>QA Dev results using Base size models. We report accuracy for WikiHop and F1 for HotpotQA, Natural Questions, and TriviaQA(<a href="https://arxiv.org/abs/2007.14062">https://arxiv.org/abs/2007.14062</a>)</figcaption></figure><p>As compared to the standard models(presented below), BigBird is able to reserve its place and is proven to be the <strong>new State-of-the-art for Natural Questions Long Answer (LA), TriviaQA Verified, and WikiHop.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/601/1*JCscihead2w039NGIjmXXA.png" /><figcaption>Fine-tuning results on Test set for QA tasks (<a href="https://arxiv.org/abs/2007.14062">https://arxiv.org/abs/2007.14062</a>)</figcaption></figure><p>To conclude, BigBird is a sparse attention mechanism(introduction of random attention) that has converted the quadratic memory requirements by full attention model to linear requirement. The paper has provided several theoretical proves to the claim. But, complexities might arise in terms of more number of layers required(due to sparse connection). Whereas, the outperforming BIGBERT-ETC(state-of-the-art) model does not use random attention.</p><p>References:</p><ul><li><a href="https://arxiv.org/abs/2007.14062">Big Bird: Transformers for Longer Sequences</a></li><li><a href="https://github.com/google-research/bert">GitHub - google-research/bert: TensorFlow code and pre-trained models for BERT</a></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*78JmWtfsMYMGvtZ97VVISg.jpeg" /><figcaption>cover</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8c95cecc30f8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SVM(Part-1): Prerequisites — vectors, linear separability and hyperplane]]></title>
            <link>https://jyotiyadav99111.medium.com/svm-part-1-prerequisites-vectors-linear-separability-and-hyperplane-a810b71ed53d?source=rss-f8266fc86ce7------2</link>
            <guid isPermaLink="false">https://medium.com/p/a810b71ed53d</guid>
            <category><![CDATA[mathematics]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[svm]]></category>
            <category><![CDATA[hyperplane]]></category>
            <category><![CDATA[linear-separability]]></category>
            <dc:creator><![CDATA[Jyoti Yadav]]></dc:creator>
            <pubDate>Tue, 07 Jan 2020 16:03:05 GMT</pubDate>
            <atom:updated>2020-01-07T16:03:05.062Z</atom:updated>
            <content:encoded><![CDATA[<h3>SVM(Part-1): Prerequisites — vectors, linear separability and hyperplane</h3><p>I am starting with a new series of posts data science enthusiasts who are struggling to understand Support Vector Machines(SVMs). This series will not only include detailed description of SVMs but also other dimensions attached to it.</p><h3><strong>Vectors</strong></h3><p>The term Support Vector Machine contains a mathematical term “Vectors”. So, the natural question comes to the mind is “What is the significance of this term in the entire algorithm”. For any of the machine learning algorithms operations on vectors is one of the fundamental part.</p><p>In mathematics, vector is an object that has two components: magnitude &amp; direction. The magnitude of a vector is more formally called its <strong>norm</strong>. It is the euclidean distance of the coordinates of the vector from the origin. Euclidean norm of a vector x lying in an ’n’ dimension space can be calculated as:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/204/1*xWJ4k7_rbxMh11B8HmTbJg.gif" /></figure><p>Whereas, the direction of a vector is angle between the vector and the horizontal line. It can be calculated through the following formula:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/156/1*zKndFDVdQohQwXzePaN6Xw.gif" /></figure><h3>Linear Separability</h3><p>We will understand linear separability through some examples. Lets consider a case study, a factory produces two types of soaps: organic soap and normal soap. In past days, they have observed that a few of the customers are getting a normal soap instead of organic soap.</p><p>The manager observed a trend in the weight of two soaps. The organic soap is having weight greater that 135 gm and the other one has weight smaller than it. Therefore, two of the soap can be segregated based on the decision boundary of 135 gm. This type of data where a linear hyperplane can classify the data into the required categories, is a linearly separable dataset.</p><h3>Hyperplanes</h3><p>Aim of the SVM is to find the optimal hyperplane that is capable of separating the corresponding plane. Hyperplane is a subspace having one dimension less than the space under consideration. For a three dimensional space, a line will be considered as a hyperplane. y =ax + b is the equation of a line and is a very simple example of a hyperplane.</p><p>In terms of the vectors it can be written as:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/94/1*FQHCdRcRj6pPMlb4Al4KLw.gif" /></figure><p>Where, w = (a, -1) and x = (x, y).</p><p>Understanding the classification of the data with a hyperplane. The following is an example of linearly separable datapoints with the above mentioned line format as the hyperplane separating the two classes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*Lm3kGAZfwD_bcCbhrVKS-g.jpeg" /><figcaption>Linear separation through a hyperplane</figcaption></figure><p>With each vector x there is a label y, these labels can have a value of +1 and -1. The points that lie on the line have a label of 0. The points lying above the line have a label of +1 and the ones lying below the line are labelled as -1.</p><p>The above labelling and separation can be represented through the equations as:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/353/1*wA--AhUKLUX21Hi0L-5gRw.gif" /></figure><p>or,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/171/1*-_GEIcjBAseg7vyrYEk7iw.gif" /></figure><p>Since, this is a function that produces linear combination of value, it is referred to as a <strong>linear classifier</strong>.</p><p>Above was the simple explanation of the essential topic for understanding SVMs. The other difficult topics will be explained in the subsequent articles.</p><p>Stay tuned!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a810b71ed53d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Selecting optimal number of clusters in KMeans Algorithm(Silhouette Score)]]></title>
            <link>https://jyotiyadav99111.medium.com/selecting-optimal-number-of-clusters-in-kmeans-algorithm-silhouette-score-c0d9ebb11308?source=rss-f8266fc86ce7------2</link>
            <guid isPermaLink="false">https://medium.com/p/c0d9ebb11308</guid>
            <category><![CDATA[optimal-cluster]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[k-means]]></category>
            <category><![CDATA[silhouette-score]]></category>
            <category><![CDATA[cluster]]></category>
            <dc:creator><![CDATA[Jyoti Yadav]]></dc:creator>
            <pubDate>Sat, 17 Aug 2019 03:32:03 GMT</pubDate>
            <atom:updated>2019-08-17T03:32:03.738Z</atom:updated>
            <content:encoded><![CDATA[<p>KMeans is a unsupervised machine learning technique primarily used for the clubbing similar instances together. In case of supervised learning, there are multiple ways of validating the results. But in case of unsupervised learning, the only way to validate the score is trough visualization. But, this technique also has its limitations which is the higher number of dimensions.</p><p>While training the model, an expert is required to decide the number of the clusters that should be there. This becomes very difficult as the dimension of the data increases. There are two simple and popular methods of doing this.</p><ol><li><strong>Inertia:</strong> It is defined as the mean squared distance between each instance and its closest centroid. Logically, as per the definition lower the inertia better the model. In general, the KMeans package of sklearn runs the algorithm for ‘n_init’ number of times and chooses the one having the lowest inertia. This approcah has a limitation, as the number of clusters increases, closest will be the clusters from the centroids and lower will be the inertia. Therefore, in this case, it is a good idea to plot the graph of inertia as the number of clusters increase. Elbow rule is used in orde rto find the optimal number of clusters. As depicted in the following diagram, curve looks like a hand and the number of clusters to be chosen over there should be equal to 3 as after that curve reaches a plateau.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/360/1*zUmFlJjvjeonOk7p3mDFfA.png" /><figcaption>Elbow Method for interia</figcaption></figure><p>2. <strong>Silhouette Score: </strong>This is a better measure to decide the number of clusters to be formulated from the data. It is calculated for each instance and the formula goes like this:</p><p><strong><em>Silhouette Coefficient = (x-y)/ max(x,y)</em></strong></p><p>where, <strong>y</strong> is the mean intra cluster distance: mean distance to the other instances in the same cluster. <strong>x</strong> depicts mean nearest cluster distance i.e. mean distance to the instances of the next closest cluster.</p><p>The coefficient varies between -1 and 1. A value close to 1 implies that the instance is close to its cluster is a part of the right cluster. Whereas, a value close to -1 means that the value is assigned to the wrong cluster.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/360/1*ftfk97tHNG9pF25BRD8GsA.png" /><figcaption>Silhouette Method</figcaption></figure><p>As per this method k=3 was a local optima, whereas k=5 should be chosen for the number of clusters. This method is better as it makes the decision regarding the optimal number of clusters more meaningful and clear. But this metric is computation expensive as the coefficient is calculated for every instance. Therefore, decision regarding the optimal metric to be chosen for the number of cluster decision is to be made according to the needs of the product.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c0d9ebb11308" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Statistics: How Should I interpret results of OLS?]]></title>
            <link>https://jyotiyadav99111.medium.com/statistics-how-should-i-interpret-results-of-ols-3bde1ebeec01?source=rss-f8266fc86ce7------2</link>
            <guid isPermaLink="false">https://medium.com/p/3bde1ebeec01</guid>
            <category><![CDATA[jbtest]]></category>
            <category><![CDATA[statistics]]></category>
            <category><![CDATA[lo]]></category>
            <category><![CDATA[model-selection]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Jyoti Yadav]]></dc:creator>
            <pubDate>Thu, 15 Aug 2019 15:55:29 GMT</pubDate>
            <atom:updated>2019-08-15T15:55:29.880Z</atom:updated>
            <content:encoded><![CDATA[<p>Linear regression is a simple but powerful tool to analyze relationship between a set of independent and dependent variables. But, often people tend to ignore the assumptions of OLS before interpreting the results of it. Therefore, it is an essential step to analyze various statistics revealed by OLS.</p><p>In statistics, model selection is an art. a lot of factors are taken into consideration in case making this art meaningful. Let look at each of the statistic one by one and see how can that affect the reliability of the results . In the following example, five variables are regressed on an output variable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/378/1*xQuFRB1f295dDRt6c0vD2g.png" /><figcaption>OLS Regression Results</figcaption></figure><p><strong>R-squared: </strong>It signifies the “percentage variation in dependent that is explained by independent variables”. Here, 73.2% variation in y is explained by X1, X2, X3, X4 and X5. This statistic has a drawback, it increases with the number of predictors(dependent variables) increase. Therefore, it becomes inconclusive in case when it is to be decided whether additional variable is adding to the predictability power of the regression.</p><p><strong>Adj. R-squared: </strong>This is the modified version of R-squared which is adjusted for the number of variables in the regression. It increases only when an additional variable adds to the explanatory power to the regression.</p><p><strong>Prob(F-Statistic): </strong>This tells the overall significance of the regression. This is to assess the significance level of all the variables together unlike the t-statistic that measures it for individual variables. The null hypothesis under this is “all the regression coefficients are equal to zero”. Prob(F-statistics) depicts the probability of null hypothesis being true. As per the above results, probability is close to zero. This implies that overall the regressions is meaningful.</p><p><strong>AIC/BIC: </strong>It stands for <em>Akaike’s Information Criteria</em> and is used for model selection. It penalizes the errors mode in case a new variable is added to the regression equation. It is calculated as number of parameters minus the likelihood of the overall model. A lower AIC implies a better model. Whereas, BIC stands for <em>Bayesian information criteria </em>and is a variant of AIC where penalties are made more severe.</p><p><strong>Prob(Omnibus): </strong>One of the assumptions of OLS is that the errors are normally distributed. Omnibus test is performed in order to check this. Here, the null hypothesis is that the errors are normally distributed. Prob(Omnibus) is supposed to be close to the 1 in order for it to satisfy the OLS assumption. In this case Prob(Omnibus) is 0.062, which implies that the OLS assumption is not satisfied. Due to this, the coefficients estimated out of it are not Best Linear Unbiased Estimators(BLUE).</p><p><strong>Durbin-watson:</strong> Another assumption of OLS is of homoscedasticity. This implies that the variance of errors is constant. A value between 1 to 2 is preferred. Here, it is ~1.8 implying that the regression results are reliable from the interpretation side of this metric.</p><p><strong>Prob(Jarque-Bera)</strong>: It i in line with the Omnibus test. It is also performed for the distribution analysis of the regression errors. It is supposed to agree with the results of Omnibus test. A large value of JB test indicates that the errors are not normally distributed.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3bde1ebeec01" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>