<?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 Sejal Goyal on Medium]]></title>
        <description><![CDATA[Stories by Sejal Goyal on Medium]]></description>
        <link>https://medium.com/@sejalgoyal1998?source=rss-23f627eb5e90------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*Dv0bysbHKdUCyfZK</url>
            <title>Stories by Sejal Goyal on Medium</title>
            <link>https://medium.com/@sejalgoyal1998?source=rss-23f627eb5e90------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 22:14:31 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sejalgoyal1998/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[Text Recognition using EasyOCR Python on SAP Data Intelligence]]></title>
            <link>https://sejalgoyal1998.medium.com/text-recognition-using-easyocr-python-on-sap-data-intelligence-29237776d549?source=rss-23f627eb5e90------2</link>
            <guid isPermaLink="false">https://medium.com/p/29237776d549</guid>
            <category><![CDATA[sap-data-intelligence]]></category>
            <category><![CDATA[easyocr]]></category>
            <category><![CDATA[rest-api]]></category>
            <category><![CDATA[ocr]]></category>
            <category><![CDATA[postman]]></category>
            <dc:creator><![CDATA[Sejal Goyal]]></dc:creator>
            <pubDate>Sat, 03 Jul 2021 05:55:37 GMT</pubDate>
            <atom:updated>2021-07-03T05:55:37.686Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*WYk_6Dgzfm9UEoin.png" /></figure><p>In this post, we will create a REST API for text recognition in an image using EasyOCR python library. Worked on SAP Data Intelligence first time recently and found difficulty in creating a REST API. Sharing my knowledge here, I hope it helps!</p><p><strong>Step-1: Create Scenario<br></strong>Go to the main page of SAP Data Intelligence and click into the “ML Scenario Manager”. Click the little “+”-sign on the top right to create a new scenario. Name it “EasyOCR example” and you enter further details into the “Text Recognition” section. Click “Create”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/679/1*ks2zJFTKVYifC7bDkl6ncQ.png" /></figure><p>You see the empty scenario. You can use the Notebooks to explore the data. Pipelines bring the code into production. Executions of these pipelines will create Machine Learning models, which are then deployed as REST-API for inference. In this tutorial we are not using any ML model.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oog0dNnTKDAah_QFlssLzg.png" /></figure><p><strong>Step-2: Create Pipeline<br></strong>Create Pipeline by selecting “Create” and Name it “OCR API” and Template as “Python Consumer”. you will see a diagram of pipeline. As we are not using any ML model so this pipeline needs to be changed like below diagram.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/482/1*8GtcaLj-uXpRdivdBvrDTA.png" /></figure><p><strong>Step-3: Change Python file<br></strong>Python script in our pipeline accepts image file and send the extracted text. For text extraction we are using Opencv2 and EasyOCR. Right click on “Python36-Inference” and select “Open Script” from the list. Copy the below python code and save the pipeline.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ThMnTIBnBzwi845-LgrgMw.png" /></figure><p><strong>Step-4: Create DockerFile<br></strong>Select “Repository” in left side menu and then select “dockerfiles”. Create a folder and place the below commands to “Dockerfile” file and save it. Select configuration on top right side and give tag name “OCR_image” and version. Build this dockerfile. After success go to next step.</p><pre>FROM $com.sap.sles.ml.python<br>RUN python3.6 -m pip — no-cache-dir install — user — upgrade pip<br>RUN python3.6 -m pip — no-cache-dir install — user easyocr<br>RUN python3.6 -m pip — no-cache-dir install — user opencv-python<br>RUN python3.6 -m pip — no-cache-dir install — user numpy</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NF7Lm3MGRYCBeoCLk4rgsQ.png" /></figure><p><strong>Step-5: Apply DockerFile<br></strong>Go to pipeline diagram and right click on Python script. Select “Group” from the list. Now right click on newly created group and select “Open configuration”. Go to tags and add “OCR_image” and version “V2”. Save it.</p><p><strong>Step-6: Deploy API<br></strong>Go back to scenario page and select the “OCR API” pipeline and select deploy.<br>Once you will get the status as “Running” then you can copy the Deployment url from the top.</p><p>Congrats!! you have created the REST API successfully.</p><p><strong>Access this REST API using Postman:-<br>1. </strong>Create an API client in Postman. Place <em>&lt;Deployment URL&gt;+/v1/uploadjson/ </em>and select post. <br><strong>2.</strong> select authorization and place “&lt;tenant name&gt;+\+&lt;user name&gt;” (Ex. default\I456789) in Username and give password.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YVczzES21oZetihzVu97_Q.png" /></figure><p><strong>3.</strong> Select “Headers”. Add header “X-Requested-With” :“XMLHttpRequest”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T86_La4dYu00pT8WFdas_g.png" /></figure><p><strong>4.</strong> Select “Body” then “Binary” and now select image from your system.<br><strong>5.</strong> Click Send. Result will be a json.</p><p>Suppose below is the selected image(Ex: test.jpg).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*s5AIUVl6Cjo9hNJy.jpg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qiCISQkBdhcwuE3yQwTm1A.png" /></figure><p>Result will be:- { “Extracted text”: “619121”}.</p><p>If you would like to learn more / have feedback, please let me know, so I can improve &amp; write more for you interested folks.<br>Keep learning! :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=29237776d549" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Database Comparison: MS SQL Server vs PostgreSQL vs MongoDB]]></title>
            <link>https://sejalgoyal1998.medium.com/database-comparison-ms-sql-server-vs-postgresql-vs-mongodb-13edd984877f?source=rss-23f627eb5e90------2</link>
            <guid isPermaLink="false">https://medium.com/p/13edd984877f</guid>
            <category><![CDATA[nosql]]></category>
            <category><![CDATA[database]]></category>
            <category><![CDATA[sql]]></category>
            <dc:creator><![CDATA[Sejal Goyal]]></dc:creator>
            <pubDate>Sat, 29 Aug 2020 04:50:41 GMT</pubDate>
            <atom:updated>2022-01-28T04:43:53.922Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*J-6R3vXEv0M9sgsL" /></figure><p>Hey There! I recently worked on a project where i was confused which Database should i use in the project. For that i picked some popular databases and compared them. Here i’m sharing my analysis for these databases.</p><h3>Databases</h3><p>For my analysis I used 3 databases:</p><ul><li><strong>Microsoft SQL Server(MS SQL)</strong></li><li><strong>PostgreSQL</strong></li><li><strong>MongoDB</strong></li></ul><p>Here we have both <strong>SQL</strong> and <strong>NoSQL</strong> databases. The difference in them is —</p><ul><li><strong>SQL</strong> databases are relational, <strong>NoSQL</strong> are non-relational</li><li><strong>SQL</strong> databases use structured query language and have a predefined schema. <strong>NoSQL</strong> databases have dynamic schema for unstructured data.</li><li><strong>SQL</strong> databases are vertically scalable, <strong>NoSQL</strong> databases are horizontally scalable</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*-hI4_oOULA04JAar.png" /></figure><p><strong>Microsoft SQL server</strong> is very popular RDBMS with highly restrictive licensing and high cost of ownership which is mainly used for e commerce and providing different data warehousing solutions. It is a cross platform database system but runs only on Windows and Linux. <br>For running it on MAC, programmer need to install Docker. This will enable you to run SQL Server from within a Docker container.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/769/0*XGTd2nxNO7W5ZC9n.jpg" /></figure><p><strong>PostgreSQL</strong> is the world’s most advanced open source relational database management system (RDBMS) emphasizing extensibility and SQL compliance. The PostgreSQL community is very strong and continuously improving existing features and implementing new features. <br>It is a cross platform database system. It provides support to many Operating Systems.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/660/0*YNNDIkpRlLkqyJAy.png" /></figure><p><strong>MongoDB</strong> is an open-source document database and leading NoSQL database. Documents consist of key-value pairs which are the basic unit of data in MongoDB.<br>It is a cross platform database system. It provides support to many Operating Systems.</p><h3><strong>Comparison in the Relational Databases(MSSQL vs PostgreSQL)</strong></h3><p>Both are popular choices in the market; let us discuss some of the major Difference:</p><p><strong>1.</strong> <strong>Cross-platform and OS support:</strong> Both servers are cross platform supported. PostgreSQL supports many operating systems Like Windows, Linux, Unix, OS X etc. But MS SQL Server supports only Windows and Linux.</p><p><strong>2. Procedural language features:</strong> <strong><em>PostgreSQL</em></strong> provides procedural language support. It supports JSON data type and has ultimate power and loads of flexibility included in a single package. A user can easily use Python, Perl, R, Java, PHP with SQL as they are supported as procedural languages in PostgreSQL. <strong><em>MS SQL Server</em></strong> also provides procedural language support as an inbuilt feature. But this feature is a bit messy, slow and has poor features. It also has small errors with different bugs always occurring.</p><p><strong>3. Regular expressions:</strong> <strong><em>PostgreSQL</em></strong> provides a huge number of regex as a basis for analytical work.<strong><em> MS SQL Server</em></strong>, on the other hand, has like, substring, pattern index which are not as good when compared to expressions provided by PostgreSQL.</p><p>4. <strong>Popularity: <em>PostgreSQL</em></strong> is used by businesses of all sizes, though it is more popular with smaller businesses due to its open-source nature.<strong><em> MS SQL Server </em></strong>is a relational database software that is most popular with mid-sized and large enterprises.</p><p>5. <strong>Good external language bindings</strong>: <strong><em>PostgreSQL</em></strong> is very easy to connect to and use from programming environments, because libpq, its external API, is very well-designed and very well-documented. <strong><em>MS SQL Server</em></strong><em> </em>‘s external language bindings vary. Sometimes you have to install extra drivers. Sometimes you have to create classes to store the data you are querying, which means knowing <em>at compile time</em> what that data looks like. Documentation is also a bit confusing and messy, which makes getting this done unnecessarily time-consuming and painful.</p><p><strong>6.</strong> <strong>Cost: <em>PostgreSQL</em></strong> is an Open-Source project so it is free. <strong><em>MS SQL server</em></strong> is a Microsoft’s product and for using it organization/User need to pay.</p><p><strong>7.</strong> <strong>Partitioning methods: <em>PostgreSQL</em></strong> uses declarative partitioning (by range or by list) since PostgreSQL 10.0. In <strong><em>MS SQL Server</em></strong>, tables can be distributed across several files (horizontal partitioning); sharding through federation.</p><p><strong>8.</strong> <strong>Script-ability: <em>PostgreSQL</em></strong> can be driven entirely from the command line. <strong><em>MS SQL Server</em></strong> is more driven through a GUI.</p><p><strong>9.</strong> <strong>Replication: <em>PostgreSQL</em></strong> uses master-slave replication. <strong><em>MS SQL Server </em></strong>supports snapshot replication, transactional replication, merge replication.</p><p><strong>10.</strong> <strong>Concurrency</strong>: <strong><em>PostgreSQL</em></strong> has a better concurrency management system. It handles very well the case where multiple processes can access and modify shared data at the same time. <strong><em>MS SQL Server</em></strong> has underdeveloped concurrency and you can easily get various locked, blocked, and deadlocked reports in the log. Thus the performance of the database, as well as the application, will be slower.</p><p><strong>From the above comparisons, in most of the cases PostgreSQL is more suitable.</strong></p><h3>Comparison in PostgreSQL, MongoDB</h3><p>Both databases are awesome; let us discuss some of the major Differences:</p><p><strong>1.</strong> <strong>Database Structure: <em>MongoDB</em></strong> is an open-source software that is used for non-relational database management systems. In <strong><em>MongoDB</em></strong>, all the contents of the database are documents and files. <strong><em>PostgreSQL</em></strong> is an open-source software that is used for the relational database management system. As PostgreSQL handles relational database, it is object-oriented in nature.</p><p><strong>2.</strong> <strong>Data Schema and orientation: <em>MongoDB</em></strong> is a schema-free database and mainly document oriented. <strong><em>PostgreSQL</em></strong> is a schema-based database and uses object oriented.</p><p><strong>3.</strong> <strong>Data Storage: </strong>In <strong><em>MongoDB</em></strong>, Collection is used for storing the related information and the document is used for getting information. In <strong><em>PostgreSQL</em></strong>, the tables are used for storing the related data information and the rows are used for getting information.</p><p><strong>4.</strong> <strong>Architecture: <em>MongoDB</em></strong> follows the distributed architecture. <strong><em>PostgreSQL</em></strong> follows the monolithic architecture.</p><p><strong>5.</strong> <strong>Syntax: </strong>In <strong><em>MongoDB</em></strong>, syntax is different compared to other relational databases. <strong><em>PostgreSQL</em></strong>’s syntax is like other relational databases.</p><p><strong>6.</strong> <strong>Multi-lingual: <em>MongoDB</em></strong> is only available in English language. <strong><em>PostgreSQL</em></strong> is available in multiple languages.</p><p><strong>7.</strong> <strong>Upfront planning: <em>MongoDB</em></strong> gives you the flexibility to focus on getting application working without doing a lot of upfront database planning. When using <strong><em>PostgreSQL</em></strong>, you’ll need to spend a lot of time upfront planning the database schema because schema changes are difficult.</p><p><strong>8.</strong> <strong>Scalability: <em>MongoDB</em></strong> can be scaled up Horizontally, which means that you can scale by adding more servers and spreading the load and data across them. <strong><em>PostgreSQL</em></strong> can be scaled up by increasing the capacity of a single server. It can be implemented by increasing the server’s RAM.</p><p><strong>9.</strong> <strong>Extensibility: <em>MongoDB</em></strong> is extensible using plug-ins. <strong><em>PostgreSQL </em></strong>is highly extensible.</p><p><strong>10.</strong> <strong>Write speed: <em>PostgreSQL</em></strong> is magically faster than <strong><em>MongoDB </em></strong>if documents are stored in a tabular format but that’s not the case with MongoDB because documents are stored in JSON format. When data in Postgres is stored as JSON documents, it no longer is faster than MongoDB.</p><p><strong>Both the databases are awesome but it depends on our use case…</strong></p><p>If you would like to learn more / have feedback, please let me know, so I can improve &amp; write more for you interested folks.<br>Keep learning! :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=13edd984877f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Data Visualization With Python: Matplotlib]]></title>
            <link>https://medium.com/swlh/data-visualization-with-python-matplotlib-16880d0d3a44?source=rss-23f627eb5e90------2</link>
            <guid isPermaLink="false">https://medium.com/p/16880d0d3a44</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[matplotlib]]></category>
            <category><![CDATA[data-visualization]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[plotting-data]]></category>
            <dc:creator><![CDATA[Sejal Goyal]]></dc:creator>
            <pubDate>Sat, 04 Jul 2020 18:24:19 GMT</pubDate>
            <atom:updated>2020-07-06T14:32:24.765Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*pv5Mz7YpFq7Ngk27.jpg" /><figcaption>Source: Google Images</figcaption></figure><p>Data visualization is the graphical representation of data in a graph, chart or other visual formats. It shows relationships of the data with images.</p><p>Python offers multiple graphics libraries, with which you can create interactive, live or highly customizable plots with the given data.</p><p>To get a little overview here are a few popular plotting libraries:</p><ul><li><a href="https://matplotlib.org/"><strong>Matplotlib</strong></a></li><li><a href="https://seaborn.pydata.org/"><strong>Seaborn</strong></a></li><li><a href="https://pandas.pydata.org/pandas-docs/stable/visualization.html"><strong>Pandas Visualization</strong></a></li><li><a href="https://plotly.com/python/"><strong>Plotly</strong></a></li></ul><p>In this article, we will learn about creating a different type of plots using the Matplotlib library.</p><p>Matplotlib is the most popular plotting library for python, which was designed to have a similar feel to MATLAB’s graphical plotting. It gives you control over every aspect of a plot.</p><p>Matplotlib allows you to create reproducible figures using a few lines of code. Let’s learn how to use it! I also encourage you to explore: <a href="http://matplotlib.org/">http://matplotlib.org/</a>.</p><h4>Installing Matplotlib</h4><p>Install it with <em>pip</em> or <em>conda</em> at your command line or the terminal with:-</p><pre>pip install matplotlib <br><strong>OR</strong><br>conda install matplotlib</pre><p>To quickly get started with Matplotlib without installing anything on your local machine, check out <a href="https://colab.research.google.com/">Google Colab</a>. It provides Jupyter Notebooks hosted on the cloud for free which are associated with your Google Drive account and it comes with all the important packages pre-installed.</p><h4>Necessary Imports</h4><p>pyplot is a module of Matplotlib that makes this library work like MATLAB. Import the matplotlib.pyplot module under the name plt (the tidy way):</p><pre>import matplotlib.pyplot as plt<br>import numpy as np <strong><em># for working with arrays </em></strong></pre><h4><strong>Making a Simple Plot</strong></h4><p>We pass two NumPy arrays(x and y) and ‘r’ as arguments to Pyplot’s plot() function. Here ‘r’ is for red colour, x elements will appear on x-axis and y elements will appear on the y-axis.</p><pre>import matplotlib.pyplot as plt<br>import numpy as np</pre><pre>x = np.array([0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5])<br>y = x ** 2 <strong><em># y is now a list with elements of x to the power 2</em></strong><em><br></em><br>plt.plot(x, y, &#39;r&#39;)<br>plt.xlabel(&#39;X Axis Title Here&#39;)<br>plt.ylabel(&#39;Y Axis Title Here&#39;)<br>plt.title(&#39;String Title Here&#39;)<br>plt.show()<br><strong><em># The plot below is the output of this program.</em></strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/505/1*Vp9NMGDRW8inLoLABDhQUg.png" /></figure><p><strong>Creating Multiple Plots on The Same Canvas <br></strong>subplot(): a method of <em>pyplot</em>, divides the canvas into nrows x ncols parts and using plot_number argument you can choose the plot.</p><p>Syntax: subplot(nrows, ncols, plot_number)</p><p>In the below example, using plt.plot(x, y, &#39;r--’)we plot a red coloured graph with line style ‘- -’ between x and y at plot_number=1.</p><pre>import matplotlib.pyplot as plt<br>import numpy as np</pre><pre>x = np.array([0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5])<br>y = x ** 2</pre><pre>plt.subplot(1,2,1) <strong><em># subplot(nrows, ncols, plot_number)</em></strong><br>plt.plot(x, y, &#39;r--&#39;) <strong><em># r-- meaning colour red with -- pattern</em></strong><br>plt.subplot(1,2,2)<br>plt.plot(y, x, &#39;g*-&#39;) <strong><em># g*- meaning colour green with *- pattern<br># The plot below is the output of this program.</em></strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/444/1*1f5YQBbO9QxsY52tjQgiPQ.png" /></figure><p>For making it more simple subplots() method can be used instead of subplot(). You will see its example in “<strong>Creating Multiple plots on The Same Canvas</strong>” under “<strong>Matplotlib Object-Oriented Method</strong>”.</p><h4>Matplotlib Object-Oriented Method</h4><p>Now we have seen the basics, let’s learn a more formal introduction of Matplotlib’s Object-Oriented API. This means we will instantiate figure objects and then call methods or attributes from that object.</p><h4>Making a Simple Plot</h4><p>For Matplotlib Object-Oriented Method, we create a <em>figure instance</em> which provides an empty canvas.</p><pre>import matplotlib.pyplot as plt<br>import numpy as np</pre><pre>x = np.array([0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5])<br>y = x ** 2</pre><pre><strong><em># Create Figure (empty canvas)<br></em></strong>fig = plt.figure()</pre><pre><strong><em># Add set of axes to figure</em></strong><br>axes = fig.add_axes([0.1, 0.1, 0.8, 0.8]) <br><strong><em># axes = fig.add_axes([left, bottom, width, height (range 0 to 1)])</em></strong></pre><pre><strong><em># Plot on that set of axes</em></strong><br>axes.plot(x, y, ‘b’) <strong><em># &#39;b&#39; = blue color<br># The plot below is the output of this program.</em></strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/472/1*x9dKmqOhmzahXSn6VCPeQQ.png" /></figure><p><strong>Creating Multiple plots on The Same Canvas</strong></p><p>The subplots() method takes two arguments nrows and ncols. <br>This method creates two objects:figure and axes which, in our example, we store in variables <em>fig</em> and <em>ax </em>which can be used to change the <strong><em>figure</em></strong> and <strong><em>axes </em></strong>level attributes respectively.</p><pre>import matplotlib.pyplot as plt<br>import numpy as np</pre><pre>x = np.array([0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5])<br>y = x ** 2</pre><pre>fig, axes = plt.subplots(nrows=1, ncols=2)</pre><pre>for ax in axes:<br>    ax.plot(x, y, &#39;g&#39;)<br>    ax.set_xlabel(&#39;x&#39;)<br>    ax.set_ylabel(&#39;y&#39;)<br>    ax.set_title(&#39;title&#39;)</pre><pre>plt.show()<br>fig.savefig(&#39;plot.png&#39;)<br><strong><em># The plot below is the output of this program.</em></strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/514/1*OkZD06k3zQdAbPwllr9VrA.png" /></figure><p><strong>Line and marker styles</strong></p><pre>import matplotlib.pyplot as plt<br>import numpy as np</pre><pre>x = np.array([0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5])<br>y = x ** 2</pre><pre>fig, ax = plt.subplots(figsize=(12,6))</pre><pre>ax.plot(x, x+3, color=&quot;red&quot;, linewidth=1.00)<br>ax.plot(x, x+4, color=&quot;red&quot;, linewidth=2.00)</pre><pre><strong><em># possible lines type options ‘-‘, ‘–’, ‘-.’, ‘:’, ‘steps’</em></strong><br>ax.plot(x, x+5, color=&quot;green&quot;, lw=3, linestyle=&#39;-&#39;)<br>ax.plot(x, x+6, color=&quot;green&quot;, lw=3, ls=&#39;-.&#39;)<br>ax.plot(x, x+7, color=&quot;green&quot;, lw=3, ls=&#39;:&#39;)</pre><pre><strong><em># custom dash</em></strong><br>line, = ax.plot(x, x+8, color=&quot;black&quot;, lw=1.50)<br>line.set_dashes([5, 10, 15, 10])<strong><em># format:line length,space length,..</em></strong></pre><pre><strong><em># possible marker symbols: marker = &#39;+&#39;, &#39;o&#39;, &#39;*&#39;, &#39;s&#39;, &#39;,&#39;, &#39;.&#39;,..</em></strong><br>ax.plot(x, x+9, color=&#39;b&#39;, lw=3,ls=&#39;-&#39;, marker=&#39;+&#39;, markersize=2)<br>ax.plot(x, x+10, color=&#39;b&#39;, lw=3, ls=&#39;--&#39;, marker=&#39;o&#39;, markersize=4)<br>ax.plot(x, x+11, color=&#39;b&#39;, lw=3, ls=&#39;-&#39;, marker=&#39;s&#39;, markersize=8)<br>ax.plot(x, x+12, color=&#39;b&#39;, lw=3, ls=&#39;--&#39;, marker=&#39;1&#39;,markersize=8)<br><strong><em># The plot below is the output of this program.</em></strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/882/1*LqQzs4r0ajwdtADZpx7Chg.png" /></figure><h4><strong>Control Over Axis Appearance</strong></h4><p>We can configure the ranges of the axes using the set_ylim and set_xlim methods in the axis object, or axis(&#39;tight&#39;) for automatically getting &quot;tightly fitted&quot; axes ranges:</p><pre>import matplotlib.pyplot as plt<br>import numpy as np</pre><pre>x = np.array([0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5])<br>y = x ** 2</pre><pre>fig, axes = plt.subplots(1, 3, figsize=(12, 4))</pre><pre>axes[0].plot(x, x**2, x, x**3)<br>axes[0].set_title(&quot;default axes ranges&quot;)</pre><pre>axes[1].plot(x, x**2, x, x**3)<br>axes[1].axis(&#39;tight&#39;)<br>axes[1].set_title(&quot;tight axes&quot;)</pre><pre>axes[2].plot(x, x**2, x, x**3)<br>axes[2].set_ylim([0, 60])<br>axes[2].set_xlim([2, 5])<br>axes[2].set_title(&quot;custom axes range&quot;)<br><strong><em># The plot below is the output of this program.</em></strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/894/1*mciC07GqrpujEM8_eEYkSg.png" /></figure><p><strong>Legends</strong></p><p>You can use the <strong>label=”label text”</strong> keyword argument in plot() function.<br>In the below example, ax.plot(x, x**2, label=&quot;x**2&quot;) sets the legend label for this plot as <strong><em>“x**2”.</em></strong></p><pre>import matplotlib.pyplot as plt<br>import numpy as np</pre><pre>x = np.array([0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5])<br>y = x ** 2</pre><pre>fig = plt.figure()</pre><pre>ax = fig.add_axes([0,0,1,1])</pre><pre>ax.plot(x, x**2, label=”x**2&quot;)<br>ax.plot(x, x**3, label=”x**3&quot;)<br>ax.legend()<br><strong><em># The plot below is the output of this program.</em></strong></pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/581/1*tg9iVyoHLCOWyRbx0b-NRA.png" /></figure><pre>ax.legend(loc=1) <strong><em># upper right corner</em></strong><br>ax.legend(loc=2)<strong><em> # upper left corner</em></strong><br>ax.legend(loc=3) <strong><em># lower left corner</em></strong><br>ax.legend(loc=4) <strong><em># lower right corner</em></strong></pre><pre><strong><em># .. many more options are available</em></strong></pre><pre><strong><em># Most common to choose</em></strong><br>ax.legend(loc=0) <strong><em># let matplotlib decide the optimal location</em></strong></pre><h3>Creating different types of graphs with Pyplot</h3><p>There are many specialized plots we can create, such as bar plots, histograms, scatter plots, and many more. Most of these type of plots we will actually create using seaborn, a statistical plotting library for Python. Here are a few examples of these type of plots:</p><h4><strong>1) Scatter plot</strong></h4><p>scatter(x, y) : x = list at X-Axis, y = list at Y-Axis</p><pre>import matplotlib.pyplot as plt<br>import numpy as np</pre><pre>x = np.array([0, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5])<br>y = x ** 2</pre><pre>plt.scatter(x,y)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/486/1*97aJqK3qS6UwOuxBbNSzQg.png" /></figure><h4>2) Histogram</h4><p>In Matplotlib we can create a Histogram using the hist method. In this method, we are passing dataarray that is having 100 numbers in the range from 1 to 1000.</p><pre>import matplotlib.pyplot as plt<br><br>from random import sample<br>data = sample(range(1, 1000), 100)<br>plt.hist(data)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/645/1*PxPr4NgtgX4l-jCCWYB6-g.png" /></figure><h4>3) Box Plot</h4><p>In Matplotlib we can create a Box plot using the boxplot method. In this method, we are passing a 2d array data and by passing patch_artist=True boxes in the graph are filled with colours.</p><pre>import matplotlib.pyplot as plt<br>import numpy as np</pre><pre>data = [np.random.normal(0, std, 100) for std in range(1, 4)]</pre><pre><strong><em># rectangular box plot</em></strong><br>plt.boxplot(data,patch_artist=True);</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/477/1*4LZcD9tIYInjMVSZLpjmvQ.png" /></figure><p>That’s all for the overview of Matplotlib.<br>If you would like to learn more / have feedback, please let me know, so I can improve &amp; write more for you interested folks.<br>Keep learning! :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=16880d0d3a44" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/data-visualization-with-python-matplotlib-16880d0d3a44">Data Visualization With Python: Matplotlib</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: A Beginner’s Overview]]></title>
            <link>https://sejalgoyal1998.medium.com/docker-a-beginners-overview-6034d1904066?source=rss-23f627eb5e90------2</link>
            <guid isPermaLink="false">https://medium.com/p/6034d1904066</guid>
            <category><![CDATA[docker-hands-on]]></category>
            <category><![CDATA[docker-command]]></category>
            <category><![CDATA[docker-overview]]></category>
            <category><![CDATA[docker-basic]]></category>
            <category><![CDATA[docker-beginner]]></category>
            <dc:creator><![CDATA[Sejal Goyal]]></dc:creator>
            <pubDate>Sun, 21 Jun 2020 17:35:54 GMT</pubDate>
            <atom:updated>2020-06-21T17:35:54.772Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*yRcI2Y7WBKbSTsEuqVLPyg.jpeg" /><figcaption><strong>Source: Google Images</strong></figcaption></figure><p><strong>Docker</strong>: an open-source tool(written in Go lang.) used to automate the deployment of applications in lightweight containers so they perform efficiently in different environments.</p><p>Docker helps in reducing requirement matching overhead between different environments.</p><p>For example, an app developed in <strong>Linux</strong>, which might also use <strong>MySQL </strong>DB is given for testing. Now the tester might need to have the same environment for testing, in which the app was initially made, which adds a lot of overhead to the full testing process.<br><strong>Docker helps avoid this</strong>. Using docker, we can significantly <strong>reduce the delay between writing code and running it in production</strong>.</p><p>Time Consumption Average for deploying an application:<br><strong>With Docker</strong>: 7–8 Minutes<br><strong>Without Docker</strong>: 1.5–2 Hours</p><p>Using Docker, <strong><em>the developer bundles up all the required settings and applications in an image</em></strong> and <strong><em>the tester can create a container from the image</em></strong>.</p><blockquote>Containers are very lightweight &amp; so don’t take much time to run the application on the tester’s machine.</blockquote><p>As you can see<strong> Docker is really beneficial in deploying a product</strong>.<br>In simple words, on a system, you can set up different environments(OS, database, servers etc.) for the product, but wait a second, we can do this with virtualization also(?). Why Docker, then?</p><h3>Virtualization vs Containerization</h3><p>Let’s have a look at the difference between virtualization and containerization:-</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*kP-wnZfWGoaHl7NQHU76SA.png" /><figcaption><strong>Source: Google Images</strong></figcaption></figure><p><strong>Virtualization: </strong>For creating virtual machines(VMs), the system uses <strong>hypervisor</strong>: a firmware layer that allows the system to run <strong>multiple OS’s on a single system</strong>. The hypervisor separates available resources (computing power, memory, storage, etc.), assigning a portion to each VM as needed.</p><p><strong>Containerization:</strong> OS-level virtualization which allows <strong>multiple isolated user-space instances on a single kernel</strong>. <strong>These instances are called containers</strong> i.e. multiple containers can run on a single OS. <br>These containers are very lightweight and easy to install on the system. The most common container technology is Docker.</p><p>In short, <strong>your use case matters</strong>. <br><strong><em>Containers are a good choice for projects with a much shorter life-cycle. </em></strong>Setting up a container in a system takes very less time so they are suitable for tasks that may only take a few hours. <br><strong><em>Virtual machines have a longer life-cycle than containers and are best used for longer periods of time.</em></strong></p><h4><strong>How Containerization Works</strong></h4><p>Docker uses namespaces to isolate workspaces. <strong><em>Process IDs, Network, Unix Time-sharing systems, Mount, Inter-Process Communication</em></strong> are created in their own namespaces, thereby providing isolation between containers.</p><p><strong>The Docker Architecture:-</strong></p><blockquote>The Docker architecture uses a <strong>client-server model </strong>and comprises of the<strong> Docker Client, Docker Host, Network and Storage components</strong>, and the <strong>Docker Registry/Hub.</strong></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/551/0*0z7FyJDx1Y0LFWER.png" /><figcaption><strong>Source: Google Images</strong></figcaption></figure><p>The <strong>Docker Engine</strong> allows user to develop and run an application using the following Docker components.</p><ol><li><strong>Docker Daemon</strong>: A persistent background process that manages Docker images, containers, networks, and storage volumes. The Docker daemon constantly listens for Docker API requests and processes them.</li><li><strong>Docker Engine REST API</strong>: An API is used by applications to interact with the Docker daemon. It can be accessed by an HTTP client.</li><li><strong>Docker CLI</strong>: A command-line interface client for interacting with the Docker daemon. It significantly simplifies how you manage container instances and is one of the key reasons why developers love using Docker.</li></ol><p><strong>Docker Client</strong> talks to the <strong>Docker Daemon</strong>, which performs the heavy lifting of the building, running our <strong>Docker Containers</strong>. <br>Fundamentally, both the Docker Client and Daemon <strong><em>can</em></strong> <strong><em>run on the same system</em></strong> however, we<em> </em><strong><em>could also connect a Docker Client to a remote Docker Daemon.</em></strong></p><h4>“docker run ubuntu” — How does it work?</h4><p>The computer makes a request to the configured <strong>Docker Host API</strong>, which in turn interacts with the <strong>Docker Daemon</strong>.<br>The daemon, then looks up the Ubuntu image on the host registry. If it’s not present, a new lookup will be made for pulling <strong>(downloading)</strong> the image from the configured registry <strong>(Docker Hub)</strong>.<br>Docker then creates(&amp; runs) a container from the pulled image.</p><h4><strong>A Little Practical</strong></h4><p>Setting up the Docker environment:<br><a href="https://docs.docker.com/docker-for-mac/install/"><em>Install Docker for Mac</em></a><em><br></em><a href="https://docs.docker.com/docker-for-windows/install/"><em>Install Docker for Windows</em></a><em><br></em><a href="https://docs.docker.com/install/linux/docker-ce/ubuntu/"><em>Get Docker CE for Ubuntu</em></a></p><ol><li><strong>Basic commands:</strong></li></ol><p>Shows <strong>information about client and server</strong>:</p><pre>$ docker info</pre><p><strong>info </strong>also shows running containers, images available in the system etc.</p><p>Docker <strong>version — </strong>detailed information about <strong>client &amp; server’s docker’s environments</strong>.</p><pre>$ docker version</pre><p><strong><em>Docker version:</em></strong></p><pre>$ docker -v</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/805/1*YCUhR0Cs7XaNBGGhAMAAqQ.png" /></figure><p><strong>2. Images: </strong>A Docker Image is an immutable file, comprised of multiple layers and it contains the source code, libraries, dependencies, tools, and other files needed for an application to run.</p><p><strong><em>Lists all the images:</em></strong></p><pre>$ docker images</pre><p><strong><em>Shows the history of an image:</em></strong></p><pre>$ docker history &lt;image name&gt;</pre><p><strong><em>Shows information about the image.</em></strong></p><pre>$ docker inspect image</pre><p><strong><em>Pulls an image from the registry:</em></strong></p><pre>$ docker pull &lt;image name&gt;</pre><p><strong><em>Removes the image:</em></strong></p><pre>$ docker rmi &lt;image name&gt;</pre><p>3. <strong>Containers </strong>(Running instances of docker images) <strong>:</strong></p><p><strong><em>Lists all the running containers:</em></strong></p><pre>$ docker ps</pre><p><strong><em>Lists all the containers(running &amp; stopped):</em></strong></p><pre>$ docker ps -a</pre><p><strong><em>Creates a container:</em></strong></p><pre>$ docker run &lt;image name&gt;</pre><blockquote>The above command creates a container of the specified image. <br>If the image doesn’t exist in the system then this command pulls this image from Docker hub.</blockquote><p><strong><em>Create a container in iterative mode &amp; a bash CLI in it.</em></strong></p><pre>$ docker run -it &lt;image name&gt; sh</pre><p><strong><em>Start and stop the container:</em></strong></p><pre>$ docker stop &lt;container id&gt;<br>$ docker start &lt;container id&gt;</pre><p><strong><em>Remove containers:</em></strong></p><pre>$ docker container rm &lt;container id1&gt; &lt; container id2&gt;……</pre><p>4. <strong>Volume:</strong></p><p>Volumes are the preferred mechanism for persisting data generated by and used by Docker containers. Deleting a container also deletes the data inside it.</p><p><strong><em>Create a volume:</em></strong></p><pre>$ docker volume create my-vol</pre><p><strong><em>Inspect a volume:</em></strong></p><pre>$ docker volume inspect my-vol</pre><p><strong><em>Starting a container in detached mode with volume:</em></strong></p><pre>$ docker run -d -v myvol2:/app nginx:latest</pre><p>All the data in the “<strong>app</strong>” directory gets stored in <strong>myvol2</strong>.<br>The path of <strong>myvol2</strong> can be fetched using the <strong>inspect </strong>command.</p><p><strong><em>Removing the volume:</em></strong></p><pre>$ docker volume rm my-vol</pre><p><strong>5. dockerfile</strong></p><p>It is a file with instruction for building a Docker image. It uses a layered architecture. When Docker build the images it builds these in a layered architecture. Each line of instruction creates a new layer in the docker image with just the changes from the previous one.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*e9Vhb-T_XVvHFIEFwgEfOg.png" /><figcaption><strong>Source: Google images</strong></figcaption></figure><p>You can see these layers using “docker history” command. Using <strong>docker build, </strong>you can see the various steps involved and the result of each task. All the layers built are cached so the layered architecture helps you restart <strong>docker build</strong> from that particular layer. <br>For example, if a build fails at step-3, on building the file again it will use cached layer2 and the build will start from there itself.</p><h4>Creating a dockerfile.</h4><blockquote><strong>Step-1:</strong>- Create a folder and inside that folder create a file named Dockerfile.</blockquote><blockquote><strong>Step-2:</strong>- Edit Dockerfile:-</blockquote><blockquote>Instructions of Dockerfile:- (Instructions are not case sensitive)</blockquote><p>Few instructions of dockerfile.</p><blockquote><strong>1. FROM </strong>:- Download the image from Docker Hub.</blockquote><blockquote>Ex:- <strong>FROM ubuntu or FROM ubuntu:&lt;tag&gt;</strong></blockquote><blockquote>Create an image from scratch</blockquote><blockquote>Ex:- <strong>FROM scratch</strong></blockquote><blockquote>2. <strong>MAINTAINER </strong>:- Specify the name of developer.</blockquote><blockquote>Ex:- <strong>MAINTAINER Sejal Goyal &lt;sejalgoyal1998@gmail.com&gt;</strong></blockquote><blockquote>3. <strong>RUN </strong>:- Instruction used to pass commands onto the image.</blockquote><blockquote>Ex. <strong>RUN apt-get update</strong></blockquote><blockquote>4. <strong>CMD </strong>:- Defines the default executable of a docker image. This gets executed after creation of the image.</blockquote><blockquote>Ex. <strong>CMD [“ECHO”, “Hello World”]</strong></blockquote><blockquote><strong>5. WORKDIR</strong>:- This instruction sets the working directory for any instruction (RUN, CMD, ENTRYPOINT, COPY, ADD) that follow it in the dockerfile.</blockquote><blockquote>Ex. <strong>WORKDIR /project</strong></blockquote><blockquote>6. <strong>EXPOSE</strong>:- Using this we expose the port number.</blockquote><blockquote>Ex. <strong>EXPOSE 80</strong></blockquote><p>Building an image with a tag :</p><pre>$ docker build -t &lt;image name&gt;: &lt;tagname&gt; “Location of dockerfile&quot;<br>Example: docker build -t myimage:2.0 .</pre><p><strong>Some other commands:</strong></p><p>For working with Host Engine:-</p><pre>$ docker -H &lt;host_ip_address&gt;:&lt;2375&gt; run &lt;image name&gt;</pre><p>For restricting usage of CPU:<br>(Here .5 signifies 50% CPU usage)</p><pre>$ docker run --cpus=.5 ubuntu</pre><p>For restricting usage of memory:<br>(Here 100m signifies 100mb)</p><pre>$ docker run --memory=100m ubuntu</pre><p>For executing a command in a running container:</p><pre>$ docker exec &lt;container id&gt; &lt;command&gt;</pre><p>That’s all for the overview. <br>If you would like to learn more / have feedback, please let me know, so I can improve &amp; write more for you interested folks. <br>Keep learning! :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6034d1904066" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>