<?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 Shashvat G on Medium]]></title>
        <description><![CDATA[Stories by Shashvat G on Medium]]></description>
        <link>https://medium.com/@shashvat01?source=rss-73ad232e2402------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*0W40Fq40mqsSP9UZba24Gg.jpeg</url>
            <title>Stories by Shashvat G on Medium</title>
            <link>https://medium.com/@shashvat01?source=rss-73ad232e2402------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 14:22:08 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@shashvat01/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[Getting Started with PySpark]]></title>
            <link>https://medium.com/analytics-vidhya/getting-started-with-pyspark-251a0af0f2c4?source=rss-73ad232e2402------2</link>
            <guid isPermaLink="false">https://medium.com/p/251a0af0f2c4</guid>
            <category><![CDATA[pyspark]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Shashvat G]]></dc:creator>
            <pubDate>Mon, 11 Oct 2021 07:11:27 GMT</pubDate>
            <atom:updated>2021-10-11T07:11:27.042Z</atom:updated>
            <content:encoded><![CDATA[<h4>Distributed Computing with Spark</h4><h4>Connect to Spark Cluster using Python</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*LCA73KkeJyTqjUl_" /><figcaption>Photo by <a href="https://unsplash.com/@wflwong?utm_source=medium&amp;utm_medium=referral">Warren Wong</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>In the last decade, there has been unprecedented demand for fast and reliable tools to handle and process the streaming of big data. One of the ways to tackle this is <a href="https://en.wikipedia.org/wiki/MapReduce#:~:text=MapReduce%20is%20a%20programming%20model,distributed%20algorithm%20on%20a%20cluster.&amp;text=MapReduce%20libraries%20have%20been%20written,with%20different%20levels%20of%20optimization.">MapReduce</a>- however, that does not only take a lot of time but is also unable to handle real-time data. Spark comes to the rescue! Spark was introduced by UC Berkeley Lab and open-sourced in 2010. It offers a solution that is both fast and general-purpose. One major advantage of Spark is that it runs computations in memory. Another one is the <a href="https://data-flair.training/blogs/apache-spark-lazy-evaluation/">Lazy Computation</a> mechanism which simply means no action until asked explicitly. This helps in quicker data processing and hence reducing time significantly.</p><p>Spark’s magic lies in its RDDs — Resilient Distributed Datasets. If you are familiar with Pandas Data frame, this will probably be easier for you. A level of abstraction of RDDs is Spark DataFrame which is simpler to work with and automatically optimized.</p><h4>First things first, What is Spark?</h4><p>Spark is a cluster computing framework that divides a task among a cluster of computers called nodes for fast and efficient processing. This splitting of data makes it easier to work with huge datasets. Each of the nodes works on computation assigned in parallel which is combined later to return the final result.</p><p><strong>What’s PySpark then?</strong></p><p>I’m glad you asked — It’s an<strong> </strong>interface for Apache Spark in Python<strong> </strong>which allows you to write Spark applications using Python APIs. In simple terms, PySpark is a way to connect to Spark cluster using Python.</p><p><strong>Why do you need Spark Data Frame if you have Pandas Data Frame?</strong></p><p>Good Question — If you have to think if you need Spark, probably you don’t need Spark at all. Honestly, unless you are dealing with really large data sets, Pandas work just fine. The primary difference between these is that pandas DataFrame’s are not distributed and runs on a single node. One of the advantages of the Spark DataFrame interface is that you can run SQL queries on the tables in your Spark cluster.</p><h4>Pandas Dataframe Columns Vs Spark Data Frame Columns</h4><p>Notably, updating a Spark DataFrame is somewhat different than working in <em>pandas</em> because the Spark DataFrame is <em>immutable</em>. This means that it can&#39;t be changed, and so columns can&#39;t be updated in place.</p><h4>Installation</h4><p>You can install Spark <a href="https://spark.apache.org/downloads.html">here</a>. It’s worth mentioning that spark is written in Scala and interacts with the JVM interface using py4j. Hence, to run PySpark, you also need <a href="https://www.java.com/en/download/">Java</a> to be installed along with Python, and Apache Spark.</p><p>To get yourself familiar with the spark ecosystem, I would recommend running spark locally before configuring it to run on a cluster as it can be run standalone.</p><p>Now that we have seen how to get <em>Spark</em>, we can now connect to a cluster and go through some basics. Without further ado, Let’s crack on —</p><ul><li><strong>Connecting to a Spark Cluster using PySpark</strong> — First of all, we need a connection to the cluster. This is done using creating an instance of the SparkContext class. To verify which version of Spark you’re running. Try this: print(SparkContext.version)</li><li><strong>Working with Spark DataFrames</strong> — Once we have a connection to the cluster, we can use that to createSparkSession object from your SparkContext. You can think of SparkContext as your connection to the cluster and SparkSession as your interface with that connection. To avoid multiple connections and sessions it is better to use<strong> SparkSession.builder.getOrCreate()</strong></li></ul><pre>#Import SparkSession<br>from pyspark.sql import SparkSession<br>#Create Session<br>spark = SparkSession.builder.getOrCreate()</pre><ul><li>You can use spark.catalog.listTables() to see all tables in your cluster. To list table contents, show() can be used. Ex- Table1.show()will display 20 rows and all the columns from the table1.</li><li>The .createDataFrame() method takes a pandas DataFrame and returns a Spark DataFrame. Please note that the created data frames will not persist in the Session catalog as they are stored locally. This means that you can use all the Spark DataFrame methods on it, but you can&#39;t access the data in other contexts.</li><li>.select() method— Used to select columns from Spark Dataframe. Also, when you’re selecting a column using the df.colName notation, you can perform any column operation and it will return the transformed column. For instance — see below.</li></ul><pre># Weekly Salary when you have monthly salary</pre><pre>Week_Salary = (df.select(df.salary/4)).alias(“weekly salary”)</pre><ul><li>.filter() method — As you would have guessed, this is the Spark equivalent of SQL’s WHERE clause. The takes either an expression that would follow the WHERE clause of a SQL expression as a string or a Spark column of boolean (True/False) values.</li></ul><pre>#SQL<br>SELECT * FROM table WHERE column &gt; 120</pre><pre>#PySpark<br>table.filter(&quot;column &gt; value&quot;).show()</pre><ul><li>.createTempView() Spark DataFrame method can help you build a temporary table and accepts the name as an argument of the temporary table you&#39;d like to register. This method registers the DataFrame as a table in the catalog, but as this table is temporary, it can only be accessed from the specific SparkSession used to create the Spark DataFrame.</li><li>spark.read.csv(file_path) can be used to read a file in PySpark. If your file has headers which it often will, you can pass an argument that tells spark to expect the first line to be the header.spark.read.csv(file_path,header = True)</li><li>.withColumn()method which takes two arguments and can be used to create a new column in the data set. First, a string with the name of your new column, and second the new column itself. Ex — Increase Price by 100. df.withColumn(&quot;price&quot;,col(&quot;price&quot;)+100).show()</li><li>Sometimes it makes sense to then take that table and work with it locally using a tool like pandas. Spark DataFrames make that easy with the .toPandas()</li><li>Another common database task is aggregation. That is, reducing your data by breaking it into parts and summarizing each part. It is also possible to GROUP BY (.groupBy()) more than one column. If you have two columns in a group by, their unique combination will be there in the output.</li></ul><p>That’s it for now folks!</p><h3>Takeaways</h3><p>In this post, we walked through some of the frequently used basic queries to make an acquaintance with PySpark. Essentially, PySpark is a way to get Python to talk with Spark Cluster. If you have a bit of background in SQL and Python, you can jump on to PySpark ship 🚢 pretty quickly.</p><p>Spark has been widely adopted and is used extensively in Data Science and Machine Learning community as a large-scale analytical processing engine. The stack includes support for real-time as well as batch data processing with Spark Streaming, Spark Machine learning libraries(MLLib), and Spark SQL. Read more about them <a href="https://spark.apache.org/">here</a>!</p><p>Depending on your preference and problem, it might be worth having a look at <a href="https://medium.com/swlh/parallel-processing-in-python-using-dask-a9a01739902a">Dask</a>. Any questions, please give me a shout!</p><p>I’m glad you came this far! Thanks for your time. Whatever you are up to, Have a good one 😄</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=251a0af0f2c4" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/getting-started-with-pyspark-251a0af0f2c4">Getting Started with PySpark</a> was originally published in <a href="https://medium.com/analytics-vidhya">Analytics Vidhya</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kubernetes Basics in Under 5 Mins]]></title>
            <link>https://medium.com/geekculture/kubernetes-basics-in-under-5-mins-c80cda99ccbb?source=rss-73ad232e2402------2</link>
            <guid isPermaLink="false">https://medium.com/p/c80cda99ccbb</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[containers]]></category>
            <dc:creator><![CDATA[Shashvat G]]></dc:creator>
            <pubDate>Wed, 12 May 2021 05:03:14 GMT</pubDate>
            <atom:updated>2021-05-12T05:03:14.216Z</atom:updated>
            <content:encoded><![CDATA[<h4>Container Orchestration with K8s</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*eXrdwGvLlthTDRDm" /><figcaption>Photo by <a href="https://unsplash.com/@garrettpsystems?utm_source=medium&amp;utm_medium=referral">Garrett parker</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p><em>Kubernetes, </em>I am almost certain you have heard the term at some point if you are a techie. No worries, if not. In this article, we will cover the basics of <a href="https://en.wikipedia.org/wiki/Kubernetes">Kubernetes</a> and its high-level architecture. Kubernetes is a container orchestration system. Container orchestration is the management of individual web servers operating in containers. So, we need containers before we can orchestrate them.</p><p>Before we dive into detail, let’s understand the concept of containers briefly, as an understanding of containers is a prerequisite to Kubernetes.</p><h4>So, what is a container?</h4><p>A container is something that enables wrapping up all your application code and dependencies and hence making everything you need to run the application is ready to be shipped across platforms. It is important to note that Kubernetes isn’t a replacement for Docker but a supplement. If docker were a baby, K8 would be a babysitter.</p><h4>Why Kubernetes?</h4><p>Suppose you have a container, what next? you could deploy it. But deploying a single instance will only cater to a limited number of end-users. What if you want to scale it to millions of users? What if your application fails? What if the system hosting the instance goes down?</p><p>One way is — do it manually. But that is not pragmatic. I’ll tell you why. Managing these container instances manually is arduous and time-taking. What’s the solution? You got it right! Kubernetes<strong> </strong>can do the heavy lifting for you. It helps us deploying a microservice-based application into a Kubernetes managed cluster which makes the containers highly available and scalable.</p><blockquote>Kubernetes is an open-source and resilient framework that automates the scaling, deployment, and operation of containers. All you need is a ready container and the rest can be taken care of by K8s.</blockquote><h4>Features</h4><ul><li><strong>Automatic rollbacks/recovery with no downtime</strong> — it progressively rolls out changes to your application or its configuration, while monitoring application health to ensure it doesn’t kill all your instances at the same time. If something goes wrong, Kubernetes will roll back the change for you[1].</li><li><strong>Scalability </strong>— automatic horizontal scaling based on CPU usage.</li><li><strong>Config Management/Secrets</strong> — Config Maps for setting up the environment variables command line arguments, Secrets let you store and manage sensitive information, such as passwords, OAuth tokens, and ssh keys.</li><li><strong>Self-Healing /Fault-Tolerance </strong>— Restarts containers that fail, replaces and reschedules containers when nodes die, kills containers that don’t respond</li></ul><h4>How does it work?</h4><p>Pods — Smallest unit of K8 cluster. A container resides on a pod. The pod itself resides in a node called the worker node. The workers take instruction from the master node. Master node tells how to run the application and what is required configurations with which we can maintain the status of the application.</p><h4>Kubernetes Architecture</h4><ul><li>Master Node</li><li>Worker Node</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/938/1*RhQTgY6cXosO6wikQi5csg.png" /><figcaption>Kubernetes Cluster[1]</figcaption></figure><h4>Master Node</h4><ul><li><strong>API Service</strong> — Main component and maintains desired state. This is the only component exposed to the outside world. Users can specify the desired state (how you want to run the application) using a YAML /JSON file. The file might contain details like how many replicas to make, the number of containers, etc.</li><li><strong>Scheduler </strong>— Schedules pods we need to run in the K8 cluster. Pods are volatile in nature i.e. they come to life — do their job and die. Whenever new pods come up, the scheduler maintains and ensures pods are assigned to a worker node.</li><li><strong>Controller </strong>— Controls operation and what happens in the worker node. Controls volume, health check of worker node. Ex- Bring up a new node/pod.</li><li><strong>Data Store </strong>— Key-value data store that stores data generated from K8 Cluster.</li></ul><h4>Worker Node</h4><p>a) <strong>kubelet </strong>— Agent that runs on a worker node and makes sure all pods within the node running and talks to API service. If you are familiar with the Linux ecosystem, this is basically a daemon.</p><p>b) <strong>kube proxy</strong> — maintains network-related rules e.g. - firewalls, expose to the external networks/outside world.</p><p>c) <strong>Container runtime</strong> — This could be a service container runtime like Docker, which provides an environment that ensures containers have everything they need to run.</p><p>d) <strong>Pods</strong> — The smallest unit in the K8 Cluster which basically contains one or more containers. Ideally, you should have one container per application but this depends on your requirement.</p><p>I hope this gives you a brief idea of how it works. That’s it from me! For further info, please see <a href="https://github.com/kubernetes/kubernetes">this</a>. 🎉</p><h3>Takeaway</h3><p>Kubernetes has revolutionized the software development 🚧 industry by making containerized applications highly available and scalable. Several conventional problems like networking can be dealt with by Kubernetes. It also supports data center outsourcing to different cloud service providers.</p><p>Kubernetes can take you to the clouds, literally! ☁️</p><h4>References</h4><p>[1] <a href="https://kubernetes.io/">https://kubernetes.io/</a></p><p>[2] <a href="https://www.vmware.com/topics/glossary/content/kubernetes">https://www.vmware.com/topics/glossary/content/kubernetes</a></p><p>If you are interested in learning more about containers, please see below.</p><p><a href="https://towardsdatascience.com/docker-101-all-you-wanted-to-know-about-docker-2dd0cb476f03">Docker 101: All you wanted to know about Docker</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c80cda99ccbb" width="1" height="1" alt=""><hr><p><a href="https://medium.com/geekculture/kubernetes-basics-in-under-5-mins-c80cda99ccbb">Kubernetes Basics in Under 5 Mins</a> was originally published in <a href="https://medium.com/geekculture">Geek Culture</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[End-to-end Low Code ML using PyCaret]]></title>
            <link>https://medium.com/coding-in-simple-english/end-to-end-low-code-ml-using-pycaret-8289c169479?source=rss-73ad232e2402------2</link>
            <guid isPermaLink="false">https://medium.com/p/8289c169479</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[fraud-detection]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Shashvat G]]></dc:creator>
            <pubDate>Fri, 11 Sep 2020 23:15:18 GMT</pubDate>
            <atom:updated>2020-10-03T14:15:22.465Z</atom:updated>
            <content:encoded><![CDATA[<h4>ML Prototyping Made Easy</h4><h4>One-Stop Solution for different ML Problems!</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*n_tzazqY74FjP_xl" /><figcaption>Photo by <a href="https://unsplash.com/@edwardhowellphotography?utm_source=medium&amp;utm_medium=referral">Edward Howell</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Have you ever wanted a simple and easy to use python library bundled in a single package that can handle an end-to-end Machine learning journey with a consistent syntax interface? If you are working on a PoC, PyCaret can be a handy tool as it provides a one-stop solution for a variety of problems. Be it removing multi-collinearity from your dataset or impute missing values, it has got your back.</p><p>PyCaret can significantly reduce the time and efforts required to build and train ML models and all this can be achieved in only a couple of function calls. It has some interesting built-in functionality for Feature engineering, Hyper Parameter Tuning, etc. It is also capable of comparing models, stack, and ensemble them based on your requirement. Furthermore, it can also be integrated with <a href="https://www.mlflow.org/docs/latest/index.html">ML Flow</a> to track and manage ML experiments. You can also use it to deploy on different cloud platforms like Azure or AWS. Usually, we have defined the machine learning pipeline that we follow in creating a model. PyCaret can do all these heavy liftings for you and it does all that under the hood.</p><p><strong>So, you would ask — What is PyCaret?</strong></p><p><a href="https://pycaret.org/"><em>PyCaret</em></a><em> is an open-source, low-code machine learning library in Python that does the heavy lifting for you right from data preparation to model deployment quickly by writing only a few lines of code.</em></p><p>PyCaret can be used for different machine learning projects ex- Classification, Regression, and Anomaly Detection. For instance, to create a decision tree model in PyCaret, only one line code is sufficient. You just need to be careful about passing the correct ID as a parameter.</p><pre>Model= create_model(‘dt’)</pre><p>This post intends to provide a step-by-step tutorial for implementing the classification problem in machine learning. Do check out the tutorials in the reference section for regression and anomaly detection using PyCaret.</p><h4>Pre-requisites</h4><ul><li>Python 3.x</li><li>The latest version of PyCaret</li><li>Some understanding of ML</li></ul><p>A quick overview of the problem and dataset:</p><ul><li>Dataset used: Pycaret in-built dataset</li><li>Problem Definition: To be able to detect Fraudulent transactions in credit cards.</li><li>Challenges: Imbalance Data</li><li>Target: Label 1/0 for Fraud/Not Fraud</li><li>ML Problem — Binay Classification</li><li>Dataset — 24000 rows, 24 columns</li></ul><h4>Installation</h4><p>We can simply install it with the python package manager. It is recommended to use virtual environments to avoid any version compatibility issues. Check <a href="https://pycaret.org/install/">this</a> out if you face any issues while installation.</p><pre>$ pip install pycaret==2.1 (Latest Version)</pre><p>Now that we have some background, Let’s dive straight in. We will follow these steps to build and train a classifier that can detect fraudulent transactions.</p><ol><li><strong>Read the Dataset</strong> — Similar to SKlearn, it has some in-built datasets that have been used here for demonstration.</li><li><strong>Initialize Set Up</strong> — It can infer Datatypes of the features in the dataset, check for missing values, impute missing values with mean or constant value depending upon continuous or categorical features.</li></ol><p>Fix imbalance argument can automatically fix the imbalanced dataset by oversampling using the SMOTE. We can also optionally pass the variables which we want to exclude in the ignore_features argument of the setup function.</p><p><strong>3. Compare Baseline / Create a Model </strong>— Returns the best model amongst the list of models (Try models() to see a list of models available).</p><p>By default, it returns results sorted based on Accuracy. create_model creates only a single model, hence takes less time as compared to compare models.</p><p><strong>4. Tune Hyperparameters</strong> — Tune model feature for Hyper Parameter Tuning.</p><p>For instance- you can specify the number of neighbors if building a K-NN Classifier. You can optionally optimize for your desired criteria.</p><p><strong>5. Finalize Model </strong>— Model finalization is the last step in the experiment.</p><p>The finalize_model() function fits the model onto the complete dataset including the hold-out sample.</p><p><strong>6. Analyze Model </strong>— plot_model() function can be used to analyze the performance through AUC, confusion_matrix, learning curve, etc. This function takes a trained model object and returns a plot.</p><p><strong>7. Save Model </strong>— PyCaret’s inbuilt function allows you to save the model along with the entire transformation pipeline for later use. You can also use it to load the saved model.</p><p>The entire experiment notebook is available <a href="https://github.com/ShashvatGuptaDS/PyCaret">here</a>. Feel free to fork and play around.</p><h4>Bonus</h4><p>If you want a pandas profiling report for the dataset, you can simply add an argument in the setup function `profile = True` and you’ll have a pandas profiling report at your disposal.</p><h3>Parting Thoughts</h3><p>PyCaret is a low-code ML library that can be used to quickly build and train a model end-to-end which can be super useful while working o a PoC. We can avoid importing dozens of python packages and all this can be achieved in only a couple of function calls. It also provides integration with MLFlow and deployment on Azure and AWS.</p><p>Some of the functionalities worth exploring are the Plot model feature that produces a nice visualization of Feature Importance and slightly advanced techniques like Stacking and ensemble feature methods to improve model performance. Here’s the <a href="https://towardsdatascience.com/announcing-pycaret-an-open-source-low-code-machine-learning-library-in-python-4a1f1aad8d46">blog</a> post that contains a nice and detailed explanation from the founder of PyCaret.</p><p>I’d love to hear your thoughts about PyCaret and Machine learning in the comments below!</p><h4>References:</h4><ul><li>Pycaret <a href="https://github.com/pycaret/pycaret/tree/master/tutorials">Tutorials</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8289c169479" width="1" height="1" alt=""><hr><p><a href="https://medium.com/coding-in-simple-english/end-to-end-low-code-ml-using-pycaret-8289c169479">End-to-end Low Code ML using PyCaret</a> was originally published in <a href="https://medium.com/coding-in-simple-english">Coding in Simple English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Is Studying Abroad Worth it?]]></title>
            <link>https://medium.com/@shashvat01/is-studying-abroad-worth-it-ae85c0fdf6bb?source=rss-73ad232e2402------2</link>
            <guid isPermaLink="false">https://medium.com/p/ae85c0fdf6bb</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[life-lessons]]></category>
            <category><![CDATA[university]]></category>
            <category><![CDATA[education]]></category>
            <category><![CDATA[life]]></category>
            <dc:creator><![CDATA[Shashvat G]]></dc:creator>
            <pubDate>Tue, 11 Aug 2020 22:36:08 GMT</pubDate>
            <atom:updated>2020-08-11T22:51:43.006Z</atom:updated>
            <content:encoded><![CDATA[<h4>MS in the UK</h4><h4>Lessons learned at Real-life Hogwarts aka UoG</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kwTzX3uu5QVbI1B0TWhERg.jpeg" /><figcaption>Image by Author</figcaption></figure><p>Are you a Harry Potter fan and want to study at real-life <strong>Hogwarts School of Witchcraft and Wizardry</strong>? Do you want to pursue higher education in the UK and not sure if it will be worth it? Are multiple offers from different Universities confusing you? Worry no more, you have landed at the right place! <strong>I’ve been there as well and I feel you. </strong>This post is dedicated to you — I have tried to answer questions that I have been asked most by different people on <a href="https://www.linkedin.com/in/shashvat-gupta/">LinkedIn</a>. The Q&amp;A below is in no particular order, so please feel free to skip any part not applicable to you.</p><h4>A little Background:</h4><p>I came to the UK in Septemeber 2018. I clearly remember the day I landed at Glasgow Airport, I struggled to understand the thick Scottish accent of my Uber driver. I had traveled out of my home country for the first time in life and I knew no one in the foreign land. I had mixed feelings — I was sad to leave my well-settled life back home and at the same time, I was also excited to see what future holds for me.</p><p>FF — Glasgow feels like Home now. There is something in the air that welcomes you with open arms and makes you feel at ease, almost like a home away from Home 🏠.</p><p>Enough said. Without any further delay, Let’s get started!</p><h4>Why Glasgow?</h4><p>I always wanted to board Harry Potter Express, grab a broom, and play quidditch with my classmates.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*QnqmPDS--A_waDuk" /><figcaption>Photo by <a href="https://unsplash.com/@woolyart?utm_source=medium&amp;utm_medium=referral">B K</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Haha, just kidding! :D</p><p>I fell in love the moment I saw the mesmerizing campus and its outstanding architecture. Apart from that, the Data Science module was very well-organized and best suited to my career aspirations. I found the faculty and the course structure to be quite impressive. And yeah, I also quite liked the city.</p><p>With a world rank of under 100, Glasgow is a great choice. I am also confident that the educative experience will help you move beyond your comfort zone, challenge your skills all the while contributing to your overall development.</p><h4>How’s your experience studying at the University Of Glasgow?</h4><p>Studying abroad is a dream for many students and it’s a completely different experience altogether. For me, I would say, pretty amazing. I had a great time learning from world-class faculties who were not only friendly and knowledgable but also always happy to help. The thing I loved the most was focus on practical learning.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*HBRi-wyD0uaBYpof" /><figcaption>Photo by <a href="https://unsplash.com/@art_maltsev?utm_source=medium&amp;utm_medium=referral">Artem Maltsev</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>I also made great friends from different parts of the world. Indeed, the clear advantage of studying in a multi-cultural environment. If you wish to work with people with diverse backgrounds, I think experiencing that beforehand in academia gives you an edge.</p><p>Additionally, if you are a travel freak — you can also travel around the UK(Scotland, England, Wales, NI) and the EU(Schengen Visa required for International students). I traveled to Belfast during Christmas and I loved it. A must-see place that should be in your bucket-list if you are a GoT fan!</p><h4>How’s the Job Market in the UK?</h4><p>Let’s be honest here. It’s not a cakewalk to get a job in the UK especially if you are an International Student but it’s not impossible either. You should mainly focus on employers who can sponsor a visa. While many employers do offer visa sponsorship, they are bound to prefer local candidates by law. I guess that’s fair to an extent.</p><p>The Job scenario is not so great at the moment due to the obvious global coronavirus outbreak but the good news is there is a recent surge in job listings across the UK. There is some uncertainty in the air due to Brexit but re-introduction of a 2-year Post-study work is certainly a boon. If you got the right skill, you will be hired. No doubt at that! The situation is much likely to improve in the coming years, so by the time you graduate, it should be much better. To sum it up, it’s your hard work and luck that will help you land a job in the UK.</p><h4>I have got multiple offers from different universities, Which one I should go for?</h4><p>I understand you. I was in the same boat two years ago. It can be a daunting task to select one University over another. I have a few leads that I considered before finalizing the University.</p><ul><li><strong>Research </strong>— This might be stating the obvious but it is crucial to do some research before concluding. List some pros and cons and compare them.</li><li><strong>Course Structure </strong>— I had a look at the course contents and figured out which one draws my interest most.</li><li><strong>Location</strong> — I wanted to live in Scotland so UoG was my first choice. Filtering your options based on location can be a good way to narrow down your choices.</li><li><strong>Fees </strong>— If I were you, I would see if it fits my budget &amp; cross options that do not fulfill my criteria.</li><li><strong>Recent Grads </strong>— I also reached out to recent graduates from the Uni and got their feedback about the course and their overall experience. This helped me a lot in making an informed decision.</li><li><strong>Part-time </strong>— If you wish to work part-time(Max 20 hours a week during term-time), you should consider taking a course that is not too demanding. I did Data Science, and it was crazy! While my friends from other schools were busy partying, we were busy working on assignments.</li></ul><p>I tend to think (and you are welcome to disagree ) — that universities do not matter much(unless you gonna study at Ivy League). At the end of the day, it’s your skill and talent that matters.</p><h4>Would you recommend coming to the UK for studies?</h4><p>Yes and no! I guess it depends on your expectations — what exactly you want to achieve and why do you want to pursue higher education in the UK in the first place.</p><p>It’s definitely a great experience and it will change your life for good but only consider coming if you want to. Ask yourself —</p><ul><li><strong>Why do I want to do it?</strong></li><li><strong>Am I ready to leave my current well-paid job to study?</strong></li></ul><p>If you can justify your stand, I don’t see it as an issue. Come here only if you want to study at a renowned university in a multi-cultural environment with a world-class education. The return of PSW in the UK is a welcome move and it provides a fair opportunity for International students to get a professional experience abroad without sweating too much about visa sponsorship. It would be value-adding to your resume. However, you should rather figure out what’s best for you instead of being a part of the rat race.</p><p>Lastly, If your main reason is to secure a job — I would seriously advise against it. There are high-paying jobs in almost any country and you just need to work hard and get into those jobs. Completing MS won’t award you a magic wand to get into high-paying jobs. Although it does help in getting a fair exposure, at the end of the day, it’s your perseverance that pays off.</p><h4>Will my previous experience be helpful?</h4><p>Well, it depends on what experience you have. If you have experience working as a Software Engineer and want to get into Data science- Yes, but if you worked as a Marketing Manager, not so much. You get the idea! Data Science is multi-disciplinary and if you know of any the fields it entails, it boosts your case, However, don’t be discouraged if you are completely new to this field. Everyone starts at some point and no one knows everything.</p><blockquote>Remember — The beginning is always the hardest.</blockquote><p>Based on my experience, I opine that core skills can be acquired but it’s your behavior that is critical for success. For instance — If your chosen field of study is highly dynamic, then you should be flexible enough to adapt to those changes quickly.</p><h4>How many years of experience is ideal? Would I be down-weighted if I have more experience?</h4><p>I can’t comment on that. Honestly, I don’t think I am qualified enough to answer that for you. I can only tell you this — if you have got the right skill set which is a match for the company, I don’t see a reason why this would be a problem. Companies only look for candidates who they believe can do the job and would be a culture fit. As long as you check those boxes, you should be fine.</p><h4>Okay, Final Question- Is it worth it?</h4><p>If your reason for studying abroad is in line with one or more of the below reasons(in no particular order), you might be on the right track.</p><ul><li>If you wish to alter your career path and explore other options.</li><li>If you are seeking an intellectually challenging environment.</li><li>If you want global exposure. (Really Important)</li><li>If you want to contribute to research.</li><li>If you wish to pursue an advanced degree in your field.</li></ul><h3>Parting Thoughts</h3><p>Studying abroad can be mentally stimulating and can change your perspective. Indeed, it is an experience of a lifetime and if you can afford it — go for it. Keep in mind, ROI does matter, and it’s completely sane to find out if it will value-adding for you but trust me experience matters more.</p><p>I’m happy to answer any questions you may have. Please feel free and let me know your thoughts on this one in the comments section below.</p><p>Thank you so much for your time :)</p><p>You can connect with me on <a href="https://www.linkedin.com/in/shashvat-gupta/">LinkedIn</a>, <a href="https://medium.com/@shashvat01">Medium</a>, <a href="https://twitter.com/shashvatam">Twitter</a>.</p><p>All the best! May you excel in whatever your heart desires😊</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ae85c0fdf6bb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[5 Important SQL Concepts for Your Next Data Science Interview]]></title>
            <link>https://medium.com/swlh/5-important-sql-concepts-for-your-next-data-science-interview-27e8bcf3d045?source=rss-73ad232e2402------2</link>
            <guid isPermaLink="false">https://medium.com/p/27e8bcf3d045</guid>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[database]]></category>
            <dc:creator><![CDATA[Shashvat G]]></dc:creator>
            <pubDate>Thu, 30 Jul 2020 23:30:24 GMT</pubDate>
            <atom:updated>2020-08-01T12:55:08.754Z</atom:updated>
            <content:encoded><![CDATA[<h4>SQL Questions for Data Jobs</h4><h4>SQL Interview Questions</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*mGdp67evv1O_k0RJ" /><figcaption>Photo by <a href="https://unsplash.com/@freetousesoundscom?utm_source=medium&amp;utm_medium=referral">Free To Use Sounds</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>SQL is everywhere. It is probably one of the most widely used languages today and also the primary language for retrieving data from databases. It came into existence after <em>E.F. Codd</em> laid the foundation of the modern relational database in his groundbreaking paper <a href="https://dl.acm.org/doi/10.1145/362384.362685"><em>A Relational Model of Data for Large Shared Data Banks</em></a><em>.</em></p><p>As a beginner, I was intimidated by different SQL( Structured Query Language) Flavors(Oracle SQL, MySQL, PostgreSQL) but I found out that the basic concept remains the same and they only differ in terms of syntax and implementation. However, In this post, we will use Oracle SQL for query and demonstration. Notably, NoSQL databases are popular nowadays as the majority of the data produced today is non-relational. Nevertheless, this does not mean SQL days are over. It’s not going anywhere. Not anytime soon. It is one of the skills most asked for in the Data job space.</p><p>Without wasting any more time, Let’s get started.</p><ol><li><strong>SQL Conditional Selects — WHERE/HAVING Clause</strong></li></ol><p>As the name suggests, it’s about fetching data that satisfies a given condition.</p><p>SQL has a <strong>WHERE</strong> clause that enables us to filter records that do not meet our desired criteria. We also have a <strong>HAVING</strong> clause to filter records.</p><p>Why do we have two separate clauses for filtering? Well, they are different. Let’s understand this using an example.</p><p>Can you guess what’s going on in this query:</p><pre><strong>SELECT</strong></pre><pre>empno, ename, AVG(sal)</pre><pre><strong>FROM</strong></pre><pre>salary</pre><pre><strong>WHERE</strong></pre><pre>deptno NOT IN (10,20,30)</pre><pre><strong>GROUP</strong> <strong>BY</strong> empno, ename</pre><pre><strong>HAVING</strong> AVG(sal) &gt;= 10000</pre><pre><strong>ORDER</strong> <strong>BY</strong> empno <strong>DESC</strong>;</pre><p>We are only fetching employee number, employee name, and their average salaries from the Salary table for employees who are not in department 10, 20 or 30, and whose average salary is greater than or equal to 10000 in decreasing order of employee number.</p><p>You probably get a clear picture now. SQL WHERE Clause filters out records before any grouping happens, on the other hand, the HAVING clause works on the grouped data and removes records that do not meet the filter criteria.</p><p>HAVING cannot be used as a replacement of WHERE clause, it’s only there as a supplement, at times you would not need where clause at all, and only a having clause would suffice. For instance, in the above example, if we had to select all departments, we can simply get rid of where clause and the query would be</p><pre><strong>SELECT</strong></pre><pre>empno, ename, AVG(sal)</pre><pre><strong>FROM</strong></pre><pre>salary</pre><pre><strong>GROUP</strong> <strong>BY</strong> empno, ename</pre><pre><strong>HAVING</strong> AVG(sal) &gt;= 10000</pre><pre><strong>ORDER</strong> <strong>BY</strong> empno <strong>DESC</strong>;</pre><p>2. <strong>Removing Duplicates in SQL</strong></p><p>Let’s say, you are working with a Student database and the database has a table called Student which is something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/890/1*dwPih1-7Y8i3axG4R3Jsuw.png" /><figcaption>Image By Author</figcaption></figure><p>Now, The Student table has a duplicate record<strong> </strong>for SID 20. How do you delete the duplicate record?</p><p>Well, there are different ways to do it. One of them would be to identify and delete duplicates using <strong>ROWID</strong>.</p><p>ROWID is a unique identifier for each row stored in the database. It consists of the data block address in the data file in which the particular row resides. It is probably the fastest way to locate a row and yes, it is faster than the primary key lookup.</p><p>We can write a query something like this:</p><pre>DELETE FROM STUDENT WHERE rowid NOT IN (SELECT MAX(rowid) FROM STUDENT GROUP By SID);</pre><p>What’s happening here? Firstly, we are fetching the max of rowid split by Student IDs and then only keeping the next highest rowid. Please note that you can also use greater than (&gt;) or less than(&lt;) operator instead of NOT IN depending upon the requirement.</p><p>Another way to delete duplicates can be using a count function based on SID. We can simply find records that have a count greater than 1 split by their marks and subject.</p><pre>DELETE FROM STUDENT WHERE SID IN (SELECT SID FROM STUDENT GROUP BY Subject, Marks HAVING COUNT(*) &gt; 1));</pre><p>If you just want to see the list of Student id which are duplicate, you can try this one:</p><pre>SELECT SID<br>FROM (<br> SELECT SID,COUNT(SID) As count<br> FROM STUDENT<br> GROUP BY SID<br>) As sid_count<br>WHERE count &gt; 1</pre><p>The above query uses inline views which is nothing but a <a href="https://www.oracletutorial.com/oracle-basics/oracle-subquery/">subquery</a> in the FROM clause of a <a href="https://www.oracletutorial.com/oracle-basics/oracle-select/">SELECT</a> statement and selecting student ids that occur more than once in the student table.</p><p>3.<strong> SQL CASE</strong></p><p>SQL CASE is essentially the EXCEL equivalent of IF-THEN logic. Let’s understand it with an example -</p><p>Suppose you are working for a hotel management company and you have a table Rooms that contain room id, room type, and charges per night. You want to categorize items into three classes — Standard(up to 2000), Deluxe(2000–4000), and Luxury(more than 4000 ) based on charges and return NA if the price is null sorted in descending order of type.</p><p>The query can be written as:</p><pre><strong>SELECT</strong> room_type, room_price, <br><strong>CASE</strong> <br><strong>WHEN</strong> room_price &gt; 0 <strong>AND</strong> room_price &lt; 2000 <strong>THEN</strong> ‘Standard’ <br><strong>WHEN</strong> room_price &gt;= 2000 <strong>AND</strong> room_price &lt;= 4000 <strong>THEN</strong> ‘Deluxe’<br><strong>WHEN</strong> room_price &gt; 4000 <strong>THEN</strong> ‘Luxury’<br><strong>ELSE</strong> ‘NA’ <br><strong>END</strong> room_category <br><strong>FROM</strong> Rooms<br><strong>ORDER BY</strong> room_type <strong>DESC</strong> ;</pre><p><strong>Note:</strong> If you wish to create a pivot table in SQL, one way to do it is by using a combination of CASE and Aggregate functions like COUNT.</p><p>4. <strong>SQL Window Functions</strong></p><p>SQL window function performs a calculation across a set of table rows that are somehow related to the current row. This is achieved using an aggregate function but it doesn’t return single output aggregated over a set of rows.</p><p>You have an employee table with columns — employee and their respective salary. How do you find the Nth highest salary?</p><p>SQL Window function can be used to achieve that.</p><pre><strong>SELECT</strong> * <br><strong>FROM<br></strong>(<br><strong>SELECT</strong> ENAME, SAL, dense_rank() <br>OVER(ORDER BY sal desc) as rank <br><strong>FROM</strong><br>Employee<br>)<br><strong>WHERE</strong> <br>rank = &amp;N;</pre><p>You can enter your desired N and it should return the Nth highest salary. Notably, the above query uses dense rank, you can also get the desired result with rank.</p><p>Maybe, Try replacing dense rank with rank and find out the difference between them?</p><p>You can read more on the <a href="https://mode.com/sql-tutorial/sql-window-functions/">Window functions </a>here.</p><p>5. <strong>SQL</strong> <strong>Joins</strong></p><p><a href="https://www.tutorialspoint.com/sql/sql-using-joins.htm">Joins</a> come into the picture when you need to get data from multiple tables and combine them, may be based on a certain condition or some common column. There are several types of joins available — INNER, OUTER(LEFT, RIGHT), SELF JOIN.</p><p>For instance, Let’s say you work for an e-commerce company and you have two different tables for the order management- orders table and product table.</p><p>Order and Customers tables have below structure:</p><pre>********************Orders***************</pre><pre>| Order_ID |  ORDER_DATE     | CUSTOMER_ID|</pre><pre>********************************************</pre><pre>|       1 |       2017-04-03 |          10 |</pre><pre>|       2 |       2016-01-22 |          20 |</pre><pre>|       3 |       2020-06-23 |          30 |</pre><pre>|       4 |       2019-01-07 |          40 |</pre><pre>********************************************</pre><pre>*******************Customers****************</pre><pre>| CUSTOMER_ID|  CUSTOMER_NAME     | COUNTRY|</pre><pre>********************************************</pre><pre>|       10 |      DOMINIC B |          UK |</pre><pre>|       30|       PRAGYA C  |          IN |</pre><pre>|       40|       JACK D    |          FR |</pre><pre>|       50|       KRISHNA M |          IT |</pre><pre>********************************************</pre><p>How do you get a list of customer names and their respective order dates?</p><p>Joins can help you here.</p><pre><strong>SELECT</strong> cust.CUSTOMER_NAME, ord.ORDER_DATE<br><strong>FROM</strong> <br>Orders ord<br><strong>INNER JOIN</strong> <br>Customers cust <br><strong>ON</strong> <br>ord.CUSTOMER_ID=cust.CUSTOMER_ID;</pre><p>If you want to practice further, here’s a common question asked in SQL interviews —</p><p>How do you find a list of employees and their managers if given an employee table? Make necessary assumptions.</p><p><em>Hint: Use Self Joins</em></p><h3>Bonus Section</h3><ul><li><strong>SELECT DISTINCT Statement</strong></li></ul><p>The SELECT DISTINCT statement can be useful when you want to return unique values ignoring duplicates.</p><ul><li><a href="https://www.w3schools.com/sql/sql_union.asp"><strong>UNION and UNION ALL</strong></a></li></ul><p>UNION is a set operator in SQL and is used to combine result sets of two queries given they have the same number of columns, similar datatype, and in the same order.</p><p>UNION ALL is essentially the same as UNION except it includes duplicates, unlike UNION.</p><ul><li><a href="https://www.w3schools.com/sql/sql_count_avg_sum.asp"><strong>SQL Aggregate Functions</strong></a></li></ul><p>These functions aggregate over a column and return a single value.</p><p>Ex — AVG(), COUNT(), MAX(), MIN() and SUM(). They can also be used to gather basic statistics.</p><h3>Conclusion</h3><p>SQL is quite popular and often a common requirement in Data jobs — be it Data scientist or Analyst. In this post, we covered some important SQL concepts that should help you prepare for your next interview.</p><p>Clearly, there is more to SQL and hopefully, we will cover more in the next posts. Stay Tuned 😊</p><p>Happy to hear your thoughts on this one!</p><p>If you found this useful and know anyone you think would benefit from this, please feel free to send it their way.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=27e8bcf3d045" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/5-important-sql-concepts-for-your-next-data-science-interview-27e8bcf3d045">5 Important SQL Concepts for Your Next Data Science Interview</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Explainable AI: Interpretability of Machine Learning Models]]></title>
            <link>https://medium.com/data-science/explainable-ai-interpretability-of-machine-learning-models-412840d58f40?source=rss-73ad232e2402------2</link>
            <guid isPermaLink="false">https://medium.com/p/412840d58f40</guid>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[explainable-ai]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Shashvat G]]></dc:creator>
            <pubDate>Sat, 25 Jul 2020 12:07:15 GMT</pubDate>
            <atom:updated>2020-07-26T11:13:06.834Z</atom:updated>
            <content:encoded><![CDATA[<h4>Model Explainability using LIME</h4><h4>Can you trust your Machine learning model?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*QJ2J4U7slCLLY9Y5" /><figcaption>Photo by <a href="https://unsplash.com/@askkell?utm_source=medium&amp;utm_medium=referral">Andy Kelly</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Why should we trust a machine learning model blindly? Wouldn’t it be wonderful if we can get a better insight into model predictions and improve our decision making? With the advent of explainable AI techniques such as LIME and SHAP, it is no longer a challenge. Nowadays, machine learning models are ubiquitous and becoming a part of our lives more than ever. These models are usually a black box in essence that it’s hard for us to assess the model behavior. From smart speakers with inbuilt conversational agents to personalized recommendation systems, we use them daily, but do we understand why they behave in a certain way? Given their ability to influence our decision, it is of paramount and supreme importance that we should be able to trust them. Explainable AI systems help us understand the inner workings of such models.</p><p><strong>So, What’s Explainable AI?</strong></p><p>Explainable AI can be summed up as a process to understand the predictions of an ML model. The central idea is to make the model as interpretable as possible which will essentially help in testing its reliability and causality of features. Broadly speaking, there are two dimensions to interpretability:</p><ol><li>Explainability(Why did it do that?)</li><li>Transparency(How it works?)</li></ol><p>Typically, explainable AI systems provide an assessment of model input features and identify the features which are driving force of the model. It gives us a sense of control, as we can then decide if we can rely on the predictions of these models. For instance, we would probably trust a flu identification model more if it considers features like temperature, and cough more significant than other symptoms.</p><p><strong><em>Now that you have an idea of explainable systems, how do we explain model predictions?</em></strong></p><p>There are different ways to do that. LIME is one of them. Let’s squeeze it.</p><blockquote>LIME stands for:<br><strong>L</strong>ocal: Approximate locally in the neighborhood of prediction being explained,<br><strong>I</strong>nterpretable: Explanations produced are human-readable,<br><strong>M</strong>odel-Agnostic: Works for any model like SVM, Neural networks, etc <strong>E</strong>xplanations: Provides explanations of model predictions.(Local linear explanation of model behaviour)</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*P8WnSf33zTfozPkT" /><figcaption>Photo by <a href="https://unsplash.com/@ninjason?utm_source=medium&amp;utm_medium=referral">Jason Leung</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Lime can be used to get more insights into model prediction like explaining why models take a particular decision for an individual observation. It can also be quite useful while selecting between different models. The central idea behind Lime is that it explains locally in the vicinity of the instance being explained by perturbating the different features rather than producing explanations at the entire model level. It does so by fitting a sparse model on the locally dispersed, noise-induced dataset. This helps convert a non-linear problem into a linear one. The indicator variables with the largest coefficients in the model are then returned as the drivers of the score.</p><h4>Installation</h4><p>You can simply pip install it or can clone the Github <a href="https://github.com/marcotcr/lime">repo</a>:</p><pre>pip install lime</pre><pre>pip install . (Git version)</pre><h4>Implementation</h4><p>We will use Lime for explaining predictions of a random forest regressor model on the Diabetes dataset which is inbuilt in sci-kit learn. This post assumes that you already have some knowledge of Python, and Machine Learning. For the sake of simplicity, we will not cover all steps we usually follow in the model building pipeline like visualization and pre-processing. For the model building bit, You can clone the repo <a href="https://github.com/ShashvatGuptaDS/ExplainableAI">here</a>.</p><p>So, let’s cut to the chase and see how can we explain a certain instance using Lime.</p><p>Understanding Model Behavior in predictions with Lime mainly comprises of two steps:</p><ul><li><strong>Initialize an explainer</strong></li><li><strong>Call <em>explain_instance</em></strong></li></ul><p>The first step in explaining the model prediction is to create an explainer. We can use Lime Tabular explainer, which is the main explainer used for tabular data. Lime scales and generates new data using locality and computes statistics like mean for numerical data and frequency for categorical data, due to this we need to pass our training data as a parameter.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e882e0dd1a3fcad34955f07e3f8faa37/href">https://medium.com/media/e882e0dd1a3fcad34955f07e3f8faa37/href</a></iframe><p>In the second step, we simply need to call explain_instance for the instance in which you need explanation<em>s. </em>You can use a different ‘<em>i’ </em>if you wish to understand a different instance.</p><p>Finally, we can use the explainer to display the explanation for a particular prediction in the Jupyter Notebook.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YdmHS1yD_G-w0IlZgyTpDA.png" /><figcaption>Lime output explaining the Instance (Image by Author)</figcaption></figure><p>As we make our model complex, its interpretability decreases and vice-versa. A word of advice would be to take care of the trade-off between model complexity and its interpretability.</p><p>You can optionally save your explanations as HTML file which makes it easier to share.</p><pre>exp.save_to_file(“explanation.html”)</pre><h4>Alternatives</h4><ul><li>Eli5 — Another Library for Model Explainability. I have used it for textual data and it works fine. You can read more on Eli5 <a href="https://eli5.readthedocs.io/en/latest/tutorials/">here</a>.</li><li>SHAP — Shapley Additive Explanations as the name suggests tells you how it got the score for an instance in an additive manner. SHAP has not only a generic explainer that works for any model but also a TreeExplainer for tree-based models. It theoretically guarantees consistency and is slower than Lime. Additionally, the computational requirements of exploring all possible feature combinations grow exponentially in SHAP.</li></ul><h3>Conclusion</h3><p>Lime provides human-readable explanations and is a quick way to analyze the contribution of each feature and hence helps to gain a better insight into a Machine Learning model behavior. Once we understand, why the model predicted in a certain way, we can build trust with the model which is critical for interaction with machine learning. In this post, we used a Random Forest regression model to interpret its prediction on a particular instance.</p><p>Interestingly, Lime also supports an explainer for images, textual data, and classification problems. You can explore Lime explanations further in more complex models such as Xgboost &amp; LightGBM and compare predictions. Read more on Lime <a href="https://arxiv.org/pdf/1602.04938.pdf">here</a>. Also, here’s an interesting <a href="https://analyticsindiamag.com/8-explainable-ai-frameworks-driving-a-new-paradigm-for-transparency-in-ai/">read</a> on different tools for transparency and explainability in AI.</p><p>I’d love to hear your thoughts about Lime, Machine learning, and Explainable AI in the comments below. If you found this useful and know anyone you think would benefit from this, please feel free to send it their way.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=412840d58f40" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/explainable-ai-interpretability-of-machine-learning-models-412840d58f40">Explainable AI: Interpretability of Machine Learning Models</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[Parallel Processing in Python Using DASK]]></title>
            <link>https://medium.com/swlh/parallel-processing-in-python-using-dask-a9a01739902a?source=rss-73ad232e2402------2</link>
            <guid isPermaLink="false">https://medium.com/p/a9a01739902a</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[parallel-computing]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Shashvat G]]></dc:creator>
            <pubDate>Sat, 18 Jul 2020 10:26:49 GMT</pubDate>
            <atom:updated>2020-07-20T12:27:13.885Z</atom:updated>
            <content:encoded><![CDATA[<h4>Distributed computing for Advanced Analytics</h4><h4>Scale-up Pandas, Numpy and Sci-kit learn natively</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/868/1*tiPvLsPnd3vKuZTwywofrA.png" /><figcaption>Image Source: <a href="http://dask.org/">Dask</a></figcaption></figure><blockquote>“Data is the new science. Big Data holds the answers.” — By Pat Gelsinger</blockquote><p>Big Data does hold the answer. The more data we have, the more possibilities of gaining business value out of it. However, gathering data is not the only challenge, we also need to consider data storage and processing. As a Data Scientist, we often use tools like Pandas and Numpy to analyze data since these are widely trusted and efficient. However, as the size of the dataset increases, we start facing the actual limitations of these tools. What do we do next? We switch to a more scalable solution such as Spark and at times, this rework is time-consuming. Wouldn’t it be wonderful if you could do it in your system locally or scale-up to a cluster on a need basis? Dask can help you achieve that.</p><p>This post assumes that you already have some knowledge of Python Pandas and NumPy. To give you an overview, Pandas is super useful for data cleaning, analysis for smaller data, and Numpy is mainly used for working with a high-performance multidimensional array. That being said, let’s dive right into Dask.</p><h4>So, what is Dask?</h4><p>Dask is a parallel computation framework that has seamless integration with your Jupyter notebook. Originally, it was built to overcome the storage limitations of a single machine and extend the computation capability of Pandas, Numpy, and Scit-kit Learn with DASK equivalents, but soon it found its use as a generic distributed system.</p><blockquote>If you are familiar with Pandas and NumPy, you are good to go with Dask Dataframe and arrays.</blockquote><p>Dask has two main virtues:</p><ol><li><strong>Scalability</strong></li></ol><p>Dask scales up Pandas, Scikit-Learn, and Numpy natively with python and Runs resiliently on clusters with multiple cores or can also be scaled down to a single machine.</p><p>2. <strong>Scheduling</strong></p><p>Dask Task Schedulers are optimized for computation much like Airflow, Luigi. It provides rapid feedback, tracks tasks using Task graphs, and aids in diagnostics both in local and distributed mode aking it interactive and responsive.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0OaznYUVfHwDJacwqfSBFg.png" /><figcaption>Image Source: <a href="https://docs.dask.org/en/latest/">Dask</a></figcaption></figure><p>Dask also provides a <a href="https://docs.dask.org/en/latest/understanding-performance.html">real-time and responsive dashboard</a> that shows several metrics like progress, memory use, etc. which is updated every 100ms.</p><h3>Installation</h3><p>Dask can be installed with Conda/pip or cloned from the git <a href="https://github.com/dask/dask">repo</a>, depending on your preference.</p><pre>conda install dask</pre><pre>conda install dask-core (Only installs core)</pre><p>Dask-core is a mini dask installation that will only install core packages. The same applies to pip. You can also install only the dask data frame, or Dask array if you are only concerned with scaling up your pandas, Numpy with Dask Dataframe, Dask arrays respectively.</p><pre>python -m pip install dask<br>python -m pip install &quot;dask[dataframe]&quot;   <em># Install requirements for dask dataframe<br></em>python -m pip install &quot;dask[array]&quot;       <em># Install requirements for dask array</em></pre><h4>Dask DataFrames Vs Pandas DataFrame</h4><p>You should refrain from using Dask if Pandas is working just fine for you. Keeping that in mind, here is a demonstration for importing an example CSV file in pandas and Dask using Jupyter notebook :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/572/1*hXYGJ1woNZs7mJn4JnUNMQ.png" /><figcaption>Pandas</figcaption></figure><p>Dask does Lazy computing much like Spark, which essentially means it does not perform the job until action is requested, Dask stays ideal in terms of computation until the compute method(in this case) is invoked.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/477/1*CaQItdnrD8rI9Pe_7j13rw.png" /><figcaption>Dask Dataframe</figcaption></figure><h4>Dask ML</h4><p>The Dask equivalent of Scikit-Learn is <a href="https://ml.dask.org/">Dask-ML</a>. Here is how we can use XGBoost Regressor(a popular Gradient Boosting algorithm for regression) in Dask:</p><pre><strong>from</strong> <strong>dask_ml.xgboost</strong> <strong>import</strong> XGBRegressor</pre><pre>model = XGBRegressor(...)<br>model.fit(train, train_labels)</pre><h4>Dask Vs Spark</h4><p>Spark is a resilient cluster computing framework tool that splits data and processing into small chunks, distributes it across a cluster of any size, and runs them in a parallel manner.</p><p>Although Spark is a universal go-to tool for Big data analysis, yet Dask seems quite promising. Dask is written as a python component and is lightweight but on the other hand, Spark offers more functionality, is written in Scala, and also offers support for Python/R. Spark should be your first choice if you are looking for an all-inclusive solution or have JVM infrastructure, but if you want to experience parallel computation swiftly which is lightweight, Dask is worth giving a try. With a simple pip install, it will be at your disposal.</p><h3>Conclusion</h3><p>Dask is a fault-tolerant, elastic framework for parallel computation in python that can be deployed locally, on the cloud, or high-performance computers. Not only it scales out capabilities of Pandas and NumPy, but also it can be used as Task schedulers. It is worth mentioning that Dask is not meant as a replacement for Pandas and NumPy since it does not provide the complete functionality as prior. You can read more on Dask <a href="https://docs.dask.org/en/latest/">here</a>.</p><p>I’d love to hear your thoughts about Dask, Machine learning, and Distributed Computing in the comments below.</p><p>If you found this useful and know anyone you think would benefit from this, please feel free to send it their way.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a9a01739902a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/parallel-processing-in-python-using-dask-a9a01739902a">Parallel Processing in Python Using DASK</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introduction to AutoML: Using H2O Flow]]></title>
            <link>https://medium.com/swlh/introduction-to-automl-using-h2o-flow-15f257707021?source=rss-73ad232e2402------2</link>
            <guid isPermaLink="false">https://medium.com/p/15f257707021</guid>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[h2o]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[automl]]></category>
            <dc:creator><![CDATA[Shashvat G]]></dc:creator>
            <pubDate>Sat, 11 Jul 2020 10:41:57 GMT</pubDate>
            <atom:updated>2020-07-12T22:55:19.040Z</atom:updated>
            <content:encoded><![CDATA[<h4>H2o Flow: H2o.ai</h4><h4>Build a Machine learning model without writing a single line of code</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ObFxlJrEKijo3mZf" /><figcaption>Photo by <a href="https://unsplash.com/@marvelous?utm_source=medium&amp;utm_medium=referral">Marvin Meyer</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Have you ever wanted to play around with Machine learning? Wish you could build a machine learning model without having to write any code? Lack of programming experience is stopping you? Happy Days are here — H2o.ai has a solution for you, it’s called <em>H2o Flow</em>.</p><p>It is widely known that the field of Data Science is highly dynamic and there is something new in DS stack every day. The advent of AutoML is certainly a commendable push to this stack. Not only it enables people with zero programming background to create and build an ML model but also it makes the life of Data scientists much easier.</p><p><strong>So, What is AutoML?</strong></p><p>Well, AutoML is here to stay, an abbreviation for Automated Machine learning that aims to automate training and building of machine learning models. AutoML ensures machine learning is available even to people with no particular background in programming.</p><p>Gone are the days when Data scientists needed to build a baseline model from scratch(<em>depending upon the use case, Of course!</em>). Enter AutoML, just a few clicks, and your baseline is ready.</p><blockquote>H2O is licensed under the <a href="https://github.com/h2oai/h2o-3/blob/master/LICENSE">Apache License, Version 2.0</a> and has a Web User interface called H2o <a href="http://docs.h2o.ai/h2o/latest-stable/h2o-docs/flow.html#using-flows"><strong>Flow</strong></a><strong>.</strong></blockquote><p>Basically, H2o Flow is a web-based interactive tool that allows data selection from various sources, visualization, a seamless environment for model building, prediction, evaluating, and exporting your model. In my opinion, H2o’s core strength is it’s distributed in-memory processing.</p><blockquote>H2O is written in Java and it supports algorithms used frequently in Data science, For instance, <a href="https://en.wikipedia.org/wiki/Gradient_boosting">GBM</a>, <a href="https://en.wikipedia.org/wiki/Random_forest">Random Forest</a>, and <a href="https://en.wikipedia.org/wiki/Ensemble_learning">Stacked Ensembles</a>. H2O works with R, Python, Scala on Hadoop/Yarn, Spark, or your laptop.</blockquote><h3>Installation</h3><p>You can get H2o <a href="http://h2o-release.s3.amazonaws.com/h2o/latest_stable.html">here</a>. You would probably need Java installed in your system for H2o Flow to work. Also, if you have python installed on your system, you can simply install this package with a conda install. see below :</p><pre>conda install -c h2oai h2o</pre><p>You can safely ignore the above step if you gonna use H2o Flow. Notably, H2o is also available for R, and Hadoop. Downloading H2o will replicate a zip file on your system and that contains everything you need to get started.</p><p>Head to your terminal, unzip, and start H2o. Here are the commands that might be helpful:</p><pre>cd ~/Downloads </pre><pre>unzip h2o-3.30.0.6.zip </pre><pre>cd h2o-3.30.0.6 </pre><pre>java -jar h2o.jar</pre><p>Go to your browser and open <a href="http://localhost:54321/">H2o</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b8a0_yiaG0lc5aY7zn20xg.png" /><figcaption>H2O Flow Home Page</figcaption></figure><p>In this post, we’ll not discuss the menu icons and bar at the top as these are fairly self-explanatory. You can always check the help section available on the right.</p><p>We will use USA housing Dataset which is available <a href="https://github.com/ShashvatGuptaDS/H2o-Flow">here</a> to build a simple regression model that can predict house prices based on given features such as Area Population, Average Area Income. We will follow these steps in order to build a model:</p><ul><li>Import Files</li><li>Split Frame</li><li>Build Model</li><li>Prediction</li></ul><p>Please note that there are other steps in Machine learning Pipeline like EDA(Exploratory Data Analysis), Pre-processing, etc. which are not covered in this tutorial.</p><p>Let’s get right to the routines that will help you build a simple regression model.</p><h4><strong>1. Import Files</strong></h4><p>This is where you can define your data source, parse your input file, and define parser as CSV, AUTO, XLSX, or even parquet files(source file format for Hadoop which is efficient in terms of storage and performance).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z76S025WWN7782flUSCbPQ.png" /><figcaption>Import files into H2o</figcaption></figure><p>Set up your parser as required, see below for reference.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p63gXEec7SUs90raVWJz2g.png" /><figcaption>Parser set up</figcaption></figure><p>Once it is loaded into H2o, you should be able to view a nice summary of columns in your dataset, the number of columns, rows, and even missing values.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bmUSrjnmSy4_xj13jdJD6A.png" /><figcaption>Loaded Data</figcaption></figure><p>H2o also allows you to impute values for missing fields for example with the mean value. Simply, Click on the column labels, this will take you to that particular column details where you can perform actions such as Impute and Inspect. Inspect the values for generating plots such as distribution plots and line charts.</p><h4><strong>2. Split Frame</strong></h4><p>Basically, It is dividing your dataset into training and testing. If you have some background in Machine learning, you must be aware that we divide the data into train and test for optimal fit of the model. Essentially, we don’t want the model to simply cram the input data, and as a result, perform poorly on unseen data. You can specify train and test ratio, names for your training set, the test set, and set seed so that the same random set of rows is generated every time(Leave it as it is if you are not sure).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/950/1*M-uqWmHtNhzO3pLc1DOIsg.png" /><figcaption>Split train and test data</figcaption></figure><h4><strong>3. Build Model</strong></h4><p>We should select the model we want to build in this step. The available options include Deep Learning, Gradient Boosting Machine, and GLM (Generalised Linear Modeling) to name a few.</p><p>Since our problem here is to predict house prices on the basis of the given set of features, we will select the GLM model, set model parameters, columns to consider in training the model, and most importantly, our target variable i.e Price. We should also set a training frame as a train and validation frame as a test as we created in the above step. Optionally, cross-validation can also be done as required.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*llDHxG9GcuFVn2viq8dSrw.png" /><figcaption>Model building</figcaption></figure><p>It is important to note that there are several advanced options for building a model if you are not sure what should be selected, you can safely skip that part, scroll to the bottom and hit Build model. Once you do it, your model should be ready.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9dZF2qWGABRzRbonQ8Cs4A.png" /><figcaption>Trained GLM Model</figcaption></figure><p>We can download the model, export it for further integration with other systems or applications, or continue using H2o Flow to make predictions. H2o also allows us to download it as Plain Java Object file <strong>POJOs</strong> which are used for increasing the readability and re-usability of a program, or Maven compatible format(<strong>MoJo</strong>).</p><h4><strong>4. Predict</strong></h4><p>In the previous step, we basically built and trained the model based on certain features such as the Average area, number of bedrooms etc. Now, our final step is to make predictions based on our trained model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/899/1*wFSobmv_abrrm4SMMFiglw.png" /><figcaption>Predict on Test Data</figcaption></figure><p>As soon as you hit predict, it comes up with a list of predictions on the test frame we created in the second step. Note that the below list is not exhaustive. Here are some of the predictions:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1011/1*CWrFLsxWrj5dGaJoGiU-Mg.png" /><figcaption>Predictions</figcaption></figure><p>Evaluating machine learning models is a significant part of the ML pipeline. The evaluation criteria vary and depends on several factors depending upon the business requirement or the use case. In Regression, common evaluation criteria are Mean Absolute Error(MAE), Root mean squared error(RMSE), or R2 Score. H2o has all of these built-in and it displays them once you click action to inspect predictions.</p><h3>Conclusion</h3><p>In this post, we used H2o Flow to create a very simple regression model to predict house prices based on the USA housing data set. We didn’t write a single line of code in this exercise to predict house prices. Clearly, there is much more to regression and H2o flow than we have covered here and you can explore more on H2o Flow and Machine learning as you dive in further. Stacked Ensembles, GBMs on H2o Flow are definitely worth a try.</p><p>I’d love to hear your thoughts about H2o, Machine learning, and Data Science in the comments below.</p><p>If you found this useful and know anyone you think would benefit from this, please feel free to send it their way.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=15f257707021" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/introduction-to-automl-using-h2o-flow-15f257707021">Introduction to AutoML: Using H2O Flow</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Streamlit — Quickly Build a Web App Using Python]]></title>
            <link>https://medium.com/swlh/streamlit-quickly-build-a-web-app-using-python-1afe3db4d552?source=rss-73ad232e2402------2</link>
            <guid isPermaLink="false">https://medium.com/p/1afe3db4d552</guid>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[web-app-development]]></category>
            <category><![CDATA[streamlit]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Shashvat G]]></dc:creator>
            <pubDate>Thu, 02 Jul 2020 22:52:57 GMT</pubDate>
            <atom:updated>2020-07-05T01:01:51.127Z</atom:updated>
            <content:encoded><![CDATA[<h4>Develop an interactive web app — Streamlit 101</h4><h3>Streamlit — Quickly Build a Web App Using Python</h3><h4>A quick and easy way to develop a web application for your machine learning models.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/311/1*EgMXOwmmjoEgZ2vGw0wjpQ.png" /></figure><p>Fancy building an interactive web app? Don’t want to write HTML/CSS scripts? Wish you could write a few lines of python code to build an app and showcase your app to stakeholders gracefully. Worry, no more, Here is a solution — Streamlit.</p><p>Streamlit is a super useful tool to develop an interactive web application in a couple of function calls written in python. It lets you create apps for your machine learning models using fairly simple python code. If you can write scripts in python, you can quickly embrace streamlit by getting acquainted with a couple of streamlit functions. It’s really that simple!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*p_3qL4a3hpx8Cd4U" /><figcaption>Photo by <a href="https://unsplash.com/@hishahadat?utm_source=medium&amp;utm_medium=referral">Shahadat Rahman</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><blockquote>One of the major plus points I have witnessed in Streamlit is its hot-reloading feature. You can see changes in the app as you write and save your python file.</blockquote><h3>Installation</h3><p>Alright, the pre-requisites for this is you already have python 3.6 or later running on your system. You can simply pip install using below command:</p><pre>pip install streamlit</pre><p>I would install streamlit in a separate virtual environment to avoid any version compatibility issues with other applications.</p><p>Once you have it up and running, you can try below command:</p><pre>Conda activate streamlit</pre><pre>streamlit hello</pre><p>If it displays Local and Network URLs and then redirects you to your web browser, you have successfully installed streamlit in your system and you are ready to develop your first application.</p><h3>Developing your First Streamlit App</h3><p>Let’s develop a simple web app that reads and visualize a pandas data frame.</p><p><strong>Step 1:</strong> Open your preferred IDE and start by importing python libraries.</p><pre>import streamlit as st<br>import pandas as pd<br>import numpy as np<br>st.title(‘Yelp Reviews’)<br>df = pd.read_csv(“yelp.csv”)<br>if st.checkbox(‘Show dataframe’):<br> st.write(df)</pre><p><strong>Step 2: </strong>Set your application title by using St.title (Given you imported streamlit as st)</p><p><strong>Step 3: </strong>Use pandas to read your CSV file — change name according to your requirement.</p><p><strong>Step 4:</strong> Now, let’s utilize a checkbox for hiding and showing a specific section as you check/uncheck.</p><p><strong>Step 5:</strong> St.write is a magic command which can be exploited to display markdowns, texts, or even data frames on the web app.</p><p>Now that you have a script, save it as <em>hello_streamlit.py</em> Next step is to run your streamlit app. The command to run an app is <em>streamlit run</em> followed by the python script name.</p><pre>streamlit run hello_streamlit.py</pre><p>Here is a screencast for the same:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fplayer.vimeo.com%2Fvideo%2F434880825%3Fapp_id%3D122963&amp;dntp=1&amp;display_name=Vimeo&amp;url=https%3A%2F%2Fvimeo.com%2F434880825&amp;image=https%3A%2F%2Fi.vimeocdn.com%2Fvideo%2F918405312_295x166.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=vimeo" width="400" height="300" frameborder="0" scrolling="no"><a href="https://medium.com/media/56b438505b01551c9ac2ca8ea18b7d30/href">https://medium.com/media/56b438505b01551c9ac2ca8ea18b7d30/href</a></iframe><blockquote>One of the major highlights of streamlit is it’s caching feature. It lets you cache that makes it fast when you make a small tweak and then try to rerun, you will witness the power of <em>@st.cache.</em></blockquote><h4>Word of Advice:</h4><ul><li>When you have too much to show on the UI, s<em>t.sidebar </em>and<em> st. checkbox </em>can be handy for a clean UI look.</li><li>It’s always a good idea to have browser windows of the code and the app to be open side by side so that changes can be seen in real-time.</li><li>Use st.map for excellent and interactive visualization. (This is amazing!)</li></ul><h4>Alternatives:</h4><ul><li>For R users — R shiny is a good option to develop web apps quickly.</li><li>While Streamlit works completely in Python, R and Plotly Dash is another popular choice that supports Julia as well as python.</li><li>You can always use Django/Flask if you like to work in HTML/CSS.</li></ul><h3>Conclusion</h3><p>In this post, We’ve covered mainly interactive data frames and talked about quickly developing a web app using python scripting. Streamlit is bliss for Data scientists as we can build machine learning web applications and demonstrate the models to stakeholders and decision-makers. Streamlit also allows maps, modification of existing elements, and showing progress. You can find excellent documentation on Streamlit <a href="https://docs.streamlit.io/en/stable/getting_started.html">here</a>.</p><p>I’d love to hear your thoughts about Streamlit, Machine learning, and model deployment in the comments below.</p><p>If you found this useful and know anyone you think would benefit from this, please feel free to send it their way.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1afe3db4d552" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/streamlit-quickly-build-a-web-app-using-python-1afe3db4d552">Streamlit — Quickly Build a Web App Using Python</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Docker 101: All you wanted to know about Docker]]></title>
            <link>https://medium.com/data-science/docker-101-all-you-wanted-to-know-about-docker-2dd0cb476f03?source=rss-73ad232e2402------2</link>
            <guid isPermaLink="false">https://medium.com/p/2dd0cb476f03</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[containers]]></category>
            <category><![CDATA[deployment]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Shashvat G]]></dc:creator>
            <pubDate>Tue, 30 Jun 2020 22:58:35 GMT</pubDate>
            <atom:updated>2020-07-18T16:24:02.919Z</atom:updated>
            <content:encoded><![CDATA[<h4><strong>Getting Started with Docker</strong></h4><h4><strong>Docker For Absolute Beginners</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Tf0nDtokK2KeTIvl" /><figcaption>Photo by <a href="https://unsplash.com/@whoisdenilo?utm_source=medium&amp;utm_medium=referral">Who’s Denilo ?</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Have you ever been intimidated by Docker’s fancy name and wondered what it is? — Great, This post is for you.</p><p>In this post, we will cover what exactly this devil is and what it does.</p><p>First and foremost, what is Docker? 🧐</p><p>Docker is an open-source containerization tool mainly used for shipping and running applications quickly across different platforms. Docker’s way of shipping and deploying code swiftly, significantly reduces the delay between writing code and running it in production. It is developed using GO and was first released in 2013.</p><p><strong>Why Docker?</strong></p><p>Docker has a list of advantages that makes it super useful. Some of them are:</p><ol><li><strong>Isolation</strong></li></ol><p>It helps us create an environment agnostic system. Your application runs smoothly on different platforms. This is essentially achieved using containers.</p><p><strong><em>2. </em>Portability</strong></p><p>Since all of your dependencies are in the same container, it’s easy to carry from one place to another giving Docker its portability.</p><p><strong><em>3.</em> Lightweight</strong></p><p>Runs as another application on your system instead of consuming whole lot resources of your system.</p><p><strong><em>4. </em>Robustness</strong></p><p>Less demanding in terms of hardware and needs very little memory as compared to VMs, hence providing efficient isolation levels which help save not only the cost but also time.</p><p><strong><em>Before we dive in further, why do we need Docker at all? Don’t we have enough tools around, huh?</em>🤨</strong></p><p>Yes, we do. Loads of them, but Docker is different. It makes our life easier. I’ll tell you how — Keep reading.</p><p>Allow me to give you some background!</p><p><strong>Background</strong></p><p>Once upon a time, we used to install software on OS which was installed on a specific set of hardware- CPU, Memory, and disk. Let’s fast forward a bit, there comes the age of virtualization. Running multiple OSs within the same OS allowing some level of hardware isolation. For instance — running Ubuntu on Windows using VirtualBox.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/914/1*-vHWBJYg5oh1fLxeYs93Rw.png" /><figcaption>Containers vs Virtual Machines (Image Source: Docker.com[1])</figcaption></figure><p>This is pretty cool you see but in the era of Agile, where time is money and you need to deliver continuously and present deliverables at the end of each sprint, chasing IT departments like operation to get access for different development environments for different stories (e.g. resource-intensive processes that need more memory/disk) can be daunting as well as time-consuming.</p><p>Worry no more, Here comes Docker to the rescue. It has something for you, a product that goes by the name docker which provides not only a lightweight level of virtualization but also an open-source Linux based software that can run on any hardware that supports docker instances like Windows or OSX. Docker achieves this level of virtualization by using containers. It’s a metaphor really as it works the same way a normal container does. It does store things in it.</p><p>A container is a standard unit of software that bundles up code and all its dependencies so the application runs smoothly and swiftly irrespective of the computing environment. Honestly, a container is nothing but a running process, with some added encapsulation features applied to it to keep it isolated from the host and other containers. [1]</p><p><strong>Lightweight, you said?</strong></p><p>Docker containers run as executable and unlike virtualization which takes up a significant portion of system resources, a container is just like another executable application that provides a similar level of virtualization but in a resource-efficient and more secure way. Since Docker containers share the same system resources, this makes them efficient. For example — a system where one needs to run virtual machines, one can have different Docker containers and have some level of isolation which you usually have in your VMs.</p><p>One of the most important aspects of container isolation is that each container interacts with its private filesystem; this filesystem is provided by a Docker image. This essentially means the need for fewer resources and in turn cost.</p><p><strong>Cool, what’s an image?</strong></p><p>It’s not what you think it is. It is more like a photocopier. You can make your containers from an image just like you can photocopy using the Xerox machine. It is nothing but a template that contains an application, as well as all the dependencies, needs to run your application like your code, libraries, config files, environment variables (ex- PATH), etc. This image can be deployed to different environments. Wondering how an image is different from the container? Well, a container is a running instance of an image.</p><p>Now that we know a bit about Docker, Let’s have a look at its architecture.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/959/1*P4jIXcQ5FlqdvAUqoHMLVw.png" /><figcaption>Docker CLI(Client) | Docker Daemon (Server) | Docker Hub (Registry) (Image Source: Docker.com[1])</figcaption></figure><p><strong>Client-Server Architecture</strong></p><p>The Docker command line uses the Docker REST API to interact with the Docker daemon. Docker client is the command-line tool and that’s how users interact with Docker. Docker daemon listens to ports for Docker client API requests and manages Docker objects such as images and containers. The client and server can be on the same machine. A Registry is where docker images are stored. It is a public registry and by default, images are stored on Docker hub. You can use the Registry of your choice for storing images.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/782/1*w80u-oaWIHH6GJfpLdZ0Tw.png" /><figcaption>Client-Server Architecture (Image Source: Docker.com[1])</figcaption></figure><p><strong>Docker Hub</strong></p><p>It is an official online repository where all docker images are stored and it also permits those images to be distributed. As discussed above, Docker uses Linux based CLI tool to interact with Docker Daemon. You can use this CLI to create and publish your image to Docker Hub. There are two ways to achieve this –</p><p>1. Create an image locally and push it to Docker Hub.</p><p>2. Create a docker file and use Docker continuous build system to build images. (Preferred)</p><p>Before you can push the image to Docker hub, you need an account (The basic version is free, get yours <a href="https://hub.docker.com/">here</a>) and Docker hub Desktop application. The pre-requisite for this is that you should have Docker installed on your system (Get <a href="https://docs.docker.com/install/">Docker CE(Community Edition)</a>). After you authenticate yourself, you can start pushing your images to the docker hub.</p><p><strong>Who needs Docker?</strong></p><p>You may want to use Docker if you need quick and consistent delivery of your application. Predominantly, Software Engineers, DevOps Engineers, Data Engineers, and Data Scientists can benefit from Docker. Docker streamlines the software development lifecycle by allowing developers to work in standardized environments that work like a charm for continuous integration and continuous delivery (CI/CD) workflows.</p><h3><strong>Conclusion</strong></h3><p>In this post, We had a quick look at Docker as a containerization tool, the client-server architecture, and its functionality. In the next posts, we will explore Docker commands, building your images, running containers, and dealing with failures.</p><p>Stay Tuned 😊</p><p>Happy to hear your thoughts on this one!</p><p>If you found this useful and know anyone you think would benefit from this, please feel free to send it their way.</p><h4>References:</h4><p>[1] <a href="https://docs.docker.com/get-started">https://docs.docker.com/get-started</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2dd0cb476f03" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/docker-101-all-you-wanted-to-know-about-docker-2dd0cb476f03">Docker 101: All you wanted to know about Docker</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>
    </channel>
</rss>