<?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 Ifeanyi Nneji on Medium]]></title>
        <description><![CDATA[Stories by Ifeanyi Nneji on Medium]]></description>
        <link>https://medium.com/@ifeanyinneji777?source=rss-eb428365def4------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*ga-cW_kt0yuvpeDa4tJK0w.jpeg</url>
            <title>Stories by Ifeanyi Nneji on Medium</title>
            <link>https://medium.com/@ifeanyinneji777?source=rss-eb428365def4------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 06:41:11 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ifeanyinneji777/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[Real-Time Image Processing using WebSockets and Flask in Python and JavaScript]]></title>
            <link>https://python.plainenglish.io/real-time-image-processing-using-websockets-and-flask-in-python-and-javascript-97fb4a0a764f?source=rss-eb428365def4------2</link>
            <guid isPermaLink="false">https://medium.com/p/97fb4a0a764f</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[flask-framework]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[html]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Ifeanyi Nneji]]></dc:creator>
            <pubDate>Thu, 23 Feb 2023 16:16:45 GMT</pubDate>
            <atom:updated>2023-02-23T16:16:45.417Z</atom:updated>
            <content:encoded><![CDATA[<h4>Building a Real-Time Image Processing App with Python and JavaScript</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MzJR51Ceqe-aGfyJtm3bpQ.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@pankajpatel?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Pankaj Patel</a> on <a href="https://unsplash.com/photos/Fi-GJaLRGKc?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><h3>Introduction</h3><p>Real-time image processing has gained a lot of importance in recent years due to its various applications. The applications range from facial recognition to autonomous vehicles. In this tutorial, we will learn how to perform real-time image processing using the client’s webcam and the given code.</p><p>We will be using Flask, Socket.IO, OpenCV, and HTML/CSS/JavaScript to create a simple web application that captures real-time video from the user’s camera, performs some image processing on it, and displays the processed video back to the user.</p><p>You can find the complete code in this GitHub repository:</p><p><a href="https://github.com/Nneji123/flask-client-camera">GitHub - Nneji123/flask-client-camera</a></p><h3>Prerequisites</h3><p>Before we start, you should have a basic understanding of Python, HTML, CSS, and JavaScript. You will also need to install the following requirements before proceeding. It’s best to create a virtual environment also before installing any of the requirements. You can do that by running the following commands:</p><pre># Create Virtual Environment<br>python -m venv env<br><br># Activate Virtual Environment<br># Linux<br>source env/bin/activate<br># Windows<br>source env\Scripts\activate</pre><p>Install requirements by running pip install -r requirements.txt</p><pre># requirements.txt<br><br>Flask-SocketIO==4.3.1<br>python-engineio==3.13.2<br>python-socketio==4.6.0<br>Flask==2.0.3<br>Werkzeug==2.0.3<br>opencv_python==4.7.0.68<br>numpy==1.24.2</pre><h3>Understanding the Code</h3><p>The code provided consists of three main parts: HTML, JavaScript, and Python.</p><h3>HTML</h3><p>The HTML code contains a video element to display the captured video and a canvas element to capture the video frame and send it to the server for processing. The JavaScript file is linked at the bottom of the HTML code, which contains the logic to capture the video frames and send them to the server.</p><h3>JavaScript</h3><p>The JavaScript code contains the logic to capture the video frames, convert them to Base64 format, and send them to the server using Socket.IO. The code also receives the processed image from the server and displays it on the webpage.</p><h3>Python</h3><p>The Python code contains the Flask application and Socket.IO code that receives the video frames, processes them, and sends back the processed image to the client.</p><h3>Building the Application</h3><p>Now let’s dive into building the application step by step.</p><h3>Step 1: Setting Up Flask and Socket.IO</h3><p>We will start by creating a Flask application and setting up Socket.IO:</p><pre>from flask import Flask, render_template, send_from_directory<br>from flask_socketio import SocketIO, emit<br><br>app = Flask(__name__, static_folder=&quot;./templates/static&quot;)<br>app.config[&quot;SECRET_KEY&quot;] = &quot;secret!&quot;<br>socketio = SocketIO(app)</pre><h3>Step 2: Setting up the Index Route</h3><p>We will now set up the index route, which will be the main page of our web application. In this step, we will create a simple HTML template that will contain the video and canvas elements.</p><pre>@app.route(&quot;/&quot;)<br>def index():<br>    return render_template(&quot;index.html&quot;)</pre><p>HTML Template</p><pre>&lt;!DOCTYPE html&gt;<br>&lt;html lang=&quot;en&quot;&gt;<br>  &lt;head&gt;<br>    &lt;meta charset=&quot;UTF-8&quot;&gt;<br>    &lt;title&gt;Flask Client Camera Web App&lt;/title&gt;<br><br>    &lt;style&gt;<br>     #video {<br>      transform: rotateY(180deg);<br>      -webkit-transform:rotateY(180deg); /* Safari and Chrome */<br>      -moz-transform:rotateY(180deg); /* Firefox */<br>      <br>     }<br>    &lt;/style&gt;<br>    &lt;script<br>      src=&quot;https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js&quot;&gt;&lt;/script&gt;<br>    &lt;script<br>      src=&quot;https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.0.3/socket.io.js&quot;&gt;&lt;/script&gt;<br>  &lt;/head&gt;<br><br>  &lt;body&gt;<br><br>    &lt;div id=&quot;container&quot;&gt;<br>      &lt;video autoplay playsinline id=&quot;videoElement&quot;&gt;&lt;/video&gt;<br>      &lt;canvas id=&quot;canvas&quot; width=&quot;400&quot; height=&quot;300&quot;&gt;&lt;/canvas&gt;<br>    &lt;/div&gt;<br><br>    &lt;div class= &#39;video&#39;&gt;<br>      &lt;img id=&quot;photo&quot; width=&quot;400&quot; height=&quot;300&quot;&gt;<br>    &lt;/div&gt;<br>    &lt;script src=&quot;{{ url_for(&#39;static&#39;,filename=&#39;script.js&#39;) }}&quot;&gt;&lt;/script&gt;<br>  &lt;/body&gt;<br><br>&lt;/html&gt;</pre><h3>Step 3: Capturing Video from the User’s Camera</h3><p>Now that we have set up the HTML and CSS, we can move on to writing the JavaScript code. We will first create a socket object to connect to the server using Socket.IO. We will then set up the canvas to capture the video stream from the user’s camera.</p><pre>var socket = io.connect(window.location.protocol + &#39;//&#39; + document.domain + &#39;:&#39; + location.port);<br>socket.on(&#39;connect&#39;, function () {<br>    console.log(&quot;Connected...!&quot;, socket.connected)<br>});<br><br>var canvas = document.getElementById(&#39;canvas&#39;);<br>var context = canvas.getContext(&#39;2d&#39;);<br>const video = document.querySelector(&quot;#videoElement&quot;);<br><br>video.width = 400;<br>video.height = 300;<br><br>if (navigator.mediaDevices.getUserMedia) {<br>    navigator.mediaDevices.getUserMedia({<br>        video: true<br>    })<br>        .then(function (stream) {<br>            video.srcObject = stream;<br>            video.play();<br>        })<br>        .catch(function (err0r) {<br><br>        });<br>}</pre><p>Here, we create a socket object and connect it to the server. We also set up the canvas to capture the video stream from the user’s camera using the getUserMedia API. We set the width and height of the video to 400 and 300, respectively.</p><p>Next, we set up a function to capture the video stream from the user’s camera at a certain frame rate and send it to the server for processing.</p><pre>const FPS = 10;<br>setInterval(() =&gt; {<br>    width = video.width;<br>    height = video.height;<br>    context.drawImage(video, 0, 0, width, height);<br>    var data = canvas.toDataURL(&#39;image/jpeg&#39;, 0.5);<br>    context.clearRect(0, 0, width, height);<br>    socket.emit(&#39;image&#39;, data);<br>}, 1000 / FPS);<br><br>socket.on(&#39;processed_image&#39;, function (image) {<br>    photo.setAttribute(&#39;src&#39;, image);<br><br>});</pre><p>Here, we set the frame rate to 10 frames per second using the FPS constant. We then capture the video stream by drawing it onto the canvas and obtaining the base64-encoded data URL of the canvas using the <em>toDataURL()</em> method. We clear the canvas after each frame using the <em>clearRect()</em> method.</p><p>We then send the base64-encoded data URL to the server using the emit() method of the socket object. We emit the data with the ‘image’ event.</p><p>We also set up a function to receive the processed image from the server and display it on the web page using the processed_image event.</p><p>Now that we have written the JavaScript code, we can move on to writing the Python code to process the image on the server.</p><h3>Step 4: Processing Client Webcam Stream</h3><p>The Python code will use Flask and Flask-SocketIO to set up a web server and handle incoming connections from the client.</p><p>First, we need to import the required libraries.</p><pre>import base64<br>import os<br>import cv2<br>import numpy as np<br>from flask import Flask, render_template, send_from_directory<br>from flask_socketio import SocketIO, emit</pre><p>We use the Flask library to create an instance of the web application, and the Flask-SocketIO library to add support for real-time communication between the client and server.</p><p>Next, we create a Flask application and initialize the SocketIO object.</p><pre>app = Flask(__name__, static_folder=&quot;./templates/static&quot;)<br>app.config[&quot;SECRET_KEY&quot;] = &quot;secret!&quot;<br>socketio = SocketIO(app)</pre><p>We set a secret key for the Flask application, which is used to sign session cookies. We then initialize the SocketIO object with our Flask application.</p><p>Next, we define a helper function that will convert a base64-encoded image to a NumPy array that can be processed using OpenCV.</p><pre>def base64_to_image(base64_string):<br>    # Extract the base64 encoded binary data from the input string<br>    base64_data = base64_string.split(&quot;,&quot;)[1]<br>    # Decode the base64 data to bytes<br>    image_bytes = base64.b64decode(base64_data)<br>    # Convert the bytes to numpy array<br>    image_array = np.frombuffer(image_bytes, dtype=np.uint8)<br>    # Decode the numpy array as an image using OpenCV<br>    image = cv2.imdecode(image_array, cv2.IMREAD_COLOR)<br>    return image</pre><p>This function takes a base64-encoded string as input, extracts the binary data, decodes it to bytes, and converts it to a NumPy array. Finally, it decodes the NumPy array as an image using OpenCV and returns the resulting image.</p><p>Next, we define a function to handle incoming connections from the client.</p><pre>@socketio.on(&quot;connect&quot;)<br>def test_connect():<br>    print(&quot;Connected&quot;)<br>    emit(&quot;my response&quot;, {&quot;data&quot;: &quot;Connected&quot;})</pre><p>This function is called whenever a client connects to the server. It simply prints a message to the console and sends a “my response” event back to the client with the message “Connected”.</p><p>We then define a function to handle incoming images from the client.</p><pre>@socketio.on(&quot;image&quot;)<br>def receive_image(image):<br>    # Decode the base64-encoded image data<br>    image = base64_to_image(image)<br><br>    # Perform image processing using OpenCV<br>    gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)<br>    frame_resized = cv2.resize(gray, (640, 360))<br><br>    # Encode the processed image as a JPEG-encoded base64 string<br>    encode_param = [int(cv2.IMWRITE_JPEG_QUALITY), 90]<br>    result, frame_encoded = cv2.imencode(&quot;.jpg&quot;, frame_resized, encode_param)<br>    processed_img_data = base64.b64encode(frame_encoded).decode()<br><br>    # Prepend the base64-encoded string with the data URL prefix<br>    b64_src = &quot;data:image/jpg;base64,&quot;<br>    processed_img_data = b64_src + processed_img_data<br><br>    # Send the processed image back to the client<br>    emit(&quot;processed_image&quot;, processed_img_data)</pre><p>This function is called whenever an “image” event is received from the client. It first decodes the base64-encoded image data using the base64_to_image helper function we defined earlier.</p><p>Next we run the application:</p><pre>if __name__ == &quot;__main__&quot;:<br>    socketio.run(app, debug=True, port=5000, host=&#39;0.0.0.0&#39;)</pre><p>Here’s the complete python code</p><pre>import base64<br>import os<br><br>import cv2<br>import numpy as np<br>from flask import Flask, render_template, send_from_directory<br>from flask_socketio import SocketIO, emit<br><br>app = Flask(__name__, static_folder=&quot;./templates/static&quot;)<br>app.config[&quot;SECRET_KEY&quot;] = &quot;secret!&quot;<br>socketio = SocketIO(app)<br><br><br>@app.route(&quot;/favicon.ico&quot;)<br>def favicon():<br>    return send_from_directory(<br>        os.path.join(app.root_path, &quot;static&quot;),<br>        &quot;favicon.ico&quot;,<br>        mimetype=&quot;image/vnd.microsoft.icon&quot;,<br>    )<br><br><br>def base64_to_image(base64_string):<br>    # Extract the base64 encoded binary data from the input string<br>    base64_data = base64_string.split(&quot;,&quot;)[1]<br>    # Decode the base64 data to bytes<br>    image_bytes = base64.b64decode(base64_data)<br>    # Convert the bytes to numpy array<br>    image_array = np.frombuffer(image_bytes, dtype=np.uint8)<br>    # Decode the numpy array as an image using OpenCV<br>    image = cv2.imdecode(image_array, cv2.IMREAD_COLOR)<br>    return image<br><br><br>@socketio.on(&quot;connect&quot;)<br>def test_connect():<br>    print(&quot;Connected&quot;)<br>    emit(&quot;my response&quot;, {&quot;data&quot;: &quot;Connected&quot;})<br><br><br>@socketio.on(&quot;image&quot;)<br>def receive_image(image):<br>    # Decode the base64-encoded image data<br>    image = base64_to_image(image)<br><br>    gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)<br><br>    frame_resized = cv2.resize(gray, (640, 360))<br><br>    encode_param = [int(cv2.IMWRITE_JPEG_QUALITY), 90]<br><br>    result, frame_encoded = cv2.imencode(&quot;.jpg&quot;, frame_resized, encode_param)<br><br>    processed_img_data = base64.b64encode(frame_encoded).decode()<br><br>    b64_src = &quot;data:image/jpg;base64,&quot;<br>    processed_img_data = b64_src + processed_img_data<br><br>    emit(&quot;processed_image&quot;, processed_img_data)<br><br><br>@app.route(&quot;/&quot;)<br>def index():<br>    return render_template(&quot;index.html&quot;)<br><br><br>if __name__ == &quot;__main__&quot;:<br>    socketio.run(app, debug=True, port=5000, host=&#39;0.0.0.0&#39;)</pre><p>With both the Python and JavaScript code in place, we can start the Flask server and test the application by visiting http://localhost:5000 in a web browser. If everything is set up correctly, we should be able to see a live video stream from the webcam, which is being processed in real-time by the Python code running on the server.</p><h3>Conclusion</h3><p>in conclusion, we have seen how to perform real-time image processing using the client’s webcam and Python Flask as the backend server. We used JavaScript to capture the video stream from the user’s camera and send it to the server for processing. On the server side, we decoded the image data using OpenCV and performed some image processing operations on it. Finally, we encoded the processed image data and sent it back to the client to display on the web page.</p><p>Real-time image processing has numerous applications, such as face detection, object tracking, and augmented reality. By using the techniques and tools demonstrated in this tutorial, you can build powerful web applications that perform complex image processing tasks in real-time.</p><h4>References</h4><ul><li><a href="https://stackoverflow.com/questions/63701979/how-can-i-capture-camera-feeds-from-browser-and-send-to-flask-server">How can I capture camera feeds from browser and send to flask server</a></li><li><a href="https://pyshine.com/Online-Video-Processing-From-Client-Camera/">How to perform online video processing from the client&#39;s camera</a></li><li><a href="https://stackoverflow.com/questions/3715493/encoding-an-image-file-with-base64">Encoding an image file with base64</a></li></ul><p>You made it to the end of the article! Thanks for reading and hope you learned a lot, If You Like My Content and Want To Connect with me You can do that by:</p><ol><li>Following Me On <a href="https://medium.com/@ifeanyinneji777"><em>Medium</em>.</a></li><li>Connecting With Me On <a href="https://www.linkedin.com/in/ifeanyi-nneji"><em>LinkedIn</em></a><em> and on</em><a href="https://twitter.com/Neji_14"><em> Twitter</em></a>.</li><li>Checking out my work on <a href="https://github.com/Nneji123">GitHub</a>.</li></ol><p><em>More content at </em><a href="https://plainenglish.io/"><strong><em>PlainEnglish.io</em></strong></a><em>.</em></p><p><em>Sign up for our </em><a href="http://newsletter.plainenglish.io/"><strong><em>free weekly newsletter</em></strong></a><em>. Follow us on </em><a href="https://twitter.com/inPlainEngHQ"><strong><em>Twitter</em></strong></a>, <a href="https://www.linkedin.com/company/inplainenglish/"><strong><em>LinkedIn</em></strong></a><em>, </em><a href="https://www.youtube.com/channel/UCtipWUghju290NWcn8jhyAw"><strong><em>YouTube</em></strong></a><em>, and </em><a href="https://discord.gg/GtDtUAvyhW"><strong><em>Discord</em></strong></a><strong><em>.</em></strong></p><p><strong><em>Interested in scaling your software startup</em></strong><em>? Check out </em><a href="https://circuit.ooo/?utm=publication-post-cta"><strong><em>Circuit</em></strong></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=97fb4a0a764f" width="1" height="1" alt=""><hr><p><a href="https://python.plainenglish.io/real-time-image-processing-using-websockets-and-flask-in-python-and-javascript-97fb4a0a764f">Real-Time Image Processing using WebSockets and Flask in Python and JavaScript</a> was originally published in <a href="https://python.plainenglish.io/">Python in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[5 key skills every data scientist should have]]></title>
            <link>https://medium.com/@ifeanyinneji777/5-key-skills-every-data-scientist-should-have-e2825931d167?source=rss-eb428365def4------2</link>
            <guid isPermaLink="false">https://medium.com/p/e2825931d167</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[statistics]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Ifeanyi Nneji]]></dc:creator>
            <pubDate>Wed, 14 Dec 2022 06:10:53 GMT</pubDate>
            <atom:updated>2022-12-14T06:10:53.343Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wV0ZQqz_-rBw3ewFebFBtQ.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@kmuza?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Carlos Muza</a> on <a href="https://unsplash.com/s/photos/data?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>As the field of data science continues to grow and evolve, it’s important for aspiring data scientists to possess a set of key skills that will enable them to succeed in their careers. While the specific skills required may vary depending on the specific job or industry, there are a few core competencies that are essential for all data scientists.</p><ol><li>Strong mathematical and statistical knowledge. Data science is a highly quantitative field, and as such, a strong foundation in math and statistics is essential. This includes a deep understanding of probability, statistics, algebra, and calculus, as well as the ability to apply these concepts to real-world data sets.</li><li>Proficiency in programming. Data scientists often work with large and complex data sets, and as such, they need to be able to write efficient and effective code to clean, manipulate, and analyze that data. This typically involves proficiency in one or more programming languages, such as Python, R, or SQL.</li><li>The ability to effectively visualize and present data. One of the key roles of a data scientist is to take complex data sets and distill them into clear and concise visualizations that can be easily understood by a non-technical audience. This requires a strong understanding of data visualization principles and the ability to use specialized tools and software, such as Tableau or D3.js.</li><li>Strong problem-solving skills. Data science involves a lot of trial and error, and data scientists need to be able to approach problems in a structured and logical way. This includes being able to identify the right data to use, choosing the appropriate analytical techniques, and iterating on solutions until they are optimized.</li><li>Domain expertise. While strong technical skills are essential for data scientists, they are not enough on their own. In order to truly be effective, data scientists also need to have a deep understanding of the specific industry or domain they are working in. This might include knowledge of economics, healthcare, finance, or any other field that generates large amounts of data.</li></ol><p>In addition to these core competencies, there are a few other skills that can be helpful for data scientists to have. For example, proficiency in machine learning algorithms can be useful for working with more advanced data sets, and strong communication skills are essential for presenting findings to stakeholders.</p><h4>CONCLUSION</h4><p>Overall, the key skills for data scientists are a combination of strong technical abilities and domain expertise. By developing these skills and staying up-to-date on the latest developments in the field, data scientists can position themselves for success in their careers.</p><p>You made it to the end of the article! Thanks for reading and hope you learned a lot, If You Like My Content and Want To Connect with me You can do that by:</p><ol><li>Following Me On <a href="https://medium.com/@ifeanyinneji777"><em>Medium</em>.</a></li><li>Connecting With Me On <a href="https://www.linkedin.com/in/ifeanyi-nneji"><em>LinkedIn</em></a><em> and on</em><a href="https://twitter.com/Neji_14"><em> Twitter</em></a>.</li><li>Checking out my work on <a href="https://github.com/Nneji123">GitHub</a>.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e2825931d167" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Exploring the Power of ChatGPT]]></title>
            <link>https://faun.pub/exploring-the-power-of-chatgpt-6d87e602ef61?source=rss-eb428365def4------2</link>
            <guid isPermaLink="false">https://medium.com/p/6d87e602ef61</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[naturallanguageprocessing]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Ifeanyi Nneji]]></dc:creator>
            <pubDate>Fri, 09 Dec 2022 18:10:11 GMT</pubDate>
            <atom:updated>2022-12-09T18:10:11.477Z</atom:updated>
            <content:encoded><![CDATA[<h3>A Natural Language Processing Model for Conversational Applications</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wi-Dp-k6q_2nr0m_LrWkeg.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@possessedphotography?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Possessed Photography</a> on <a href="https://unsplash.com/?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>ChatGPT is a natural language processing (NLP) model developed by OpenAI. It is a variant of the GPT-3 language model that has been specifically trained to generate human-like responses in a conversational context.</p><p>One of the key features of ChatGPT is its ability to generate responses that are contextually appropriate and coherent. This means that when given a prompt or a conversation history, ChatGPT is able to generate responses that are relevant to the topic and flow naturally with the rest of the conversation.</p><p>For example, if you were to ask ChatGPT about the weather, it might respond with something like “It’s currently sunny and warm. The forecast for the rest of the day is mostly clear with a slight chance of showers in the afternoon.”</p><p>Another key feature of ChatGPT is its ability to handle a wide range of topics and languages. It has been trained on a massive dataset of conversational data and can generate responses in multiple languages, including English, Spanish, and French.</p><p>To use ChatGPT, you can either use the pre-built model provided by OpenAI or fine-tune the model on your own dataset. If you choose to fine-tune the model, you will need to provide a large dataset of conversational data that is relevant to your specific use case. This will allow ChatGPT to learn the specific language and content that is relevant to your application.</p><p>Once you have trained or fine-tuned ChatGPT, you can use it to generate responses in real-time. For example, you could use ChatGPT in a chatbot application, where it would generate responses to user inputs in a conversational manner.</p><p>Overall, ChatGPT is a powerful NLP model that can generate human-like responses in a conversational context. It is highly versatile and can be fine-tuned to handle a wide range of topics and languages. By using ChatGPT, you can develop chatbot applications and other conversational systems that provide a more natural and engaging user experience.</p><h4><strong>How to use ChatGPT</strong></h4><p>To use ChatGPT, you can either use the pre-built model provided by OpenAI or fine-tune the model on your own dataset. If you choose to fine-tune the model, you will need to provide a large dataset of conversational data that is relevant to your specific use case. This will allow ChatGPT to learn the specific language and content that is relevant to your application.</p><p>Here is an example of how you might fine-tune ChatGPT in Python using the openai library:</p><pre>import openai<br><br># Set your OpenAI API key<br>openai.api_key = &quot;YOUR_API_KEY&quot;<br><br># Load the ChatGPT model<br>model = openai.Model.get(&quot;chatbot-001&quot;)<br><br># Fine-tune the model on your own dataset<br>model.engine = &quot;text-davinci-002&quot;<br>model.train([<br>    &quot;Hi, how are you?&quot;,<br>    &quot;I&#39;m good, thanks for asking. How about you?&quot;,<br>    &quot;I&#39;m doing well too. Thanks for asking.&quot;,<br>    &quot;That&#39;s great to hear. What do you like to do in your free time?&quot;,<br>    &quot;I enjoy reading, hiking, and spending time with my family.&quot;,<br>    &quot;That sounds like a lot of fun. What kind of books do you like to read?&quot;,<br>    &quot;I enjoy reading sci-fi and fantasy novels, as well as non-fiction books about science and technology.&quot;<br>])<br><br># Save the fine-tuned model<br>model.save(&quot;chatbot-001-fine-tuned&quot;)</pre><p>This code uses the openai library to fine-tune the ChatGPT model on a small dataset of conversational data. The code first sets the API key for the OpenAI API and then loads the pre-built ChatGPT model.</p><p>Next, the code fine-tunes the model on the provided dataset using the text-davinci-002 engine. This allows the model to learn the specific language and content of the dataset and generate more relevant and coherent responses.</p><h4>Conclusion</h4><p>In conclusion, ChatGPT is a powerful natural language processing model that can generate human-like responses in a conversational context. Its ability to generate contextually appropriate and coherent responses, as well as its versatility in handling a wide range of topics and languages, make it a valuable tool for developing chatbot applications and other conversational systems. By using ChatGPT, you can create more natural and engaging user experiences for your users.</p><p>You made it to the end of the article! Thanks for reading and hope you learned a lot, If You Like My Content and Want To Connect with me You can do that by:</p><ol><li>Following Me On <a href="https://medium.com/@ifeanyinneji777"><em>Medium</em>.</a></li><li>Connecting With Me On <a href="https://www.linkedin.com/in/ifeanyi-nneji"><em>LinkedIn</em></a><em> and on</em><a href="https://twitter.com/Neji_14"><em> Twitter</em></a>.</li><li>Checking out my work on <a href="https://github.com/Nneji123">GitHub</a>.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*QmSznOENhiJ-Z-wT.png" /></figure><h4>👋 If you find this helpful, please click the clap 👏 button below a few times to show your support for the author 👇</h4><h4>🚀<a href="http://from.faun.to/r/8zxxd">Join FAUN Developer Community &amp; Get Similar Stories in your Inbox Each Week</a></h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6d87e602ef61" width="1" height="1" alt=""><hr><p><a href="https://faun.pub/exploring-the-power-of-chatgpt-6d87e602ef61">Exploring the Power of ChatGPT</a> was originally published in <a href="https://faun.pub/">FAUN.dev() 🐾</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Deploy a Machine Learning API on AWS Lightsail]]></title>
            <link>https://aws.plainenglish.io/how-to-deploy-a-machine-learning-api-on-aws-lightsail-151052470b7d?source=rss-eb428365def4------2</link>
            <guid isPermaLink="false">https://medium.com/p/151052470b7d</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[deployment]]></category>
            <dc:creator><![CDATA[Ifeanyi Nneji]]></dc:creator>
            <pubDate>Mon, 12 Sep 2022 13:40:35 GMT</pubDate>
            <atom:updated>2022-09-12T13:40:35.931Z</atom:updated>
            <content:encoded><![CDATA[<h4>Deploy Hugging Face Transformer Models with FastAPI and AWS Lightsail</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ilLMXuX1ua32-xzv37JsSg.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@casparrubin?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Caspar Camille Rubin</a> on <a href="https://unsplash.com/s/photos/cloud-computing?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>In this article, I will explain in detail how to use Hugging Face Transformer models and how to wrap and deploy them as APIs with FastAPI, Docker and AWS Lightsail.</p><h4>What is Hugging Face?</h4><p>Hugging Face is a community and data science platform that provides:</p><ul><li>Tools that enable users to build, train and deploy ML models based on open source (OS) code and technologies.</li><li>A place where a broad community of data scientists, researchers, and ML engineers can come together and share ideas, get support and contribute to open source projects.</li></ul><h4>What are Hugging Face Transformers?</h4><p>Transformers provides APIs to easily download and train state-of-the-art pretrained models. Using pretrained models can reduce your compute costs, carbon footprint, and save you time from training a model from scratch. The models can be used across different modalities such as:</p><ul><li>📝 Text: text classification, information extraction, question answering, summarization, translation, and text generation in over 100 languages.</li><li>🖼️ Images: image classification, object detection, and segmentation.</li><li>🗣️ Audio: speech recognition and audio classification.</li><li>🐙 Multimodal: table question answering, optical character recognition, information extraction from scanned documents, video classification, and visual question answering.</li></ul><h4>About the Model</h4><p>In this tutorial I’ll be using a transformer model namely the <strong>microsoft/dit-base-finetuned-rvlcdip </strong>model.</p><p>The <strong>microsoft/dit-base-finetuned-rvlcdip </strong>model is Document Image Transformer (DiT) model pre-trained on IIT-CDIP, a dataset that includes 42 million document images and fine-tuned on <a href="https://www.cs.cmu.edu/~aharley/rvl-cdip/">RVL-CDIP</a>, a dataset consisting of 400,000 grayscale images in 16 classes, with 25,000 images per class. It was introduced in the paper <a href="https://arxiv.org/abs/2203.02378">DiT: Self-supervised Pre-training for Document Image Transformer</a> by Li et al. and first released in <a href="https://github.com/microsoft/unilm/tree/master/dit">this repository</a>. Note that DiT is identical to the architecture of <a href="https://huggingface.co/docs/transformers/model_doc/beit">BEiT</a>.</p><p>For more information about the model visit this <a href="https://huggingface.co/microsoft/dit-base-finetuned-rvlcdip">link.</a></p><h4>What is an API?</h4><p>An <strong>application program interface (API)</strong> is a set of routines, protocols, and tools for building software applications. Basically, an API specifies how software components should interact.</p><h4>What is FastAPI?</h4><p><strong>FastAPI </strong>is a Web framework for developing <strong>RESTful APIs</strong> in Python. FastAPI is based on <strong>Pydantic</strong> and type hints to validate, serialize, and deserialize data, and automatically auto-generate <strong>OpenAPI </strong>documents. It fully supports asynchronous programming and can run with <strong>Uvicorn</strong> and<strong> Gunicorn</strong>.</p><p>You can check out these links on documentation of FastAPI and how it works 👇</p><blockquote><a href="https://fastapi.tiangolo.com/"><em>FastAPI (tiangolo.com)</em></a></blockquote><blockquote><a href="https://realpython.com/fastapi-python-web-apis/"><em>Using FastAPI to Build Python Web APIs — Real Python</em></a></blockquote><blockquote><a href="https://github.com/tiangolo/fastapi"><em>tiangolo/fastapi: FastAPI framework, high performance, easy to learn, fast to code, ready for production (github.com)</em></a></blockquote><h4>Why FastAPI?</h4><p>Reasons for using FastAPI:</p><ul><li><strong>Fast</strong>: Very high performance, on par with <strong>NodeJS</strong> and <strong>Go</strong> (thanks to Starlette and Pydantic). <a href="https://fastapi.tiangolo.com/#performance">One of the fastest Python frameworks available</a>.</li><li><strong>Fast to code</strong>: Increase the speed to develop features by about 200% to 300%. *</li><li><strong>Fewer bugs</strong>: Reduce about 40% of human (developer) induced errors. *</li><li><strong>Intuitive</strong>: Great editor support. Completion everywhere. Less time debugging.</li><li><strong>Easy</strong>: Designed to be easy to use and learn. Less time reading docs.</li><li><strong>Short</strong>: Minimize code duplication. Multiple features from each parameter declaration. Fewer bugs.</li><li><strong>Robust</strong>: Get production-ready code. With automatic interactive documentation.</li><li><strong>Standards-based</strong>: Based on (and fully compatible with) the open standards for APIs: <a href="https://github.com/OAI/OpenAPI-Specification">OpenAPI</a> (previously known as Swagger) and <a href="https://json-schema.org/">JSON Schema</a>.</li></ul><h4>What is Docker?</h4><p>Docker is an open source containerization platform. It <strong>enables us topackage applications into containers</strong> — standardized executable components combining application source code with the operating system (OS) libraries and dependencies required to run that code in any environment.</p><h4>What is Docker Compose?</h4><p>Docker Compose is <strong>a tool that was developed to help define and share multi-container applications</strong>. With Compose, we can create a YAML file to define the services and with a single command, can spin everything up or tear it all down.</p><p>More information about Docker and docker-compose can be found below 👇</p><blockquote><a href="https://www.docker.com/"><em>https://www.docker.com/</em></a></blockquote><blockquote><a href="https://docs.docker.com/compose/"><em>https://docs.docker.com/compose/</em></a></blockquote><h4>About AWS Lightsail</h4><p>Amazon Lightsail is <strong>a virtual private server (VPS) provider</strong> and is the easiest way to get started with AWS for developers, small businesses, students, and other users who need a solution to build and host their applications on cloud.</p><h3>Development Environment</h3><p>I’ll be using Gitpod as my development environment for this project.</p><p>Gitpod is <em>an open source developer platform automating the provisioning of ready-to-code developer environments</em>. Gitpod continuously builds your git branches like a CI server so that you can start coding right away — no more waiting for dependencies to download and builds to finish.</p><p>Before you can use Gitpod you need to sign up and then login so you can create and access a Gitpod Workspace. Follow the link below to sign up and login</p><blockquote><a href="https://gitpod.io/">https://gitpod.io/</a></blockquote><blockquote><a href="https://www.gitpod.io/docs/getting-started">https://www.gitpod.io/docs/getting-started</a></blockquote><p>You can go to the repository below to clone the source code for this tutorial. The repository also contains a gitpod link so you can immediately start working with the project files.</p><blockquote><a href="https://github.com/Nneji123/Deploy-ML-Models-using-FastAPI-and-AWS-Lightsail">https://github.com/Nneji123/How-to-Deploy-Machine-Learning-Models-with-FastAPI-and-AWS-Lightsail</a></blockquote><h3>Project File Structure</h3><p>The repository file structure is given below:</p><pre>├── app.py<br>├── docker-compose.yml<br>├── Dockerfile<br>├── download.py<br>├── LICENSE<br>├── README.md<br>├── requirements.txt<br>└── utils.py</pre><h4>app.py</h4><p>This file contains the important source code for building and running our FastAPI application. This is what the file contains:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/685afeb4a6747bff3149d3f4b2c834eb/href">https://medium.com/media/685afeb4a6747bff3149d3f4b2c834eb/href</a></iframe><p>The API has three endpoints;</p><ol><li>The GET endpoint ‘/’ which is just the homepage.</li><li>The ‘/document-classifier’ endpoint. This endpoint takes a PDF file as input and then returns a JSON response with the classes the PDF file belongs to.</li><li>The ‘/classify-image’ endpoint. This endpoint takes an image file as input and then returns a JSON response with the classes the image file belongs to.</li></ol><h4>docker-compose.yml</h4><p>A docker-compose. yml is <strong>a config file for Docker Compose</strong>. It allows to deploy, combine, and configure multiple docker containers at the same time. In this case I used it to run the Docker container for the project locally.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/33bb2e5d29979057f3b2c7717008b132/href">https://medium.com/media/33bb2e5d29979057f3b2c7717008b132/href</a></iframe><h4>Dockerfile</h4><p>The Dockerfile contains all the commands needed to to build and run our Docker image.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e6f3d65d9790c086cb6430b1bf8fb1cc/href">https://medium.com/media/e6f3d65d9790c086cb6430b1bf8fb1cc/href</a></iframe><p>The Dockerfile above performs the following steps:</p><ol><li>Grabs the python:3.8.13-slim-bullseye image from Docker hub. This is called the <strong>base image.</strong></li><li>Creates a work directory called <strong>app.</strong></li><li>Installs the poppler-utils package. This package is needed by Linux in order for us to work with and manipulate PDF files.</li><li>Upgrades the setuptools library.</li><li>Installs the CPU version of Pytorch and other requirements.</li><li>Copies all the files from our current directory to the Docker builder.</li><li>Exposes the port 8000. This is a very important step that allows our container to be visible on AWS Lightsail.</li><li>Runs the download.py file.</li><li>Launches the FastAPI application using uvicorn.</li></ol><h4>download.py</h4><p>This file downloads the pre-trained model from Hugging Face.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fe661635274dd3b141f3b3a1c652d813/href">https://medium.com/media/fe661635274dd3b141f3b3a1c652d813/href</a></iframe><h4>requirements.txt</h4><p>This file contains the necessary requirements for our API.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e03251e013067449f07f17550472b559/href">https://medium.com/media/e03251e013067449f07f17550472b559/href</a></iframe><h4>utils.py</h4><p>This file contains the functions that generate the classifications for the PDF and image files.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/510943ee91c70edfba7905445a02daf8/href">https://medium.com/media/510943ee91c70edfba7905445a02daf8/href</a></iframe><h3>How to run the API</h3><p>Now that we’re done with creating our files, the next step is to run the application. To build and run the application we’ll be using docker compose.</p><p>Run the command below in your terminal to build and run the application:</p><pre>docker-compose up -d --build</pre><p>The -d flag builds and runs the Docker container in detached mode i.e you wouldn’t be able to view the logs. The --build flag builds the Docker image and the up flag starts the container.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R4W21XglHCeLo1NHZKwTqA.png" /><figcaption>Screenshot by Author: Building the Docker Image with Docker Compose</figcaption></figure><h3>API Demo</h3><p>The video below demonstrates how the application works. The application is running on port 8080 from the Gitpod Environment.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FzkQzxtxslAE%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DzkQzxtxslAE&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FzkQzxtxslAE%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/c74087c9ac727455239e006c65e92d4a/href">https://medium.com/media/c74087c9ac727455239e006c65e92d4a/href</a></iframe><h3>Pushing the Docker Image to Docker Hub</h3><p>Before we deploy the API on AWS Lightsail we have to build and push the Docker image to Docker hub so we can specify it when configuring the Lightsail requirements. To build and push the Docker image, perform the steps below:</p><ol><li>Signup/Login to Docker Hub using the terminal.</li></ol><p>If you don’t have a Docker Hub account, navigate to this <a href="http://hub.docker.com/">site</a> and sign up so you can login to docker hub from the terminal.</p><p>docker login or docker login -u username -p password</p><p>Replace username with your actual username and password with your actual password from Docker Hub.</p><p>2. Build and push the Docker image to Docker Hub</p><pre>docker build -t username/imagename .<br>docker push username/imagename</pre><p>Replace username with your Docker Hub username and imagename with any name you want. For example, in my case the commands will look like:</p><pre>docker build -t nneji123/doc-classifier .<br>docker push nneji123/doc-classifier</pre><p>After carrying out the above steps your image should be available on Docker Hub. My Docker image is available <a href="https://hub.docker.com/repository/docker/nneji123/doc-classifier">here</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZxkutfKs8NT08f0bUYEF0g.png" /><figcaption>Screenshot by Author: Pushing Image to Docker Hub</figcaption></figure><h3>Deploying the API on AWS LightSail</h3><p>The next step is to deploy the API on AWS LightSail. To do this, follow and perform the steps below:</p><ol><li>Navigate to <a href="https://aws.amazon.com/">https://aws.amazon.com</a> to login or signup to AWS.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qyh35ZN9zm4dXNCIakIBMQ.png" /><figcaption>Screenshot by Author: AWS Homepage</figcaption></figure><p>2. After you’ve logged in to AWS, navigate to the LightSail <a href="http://lightsail.aws.amazon.com/">homepage</a> and create a new container service as shown in the image below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CwKQiVSqSXPQonMHS0_vHA.png" /><figcaption>Screenshot by Author: Create container service</figcaption></figure><p>3. After clicking on <strong>create container service, </strong>choose the scale and specify a custom deployment.</p><p>4. Type in your desired container name, your image(the docker image that was uploaded to Docker Hub earlier), and ports and protocol(8000 and HTTP respectively).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eUzh5mYnhulp_n18SrVjBg.png" /><figcaption>Screenshot by Author: Setting up Lightsail Deployment</figcaption></figure><p>5. Choose a public endpoint and then click on<strong> create on container service</strong> to deploy the application.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NkZ7KS-sZZsOMRs7i3ikkA.png" /><figcaption>Screenshot by Author: Choose Public Endpoint</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m10oxgkSWk2t2isT8jKAQA.gif" /><figcaption>GIF by Author: AWS Lightsail Deployment Summary</figcaption></figure><h3>Final Steps</h3><p>We’re almost done! The final step is to check if the application was deployed successfully and running without any errors. To do this, you can check the logs or navigate to the container link created by Lightsail like in the image below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1022/1*sesVQeUqC702KOEx24Z88Q.png" /><figcaption>Screenshot by Author: Document Classifier logs on AWS Lightsail</figcaption></figure><p>As you can see from the above image, our application was built and is running successfully. You can now test the endpoint if it works.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*KyDVITBwj8VgnRDylbtF5g.gif" /><figcaption>GIF by Author: Document Classifier running on AWS LightSail</figcaption></figure><h3>Conclusion</h3><p>In conclusion, we were able to utilise a pretrained hugging face transformer model that can classify documents into various categories and deploy the model as an API with FastAPI, Docker and AWS Lightsail.</p><h3>References</h3><ul><li><a href="https://testdriven.io/blog/fastapi-streamlit/">Serving a Machine Learning Model with FastAPI and Streamlit</a></li><li><a href="https://aws.amazon.com/lightsail/faq/">Virtual Private Server and Web Hosting - Amazon Lightsail FAQs - Amazon Web Services</a></li><li><a href="https://huggingface.co/">Hugging Face - The AI community building the future.</a></li></ul><p>You made it to the end of the article! Thanks for reading and hope you learned a lot, If You Like My Content and Want To Connect with me You can do that by:</p><ol><li>Following Me On <a href="https://medium.com/@ifeanyinneji777"><em>Medium</em>.</a></li><li>Connecting With Me On <a href="https://www.linkedin.com/in/ifeanyi-nneji"><em>LinkedIn</em></a><em> and on</em><a href="https://twitter.com/Neji_14"><em> Twitter</em></a>.</li><li>Checking out my work on <a href="https://github.com/Nneji123">GitHub</a>.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=151052470b7d" width="1" height="1" alt=""><hr><p><a href="https://aws.plainenglish.io/how-to-deploy-a-machine-learning-api-on-aws-lightsail-151052470b7d">How to Deploy a Machine Learning API on AWS Lightsail</a> was originally published in <a href="https://aws.plainenglish.io/">AWS in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Run VS Code Server with Google Colab]]></title>
            <link>https://python.plainenglish.io/how-to-run-vs-code-server-with-google-colab-2f902d8fa4f5?source=rss-eb428365def4------2</link>
            <guid isPermaLink="false">https://medium.com/p/2f902d8fa4f5</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[vscode]]></category>
            <category><![CDATA[colab]]></category>
            <dc:creator><![CDATA[Ifeanyi Nneji]]></dc:creator>
            <pubDate>Mon, 12 Sep 2022 12:16:58 GMT</pubDate>
            <atom:updated>2022-09-12T12:16:58.499Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2A2zR_BWfgaRHx6_ila13w.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@ricaros?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Danial Igdery</a> on <a href="https://unsplash.com/s/photos/programmer?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>Colaboratory, Google Colab or “Colab” for short, is a product from Google Research. Colab <strong>allows anybody to write and execute arbitrary python code through the browser</strong>, and is especially well suited to machine learning, data analysis and education.</p><p>Visual Studio Code, also commonly referred to as VS Code, is a source-code editor made by Microsoft for Windows, Linux, and macOS. Features include support for debugging, syntax highlighting, intelligent code completion, snippets, code refactoring, and embedded Git</p><p>Data scientists or Python developers/programmers may already be familiar with Google Colab.</p><p>However, did you know that you may install Visual Studio Code on Google Colab and use it in the same way as on your local machine?</p><p><strong>In this article, you will learn:</strong></p><ol><li>How to set up the Python Colab code package.</li><li>Installing and running VS Code (code server).</li><li>how to get to VS Code online.</li><li>Opening the terminal.</li><li>How to execute a Python script.</li></ol><h3>Open Colab Notebook</h3><p>The first step is to launch a new Colab notebook in your Google Colab. You can rename the file as you want.</p><p>You can do this by going to <a href="https://colab.research.google.com/">https://colab.research.google.com/</a> and then creating a new notebook.</p><h3>Install colabcode Python package.</h3><p>To use Google Colab with VS Code (code server), you need to install the colabcode Python package. This is an awesome open-source Python package developed by <a href="https://github.com/abhishekkrthakur">Abhishek Thakur</a>.</p><p>To install the package, run the following command in your notebook cell:</p><pre>!pip install colabcode</pre><h3>Install and Authenticate Ngrok</h3><p><em>ngrok</em> is a globally distributed reverse proxy fronting your web services running in any cloud or private network, or your machine.</p><p>Before you can run the codeserver from your browser without getting errors you need to install and authenticate Ngrok with your colab instance. To do this you need to sign up for an ngrok account and get your authtoken. <strong>To sign up visit: </strong><a href="https://t.co/HBrF7zf18M"><strong>http://ngrok.com</strong></a></p><p>After signing up hit the sidebar and you’d see something like this in the picture.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*RQX7sHYl9Y_zY_LM.png" /><figcaption>Screenshot by Author: Retrieving Authtoken</figcaption></figure><p>Click on “Your Authtoken” then copy your token.</p><p>After you’ve completed the above steps run the code below in a new cell in your google colab instance:</p><pre>!wget https://bin.equinox.io/c/bNyj1mQVY4c/ngrok-v3-stable-linux-amd64.tgz<br>!tar -xvzf ngrok-v3-stable-linux-amd64.tgz<br>!ngrok authtoken your_authtoken</pre><p>Replace your_authtoken with your actual authtoken.</p><h3>Import ColabCode</h3><p>The next step is to import the ColabCode class from the package.</p><pre>from colabcode import ColabCode</pre><h3>Create an instance of ColabCode</h3><p>After importing ColabCode, you need to create an instance of ColabCode and set the following arguments:</p><ul><li><strong>port </strong>— The port you want to run the code-server on. For example port=10000</li><li><strong>password</strong> — You can set a password to protect your code-server from unauthorized access. This is an optional argument.</li><li><strong>mount_drive</strong> — If you want to use your Google drive. This is a Boolean argument which means you can set it to True or False. This is an optional argument.</li></ul><pre>ColabCode(port=10000) or <br>ColabCode(port=10000, password=&#39;mypassword&#39;, mount_drive=True)</pre><h3>Start the Code Server</h3><p>After running the ColabCode instance, it will start the server and show the link to access the code server.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YbGwTpkjtOoDSzUTRSvVlg.png" /><figcaption>Screenshot by Author: Running the ColabCode Ngrok Server</figcaption></figure><p>You need to click the link and it will open in a new tab.</p><p>You may now use a complete code editor and do various experiments on the Colab VM.</p><p>You can observe that the cell that executes the ColabCode instance is always running by looking at your Colab Notebook.<br>Close your Colab notebook only if you also wish to shut down the server that hosts VS Code.</p><p>In the image below, because I set my password I will have to type in my password before I can use the code-server. This is a nice feature if you want more security.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MqjRp2dhlu6Zm3cNirDMbw.png" /><figcaption>Screenshot by Author: code-server login page</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ru6_bEkYsi0SI4HxIV7AnA.png" /><figcaption>Screenshot by Author: VS Code Server Page</figcaption></figure><h3>Next Steps</h3><p>After launching the code server, use the following tips to help you start using VS Code on Google Colab.</p><ol><li>Launch your terminal:</li></ol><pre>Ctrl + `</pre><p>2. Change your theme</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DmAtyhDuOSsHUVFlYAPqNg.png" /><figcaption>Screenshot by Author: Change Theme</figcaption></figure><p>3. Run a simple python script</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*y1rdf5kuLtZ_41gQ1El5Og.png" /><figcaption>Screenshot by Author: Running a Simple Python Script</figcaption></figure><h3>Final Thoughts</h3><p>You have successfully finished reading this article!<br>I’m hoping you now know something new.<br>Take your coding to the next level by installing VS Code on Google Colab.</p><p>VS Code can also be run on the Kaggle platform using the colabcode Python package!</p><p>You made it to the end of the article! Thanks for reading and hope you learned a lot, If You Like My Content and Want To Connect with me You can do that by:</p><ol><li>Following Me On <a href="https://medium.com/@ifeanyinneji777"><em>Medium</em>.</a></li><li>Connecting With Me On <a href="https://www.linkedin.com/in/ifeanyi-nneji"><em>LinkedIn</em></a><em> and on</em><a href="https://twitter.com/Neji_14"><em> Twitter</em></a>.</li><li>Checking out my work on <a href="https://github.com/Nneji123">GitHub</a></li></ol><p><em>More content at </em><a href="https://plainenglish.io/"><strong><em>PlainEnglish.io</em></strong></a><em>. Sign up for our </em><a href="http://newsletter.plainenglish.io/"><strong><em>free weekly newsletter</em></strong></a><em>. Follow us on </em><a href="https://twitter.com/inPlainEngHQ"><strong><em>Twitter</em></strong></a>, <a href="https://www.linkedin.com/company/inplainenglish/"><strong><em>LinkedIn</em></strong></a><em>, </em><a href="https://www.youtube.com/channel/UCtipWUghju290NWcn8jhyAw"><strong><em>YouTube</em></strong></a><em>, and </em><a href="https://discord.gg/GtDtUAvyhW"><strong><em>Discord</em></strong></a><em>. Interested in Growth Hacking? Check out </em><a href="https://circuit.ooo/"><strong><em>Circuit</em></strong></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2f902d8fa4f5" width="1" height="1" alt=""><hr><p><a href="https://python.plainenglish.io/how-to-run-vs-code-server-with-google-colab-2f902d8fa4f5">How to Run VS Code Server with Google Colab</a> was originally published in <a href="https://python.plainenglish.io/">Python in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Elements of a Good Data Science Project]]></title>
            <link>https://medium.com/@ifeanyinneji777/elements-of-a-good-data-science-project-d7ef8911c02b?source=rss-eb428365def4------2</link>
            <guid isPermaLink="false">https://medium.com/p/d7ef8911c02b</guid>
            <category><![CDATA[ml-so-good]]></category>
            <category><![CDATA[projects]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Ifeanyi Nneji]]></dc:creator>
            <pubDate>Sat, 23 Jul 2022 21:26:08 GMT</pubDate>
            <atom:updated>2022-07-23T21:26:08.568Z</atom:updated>
            <content:encoded><![CDATA[<p>A brief article on what makes up a good Data Science Project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HeFz5z3SSpO-Pa7QVZVrSg.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@mjessier?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Myriam Jessier</a> on <a href="https://unsplash.com/s/photos/data-science?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>Watched this <a href="https://youtu.be/c4Af2FcgamA">video</a> some time ago and I can say it was really informative because he was talking from the perspective of an employer or hiring manager. He talked about what a complete data science project should/should not have or things you should and shouldn’t do when carrying out a project and these are what he listed:</p><ol><li>Don’t work with ready made datasets like datasets found from <a href="http://kaggle.com/">kaggle.com</a>. It’s better to find, clean and process data you pulled by yourself through webscraping or working with API’s. Personally I’ve done some webscraping using beautifulsoup4 and selenium. It’s better because you can get real time data instead of data that has already been cleaned by someone else and shows your employer that you can work with real world data.</li></ol><blockquote>You can read more about webscraping and working with API’s with these links: <a href="https://www.edureka.co/blog/web-scraping-with-python/">https://www.edureka.co/blog/web-scraping-with-python/</a> <a href="https://realpython.com/python-web-scraping-practical-introduction/">https://realpython.com/python-web-scraping-practical-introduction/</a></blockquote><ol><li>He also says you should be able to work with databases in the cloud such as GCP(Google Cloud Platform, AWS(Amazon Web Services, Microsoft Azure etc. Carrying out projects on the cloud gives you an edge because it shows employers that you have knowledge of the cloud and working with databases on the cloud which is an important requirement when working with “big data” like you would in the real world.</li><li><strong>Building models</strong>. Employers don’t want to know if you’re model is 99.99% accurate, they want to know your reasons behind using such model. Questions such as; Why did you pick your model?, How did you clean your data?, What are the assumptions made from your model?, How did you test your model?, Can you explain the math behind your model?, etc will come up and it’ll be good if you can answer such questions.</li><li><strong>Deploying your Project.</strong> He talks about deploying your project and this is very important because most people aren’t going to take you serious with just a notebook to show for your work😅. Learn how to deploy your project so it can used/viewed by others. You can deploy your project as a Web app using technologies like Streamlit, Django, Flask,FastAPI and you can host them on sites like Heroku, Streamlit cloud sharing, AWS(Amazon Web Services) etc. This will go a long way and show your employers that you can create models and also deploy models.</li></ol><blockquote>Links to some interesting projects with source code: <a href="https://github.com/Nneji123/Credit-Card-Fraud-Detection">https://github.com/Nneji123/Credit-Card-Fraud-Detection</a> <a href="https://github.com/Nneji123/Media-Recommendation-Engine">https://github.com/Nneji123/Media-Recommendation-Engine</a> <a href="https://github.com/Nneji123/Lung-Cancer-Detection">https://github.com/Nneji123/Lung-Cancer-Detection</a></blockquote><h4>Final Thoughts</h4><p>The most important thing is that whatever project you carry out, it should always be for the purpose of gaining insight or meaningful information because that’s what Data Science is about.</p><p>You made it to the end of the article! Thanks for reading and hope you learned a lot, If You Like My Content and Want To Connect with me You can do that by:</p><ol><li>Following Me On <a href="https://medium.com/@ifeanyinneji777"><em>Medium</em>.</a></li><li>Connecting With Me On <a href="https://www.linkedin.com/in/ifeanyi-nneji"><em>LinkedIn</em></a><em> and on</em><a href="https://twitter.com/Neji_14"><em> Twitter</em></a>.</li></ol><p><a href="https://medium.com/mlearning-ai/mlearning-ai-submission-suggestions-b51e2b130bfb">Mlearning.ai Submission Suggestions</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d7ef8911c02b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Data Science for Beginners]]></title>
            <link>https://medium.com/@ifeanyinneji777/data-science-for-beginners-8389fd6293ca?source=rss-eb428365def4------2</link>
            <guid isPermaLink="false">https://medium.com/p/8389fd6293ca</guid>
            <category><![CDATA[beginner]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[ml-so-good]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Ifeanyi Nneji]]></dc:creator>
            <pubDate>Thu, 07 Jul 2022 08:17:49 GMT</pubDate>
            <atom:updated>2022-07-07T08:17:49.842Z</atom:updated>
            <content:encoded><![CDATA[<p>A brief introduction to Data Science for Beginners</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eTt4AjMkfJhrcYjiTmHwwA.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@goumbik?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Lukas Blazek</a> on <a href="https://unsplash.com/collections/8358587/data-science?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>In this article I’ll be talking briefly about the following points:</p><ol><li>Meaning of Data Science</li><li>Processes involved in Data Science</li><li>Relevance of Data Science in Various Industries</li></ol><h3>Meaning of Data Science</h3><p><strong>Data science</strong> is the field of study that combines domain expertise, programming skills, and knowledge of mathematics and statistics to extract meaningful insights from data.</p><p><strong>Domain expertise</strong> could be in business, health, technology, engineering, finance etc. These are skills that you specialize in and use data to gain insight in those particular fields.</p><p><strong>Programming skills</strong> is your efficiency in working with a programming language e.g <em>Python, R, Julia</em>(these are most frequently used programming languages used by Data Scientists ) etc. Personally I use Python because of the many packages available and ease of writing programs.</p><p><strong>Mathematics and Statistics</strong> is important in Data Science because various mathematical and statistical models and algorithms are used to get insight from data e.g Linear Regression algorithm for regression tasks, Logistic regression for classification tasks etc.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*geEUTANhEQ14I8euv60rSA.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@markuswinkler?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Markus Winkler</a> on <a href="https://unsplash.com/s/photos/data-science?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>So in summary, Data science practitioners apply <a href="https://www.datarobot.com/wiki/machine-learning/">machine learning</a> <a href="https://www.datarobot.com/wiki/algorithm/">algorithms</a> to numbers, text, images, video, audio, and more to produce <a href="https://www.datarobot.com/wiki/artificial-intelligence/">artificial intelligence (AI)</a> systems to perform tasks that ordinarily require human intelligence. In turn, these systems generate <a href="https://www.datarobot.com/wiki/insights/">insights</a> which analysts and business users can translate into tangible business value.</p><h3>Processes involved in Data Science</h3><p>Data science projects involve a series of data collection and analysis steps. In an article that <a href="https://www.techtarget.com/searchbusinessanalytics/feature/The-data-science-process-6-key-steps-on-analytics-applications">describes the data science process</a>, Donald Farmer, principal of analytics consultancy TreeHive Strategy, outlined these six primary steps:</p><ol><li>Identify a business-related hypothesis to test.</li><li>Gather data and prepare it for analysis.</li><li>Experiment with different analytical models.</li><li>Pick the best model and run it against the data.</li><li>Present the results to business executives.</li><li>Deploy the model for ongoing use with fresh data.</li></ol><p>Data science, according to Farmer, is a scientific effort. He stated, however, that data science efforts in corporate companies “will always be most usefully focused on basic commercial realities” that can help the company. As a result, data scientists should work on projects with business stakeholders throughout the analytics lifecycle, according to him.</p><h3>Relevance of Data Science in Various Industries</h3><p>Jessica Stauth, managing director for data science in Fidelity Investments’ Fidelity Labs branch, said there’s “a very clear relationship” between data science effort and business results in an October 2020 webinar hosted by Harvard University’s Institute for Applied Computational Science. She mentioned improved ROI, sales growth, more effective operations, faster time to market, and increased customer involvement and satisfaction as potential company benefits.</p><p>One of the most significant advantages of data science is that it empowers and facilitates better decision-making. Organizations that invest in it can make business decisions based on verifiable, data-driven facts. Such data-driven decisions should, in theory, result in improved business performance, cost savings, and more efficient business processes and workflows.</p><p>Predictive modeling, pattern recognition, anomaly detection, classification, categorization, and sentiment analysis are some of the applications that data scientists work on, as well as the development of technologies like recommendation engines, personalization systems, and artificial intelligence (AI) tools like chatbots and autonomous vehicles and machines.</p><p>These applications power a wide range of business use cases, including the following:</p><ul><li>Customer service</li><li>Website personalization</li><li>Fraud detection</li><li>Risk management</li><li>Stock trading</li><li>Targeted advertising</li><li>Customer analytics</li><li>Speech recognition</li><li>Logistics and supply chain management</li><li>Processing of natural language</li><li>Cybersecurity</li><li>Medical evaluation</li><li>Maintenance planning</li><li>Image Recognition</li></ul><p>You made it to the end of the article! Thanks for reading and hope you learned a lot, If You Like My Content and Want To Connect with me You can do that by:</p><ol><li>Following Me On <a href="https://medium.com/@ifeanyinneji777"><em>Medium</em>.</a></li><li>Connecting With Me On <a href="https://www.linkedin.com/in/ifeanyi-nneji"><em>LinkedIn</em></a><em> and on</em><a href="https://twitter.com/Neji_14"><em> Twitter</em></a>.</li><li>Checking out my work on <a href="https://github.com/Nneji123">GitHub</a></li></ol><p><a href="https://medium.com/mlearning-ai/mlearning-ai-submission-suggestions-b51e2b130bfb">Mlearning.ai Submission Suggestions</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8389fd6293ca" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Credit Card Fraud Detection]]></title>
            <link>https://medium.com/@ifeanyinneji777/credit-card-fraud-detection-2527ca04c3de?source=rss-eb428365def4------2</link>
            <guid isPermaLink="false">https://medium.com/p/2527ca04c3de</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[ml-so-good]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[streamlit]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Ifeanyi Nneji]]></dc:creator>
            <pubDate>Tue, 21 Jun 2022 18:23:27 GMT</pubDate>
            <atom:updated>2022-06-22T05:26:42.968Z</atom:updated>
            <content:encoded><![CDATA[<h4>An End-to-end Machine Learning Project with Streamlit, FastAPI and Docker.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Zsvm31OqQNA9-nnsiTUNSQ.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@rupixen?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">rupixen.com</a> on <a href="https://unsplash.com/s/photos/credit-card?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><h3><strong>Introduction</strong></h3><h4>What is Credit card fraud?</h4><p>According to the <a href="https://www.law.cornell.edu/wex/credit_card_fraud#:~:text=Credit%20card%20fraud%20is%20a,or%20removing%20funds%20from%20it.">Legal Information Institute</a>:</p><blockquote>Credit card fraud is a form of identity theft that involves an unauthorized taking of another’s credit card information for the purpose of charging purchases to the account or removing funds from it.</blockquote><p>In this project, we will develop a machine learning model using classification algorithms and techniques to accurately detect if a credit card transaction is fraudulent or not. We will also deploy our model as an API using FastAPI and create a frontend interface using Streamlit to access our API.</p><p>If you want to check out the completed project and source code you can go to the link below:</p><p><a href="https://github.com/Nneji123/Credit-Card-Fraud-Detection.git">GitHub - Nneji123/Credit-Card-Fraud-Detection: Repository for the Credit Card Fraud Detection Paper Review for Group 3 Zummit Africa AI/ML Team.</a></p><h3>Project Outline</h3><p>These are the steps that will be carried out in this project:</p><ol><li>Data Sourcing</li><li>Data Analysis</li><li>Model Building</li><li>Model Evaluation</li><li>Deploying the model with FastAPI</li><li>Interfacing the API with Streamlit frontend</li><li>Combining the frontend and backend with docker-compose</li></ol><h3>Data Sourcing</h3><p>Publicly accessible datasets on financial services are scarce, particularly in the newly growing field of mobile money transfers. Many scholars, like us who conduct research in the field of fraud detection, value financial datasets. Because financial transactions are inherently private, there are no publicly accessible datasets, which contributes to the problem.</p><p>A synthetic dataset generated using the simulator called PaySim was used as the dataset for building the model used in this project. PaySim uses aggregated data from the private dataset to generate a synthetic dataset that resembles the normal operation of transactions and injects malicious behaviour to later evaluate the performance of fraud detection methods.</p><p><a href="https://www.kaggle.com/datasets/ealaxi/paysim1">Synthetic Financial Datasets For Fraud Detection</a></p><h4>Setting up our Environment</h4><p>We will be using <a href="https://research.google.com/colaboratory/">Google Colab</a> to carry out this project. Colab is a hosted Jupyter notebook service that requires no setup to use, while providing access free of charge to computing resources including GPUs.</p><p>To load our dataset using Google Colab, we will be using the Kaggle API to download the dataset. You can get access to the Kaggle API by creating a Kaggle account and downloading your Kaggle JSON authentication key.</p><blockquote><a href="https://research.google.com/colaboratory/">https://research.google.com/colaboratory/</a></blockquote><blockquote><a href="https://www.kaggle.com/general/74235">Easiest way to download kaggle data in Google Colab | Data Science and Machine Learning</a></blockquote><h4>Loading the Dataset</h4><p>We can now load the dataset with the Kaggle API by running the following code in another cells:</p><pre><strong>!</strong>pip install -q kaggle</pre><p>Upload your kaggle.json file using the kaggle API in Google Colab</p><pre><strong>from</strong> google.colab <strong>import</strong> files<br><br>files<strong>.</strong>upload()</pre><p>This cell creates a .kaggle hidden folder in our root directory and copies the kaggle.json file to that folder.</p><pre><strong>!</strong> mkdir ~/.kaggle<br><strong>!</strong> cp kaggle.json ~/.kaggle/<br><strong>!</strong> chmod 600 /root/.kaggle/kaggle.json</pre><p>This cell will download the dataset used for this project to the /content directory in your Google Colab instance and also unzip the csv file.</p><pre><strong>!</strong>kaggle datasets download -d ealaxi/paysim1<br><strong>!</strong>unzip /content/paysim1.zip</pre><p>After we’ve installed the requirements and loaded the data, we can then do some analysis on the dataset.</p><h3>Data Analysis</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2682bc95b0e9a39a58105a040be435d4/href">https://medium.com/media/2682bc95b0e9a39a58105a040be435d4/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/915/1*2ln73s_hBxgspioWV-bLNA.png" /><figcaption>Screenshot by Author: Loaded Data</figcaption></figure><p>We can see above that the dataset contains a total of 11 columns and more than 6 million rows.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2315f8391ff0a787a884848393bf68f9/href">https://medium.com/media/2315f8391ff0a787a884848393bf68f9/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KlSfiKkfs2OVSG6I0shvmg.png" /><figcaption>Screenshot by Author: Number of fraudulent cases.</figcaption></figure><p>The dataset is also highly imbalanced with only 0.12% of transactions tagged as fraudulent cases. Some workarounds can be done when working with imbalanced data such as:</p><ul><li>Synthetic Minority Oversampling Technique (SMOTE)</li><li>Undersampling</li></ul><p>But we won’t be applying any technique here for the sake of simplicity. You can read about SMOTE, undersampling and working with imbalanced data by checking out the links below;</p><ul><li><a href="https://medium.com/analytics-vidhya/credit-card-fraud-detection-how-to-handle-imbalanced-dataset-1f18b6f881">Credit Card Fraud Detection : How to handle Imbalanced Dataset</a></li><li><a href="https://machinelearningmastery.com/imbalanced-classification-with-the-fraudulent-credit-card-transactions-dataset/">Imbalanced Classification with the Fraudulent Credit Card Transactions Dataset - Machine Learning Mastery</a></li></ul><h4>Feature Engineering</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/935/1*uAiDi9gZArZlTpG4mr_GLw.png" /><figcaption>Screenshot by Author: Feature Selection</figcaption></figure><p>The image above shows the columns in the dataset. This is the description of each column:</p><ul><li>step column: Number of hours it took for a transaction to complete.</li><li>type column: Type of transaction that took place. There are 5 categories in this column namely; ‘PAYMENT’, ‘TRANSFER’, ‘CASH_OUT’, ‘DEBIT’, ‘CASH_IN’ .</li><li>nameOrig: Name/ID of the Sender.</li><li>oldbalanceOrg: Sender balance before the transaction took place.</li><li>newbalanceOrg: Sender balance after the transaction took place.</li><li>nameDest: Name/ID of the Recipient.</li><li>oldbalanceDest: Recipient balance before the transaction took place.</li><li>newbalanceDest: Recipient balance after the transaction took place.</li><li>isFraud: This is the transactions made by the fraudulent agents inside the simulation.</li><li>isFlaggedFraud: The business model aims to control massive transfers from one account to another and flags illegal attempts. An illegal attempt in this dataset is an attempt to transfer more than 200.000 in a single transaction.</li></ul><p>We will be dropping the ‘nameOrig’ and ’nameDest’ columns and also converting the ‘type’ column from categorical data to numerical data using label encoding.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/07162d58db8ec7b335ce0f1e1ec25487/href">https://medium.com/media/07162d58db8ec7b335ce0f1e1ec25487/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IYBRffLmKRHlCETxc-MeWA.png" /><figcaption>Screenshot by Author: Label Encoding</figcaption></figure><p>We will also be creating an “evaluate_model” function that will be used to get the metric scores of our models for evaluation. The metrics used are:</p><ul><li>Accuracy Score: Accuracy is a metric used in classification problems used to tell the percentage of accurate predictions. We calculate it by dividing the number of correct predictions by the total number of predictions.</li><li>Precision Score: Precision quantifies the number of positive class predictions that actually belong to the positive class.</li><li>Recall Score: Recall quantifies the number of positive class predictions made out of all positive examples in the dataset.</li><li>F1 Score: F-Measure or F1 Score provides a single score that balances both the concerns of precision and recall in one number.</li><li>Confusion Matrix: A confusion matrix is <strong>a technique for summarizing the performance of a classification algorithm</strong>. Classification accuracy alone can be misleading if you have an unequal number of observations in each class or if you have more than two classes in your dataset.</li></ul><blockquote><a href="https://neptune.ai/blog/performance-metrics-in-machine-learning-complete-guide#:~:text=Classification%20models%20have%20discrete%20output,it%20in%20a%20different%20way.">Performance Metrics in Machine Learning [Complete Guide] — neptune.ai</a></blockquote><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4b927b4909bef57b346013fd6c9ce151/href">https://medium.com/media/4b927b4909bef57b346013fd6c9ce151/href</a></iframe><h3>Model Building</h3><p>Seeing as this project tries to solve a classification problem(detecting whether or not a transaction was fraudulent), we will be building and evaluating a classification model for our credit card detection app.</p><p>You can read more about classification machine learning techniques with the links below:</p><blockquote><a href="https://www.edureka.co/blog/classification-in-machine-learning/#:~:text=In%20machine%20learning%2C%20classification%20is,recognition%2C%20document%20classification%2C%20etc.">Classification In Machine Learning | Classification Algorithms | Edureka</a></blockquote><blockquote><a href="https://machinelearningmastery.com/types-of-classification-in-machine-learning/">4 Types of Classification Tasks in Machine Learning (machinelearningmastery.com)</a></blockquote><h4>Logistic Regression</h4><p>Logistic regression <strong>estimates the probability of an event occurring, such as voted or didn’t vote, based on a given dataset of independent variables</strong>. Since the outcome is a probability, the dependent variable is bounded between 0 and 1.</p><p>We will split our dataset into training and testing sets and use the LogisticRegression function from Sci-Kit Learn library to predict the outcome of a credit card transaction.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f21bb991d62cf9a0174e695034bf6a40/href">https://medium.com/media/f21bb991d62cf9a0174e695034bf6a40/href</a></iframe><p>In the code snippet above;</p><ul><li>We set our X variable by dropping the ‘isFraud’ column because that is our target column.</li><li>The ‘isFraud’ column is subsequently assigned to our y variable.</li><li>The data was then divided into a training and testing set, and logistic regression was then applied to the training set.</li><li>Using the ‘evaluate model’ function we previously declared, we then evaluated the model.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/563/1*x45qiz8_wqI1cpVl8eli6A.png" /><figcaption>Image by Author: Logistic Regression</figcaption></figure><p>As shown in the above image the Logistic Regression model has a very high accuracy score but very low recall score.</p><p>Accuracy score is not a good metric for evaluating our model because the data is highly imbalanced and the model will tend to predict non-fraudulent cases more accurately than fraudulent cases because there are more of them in the dataset.</p><p>You can read more about evaluating model accuracy with the links below:</p><blockquote><a href="https://stats.stackexchange.com/questions/312780/why-is-accuracy-not-the-best-measure-for-assessing-classification-models">machine learning — Why is accuracy not the best measure for assessing classification models? — Cross Validated (stackexchange.com)</a></blockquote><blockquote><a href="https://medium.com/@KrishnaRaj_Parthasarathy/ml-classification-why-accuracy-is-not-a-best-measure-for-assessing-ceeb964ae47c">ML Classification-Why accuracy is not a best measure for assessing?? | by KRISHNA RAJ | Medium</a></blockquote><h4>Random Forest Classifier</h4><p>As the name suggests, Random Forest is <strong>a classifier that contains a number of decision trees on various subsets of the given dataset and takes the average to improve the predictive accuracy of that dataset</strong>.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/62d95ba1efd4677e54195dbe4c4b8db7/href">https://medium.com/media/62d95ba1efd4677e54195dbe4c4b8db7/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/462/1*ilWIHrccHu_iUs9oNAm6rQ.png" /><figcaption>Image by Author: Random Forest Classifier</figcaption></figure><p>We can see that the random forest classifier performs really well using the different metric evaluations. We can now go ahead and use this model for our web application.</p><h4>Saving our model</h4><p>We can now save our random forest model as a pickle file “.pkl” using joblib.</p><pre>import joblib<br>joblib.dump(rfc, &quot;credit_fraud.pkl&quot;)</pre><h3>Deploying our Model with FastAPI, Streamlit and Docker</h3><p>In this section, we will be deploying our saved model as an API using FastAPI and creating a frontend interface to get inputs from the user that will be used to make predictions on whether a credit card transaction is fraudulent or not. A Dockerfile and docker-compose file will also be used to compile our project.</p><p><strong>What is an API?</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1Pc7vKlRzDEf7ZwzOo7C5A.png" /><figcaption>Image from <a href="https://www.altexsoft.com/blog/engineering/what-is-api-definition-types-specifications-documentation/">altexsoft.com</a></figcaption></figure><p>An <strong>application program interface (API)</strong> is a set of routines, protocols, and tools for building software applications. Basically, an API specifies how software components should interact.</p><p><strong>What is FastAPI?</strong></p><p><strong>FastAPI </strong>is a Web framework for developing <strong>RESTful APIs</strong> in Python. FastAPI is based on <strong>Pydantic</strong> and type hints to validate, serialize, and deserialize data, and automatically auto-generate <strong>OpenAPI </strong>documents. It fully supports asynchronous programming and can run with <strong>Uvicorn</strong> and<strong> Gunicorn</strong>.</p><p>You can check out these links on documentation of FastAPI and how it works 👇</p><blockquote><a href="https://fastapi.tiangolo.com/">FastAPI (tiangolo.com)</a></blockquote><blockquote><a href="https://realpython.com/fastapi-python-web-apis/">Using FastAPI to Build Python Web APIs — Real Python</a></blockquote><blockquote><a href="https://github.com/tiangolo/fastapi">tiangolo/fastapi: FastAPI framework, high performance, easy to learn, fast to code, ready for production (github.com)</a></blockquote><p><strong>What is Streamlit?</strong></p><p>Streamlit is an open source app framework in Python language. It <strong>helps us create web apps for data science and machine learning in a short time</strong>. It is compatible with major Python libraries such as scikit-learn, Keras, PyTorch, SymPy(latex), NumPy, pandas, Matplotlib etc.</p><p>You can find out more information about streamlit below 👇</p><blockquote><a href="https://streamlit.io/">Streamlit • The fastest way to build and share data apps</a></blockquote><blockquote><a href="https://www.analyticsvidhya.com/blog/2021/06/build-web-app-instantly-for-machine-learning-using-streamlit/">https://www.analyticsvidhya.com/blog/2021/06/build-web-app-instantly-for-machine-learning-using-streamlit/</a></blockquote><p><strong>What is Docker?</strong></p><p>Docker is an open source containerization platform. It <strong>enables us topackage applications into containers</strong> — standardized executable components combining application source code with the operating system (OS) libraries and dependencies required to run that code in any environment.</p><p><strong>What is Docker-Compose?</strong></p><p>Docker Compose is <strong>a tool that was developed to help define and share multi-container applications</strong>. With Compose, we can create a YAML file to define the services and with a single command, can spin everything up or tear it all down.</p><p>More information about Docker and docker-compose can be found below 👇</p><blockquote><a href="https://www.docker.com/">https://www.docker.com/</a></blockquote><blockquote><a href="https://docs.docker.com/compose/">https://docs.docker.com/compose/</a></blockquote><h3>Project Structure</h3><p>This project consists of two parts, a frontend based on Streamlit and a backend based on FastAPI and the whole application is packaged using Docker.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/231/1*xCQc1igFwWxqsYTXnLCJJg.png" /><figcaption>Screenshot by Author: Project Structure</figcaption></figure><h4>Setting up the Streamlit app with Docker</h4><p>The Streamlit application will be used to make requests to our API so as to get predictions when data is sent to it.</p><pre>📦Frontend<br> ┣ 📂.streamlit<br> ┃ ┗ 📜config.toml <br> ┣ 📜Dockerfile<br> ┣ 📜app.py<br> ┗  image.png<br> ┗ 📜requirements.txt</pre><p>In the app.py you create your web page and use <a href="https://share.streamlit.io/daniellewisdl/streamlit-cheat-sheet/master/app.py">Streamlit widgets</a> to do so.</p><p>For Custom themes for your Streamlit app, they can be defined in the config file: ./.streamlit/config.toml. Check this <a href="https://blog.streamlit.io/introducing-theming/">link</a> for more details.</p><p>These are the dependencies for the streamlit app:</p><pre>numpy==1.21.6<br>requests==2.23.0<br>streamlit==1.10.0</pre><p>The following is the Dockerfile I used to build the Streamlit application. It consists of the dependencies which I listed in the requirements.txt file. Once the build command is run, these dependencies will be installed with its corresponding versions.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e8fe95d106e29bc2af1cba2697beb99a/href">https://medium.com/media/e8fe95d106e29bc2af1cba2697beb99a/href</a></iframe><p>The code for our streamlit application is given below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a94e946ac45b36b2247d0afb03d86f5e/href">https://medium.com/media/a94e946ac45b36b2247d0afb03d86f5e/href</a></iframe><p>The code above performs the following actions;</p><ul><li>takes inputs from the user,</li><li>sends the inputs as a post request to our FastAPI application that’s hosting the model.</li><li>When the data is received by the API, the model then predicts the outcome of the transaction and sends the response back to the frontend so the result can be displayed.</li></ul><p>The command to build my Dockerfile is:</p><pre>docker build -t myapp:latest .</pre><p>To run the application use this command in the terminal:</p><pre>docker run -p 8501:8501 myapp:latest</pre><p>You should get this as a result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pf8It3DFfVtm_y6Ypsgw-Q.png" /><figcaption>Image by Author: Streamlit Running from Terminal</figcaption></figure><p>Then you can view your app in the browser using the Network URL: <a href="http://localhost:8501/">http://localhost:8501/</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*UUnkrOFMY-1D2bPTKnIVHQ.gif" /><figcaption>GIF by Author: Streamlit Application</figcaption></figure><h4>Setting up the backend with FastAPI and Docker</h4><p>We will be using FastAPI and a Dockerfile to deploy our model as an API to get predictions.</p><p>The random forest model we saved as “credit_fraud.pkl” will be used to make predictions. This model will be triggered via the web interface, to get predictions from a test data sample which the end user will provide.</p><p>This is my backend repository structure:</p><pre>📦Backend<br> ┣ 📜Dockerfile<br> ┣ 📜credit_fraud.pkl<br> ┣ 📜app.py<br> ┗ 📜requirements.txt</pre><p>In the app.py file, the model is loaded and an API is created for getting attributes from the test data and generate the prediction associated to it.</p><p>These are the dependencies I used in this project for the backend:</p><pre>fastapi==0.68.0<br>gunicorn==20.1.0<br>uvicorn==0.14.0<br>pandas==1.3.1<br>scikit-learn==1.0.2<br>scipy==1.8.1<br>six==1.16.0<br>joblib==1.0.1<br>numpy==1.21.6<br>pydantic==1.9.1<br>httptools<br>uvloop</pre><p>This is the Dockerfile used for the backend:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ccdd45908a4e4600aaf0e83412ebc082/href">https://medium.com/media/ccdd45908a4e4600aaf0e83412ebc082/href</a></iframe><p>To elaborate on the last command in the backend Dockerfile, the following are the defined <strong>settings</strong> for <a href="https://www.uvicorn.org/deployment/">Uvicorn</a>:</p><p><strong>— host 0.0.0.0</strong> defines the address to host the server on.</p><p><strong>— port 8000</strong> defines the port to host the server on.</p><p><strong>app:app</strong> tells Uvicorn where it can find the FastAPI ASGI application — e.g., “within the the ‘app.py’ file, you’ll find the ASGI app, app = FastAPI().</p><p><strong>— reload</strong> enables auto-reload so the server will restart after changes are made to the code base.</p><p>The code for the API is given below:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f13e3552b8275000b4a0f77daf8aba82/href">https://medium.com/media/f13e3552b8275000b4a0f77daf8aba82/href</a></iframe><p>These are the steps which explain the code above:</p><ol><li>A “fraudDetection” Model class was created so as to define all the parameters of our machine learning model. The first two values are integer types while the rest are float types.</li><li>Next, the model is loaded with joblib and then saved as a variable called “model”. This model object will be used to get the predictions.</li><li>The “/predict” route function declares a parameter called “data” of the “fraudDetection” Model type. This parameter can be accessed as a dictionary. The dictionary object will allow you to access the values of the parameters as key-value pairs.</li><li>Now, you are saving all the parameter values sent by the client. These values are now fed to the model predict function and you have your prediction for the data provided.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/838/1*wI_h2REBL9b89x-X9b_CEA.png" /><figcaption>Image by Author: Data Transfer between API and Streamlit Application</figcaption></figure><p>From the “backend” folder in your terminal, build the image by executing:</p><pre>$ docker build -t backend .</pre><p>Run the container:</p><pre>$ docker run -p 8000:8000 backend</pre><p>In your browser, navigate to <a href="http://localhost:8080/">http://localhost:8000/</a>. You should see:</p><pre>Credit Card Fraud Detection API 🙌🏻<br><br>Note: add &quot;/docs&quot; to the URL to get the Swagger UI Docs or &quot;/redoc&quot;</pre><p>You can access the API documentation if you navigate to <a href="http://localhost:8080/docs">http://localhost:8000/docs</a></p><p>You’ll see the documentation for every route you created as well as an interactive interface where you can test each endpoint directly from the browser.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*XUKSj--Z9-UeuS2wGMUQUw.gif" /><figcaption>GIF by Author: Credit Card Fraud Detection API</figcaption></figure><p>Now we will define a docker-compose.yml file that will create a service for our API and a service for the frontend Streamlit app.</p><p>Docker-compose is a great tool for defining multi-container applications and it enables you to configure them and also it gives you the ability to set up the communication between you services.</p><p>This is the docker-compose file which was used to attach the backend and frontend containers together:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9d6b4f49f28bfaacf5d3aa8c06daef6a/href">https://medium.com/media/9d6b4f49f28bfaacf5d3aa8c06daef6a/href</a></iframe><p>The docker-compose file is configured so that we no longer need to build each Dockerfile of the different images at a time. We could do that in one shot by running the docker- compose command:</p><pre>docker-compose up -d --build</pre><p>The image for service Frontend and Backend were built because they did not already exist.</p><p>To enable the communication between the docker containers of the frontend and the backend, creating a network and giving each of the containers an alias was necessary.</p><p>To see changes it is useful to use the following commands:</p><pre>docker-compose stop</pre><p>And then, if you have not added any new dependency, you do not need to rebuild again your images of Streamlit and FastAPI and you could just use this command to see changes:</p><pre>docker-compose up -d</pre><h3>Conclusion</h3><p>In conclusion, we were able to build a machine learning model that could detect fraudulent credit card transactions, deploy our model as an API with FastAPI, create a frontend application with Streamlit and combine both applications with docker-compose.</p><blockquote>You can check out the final application deployed on streamlit cloud by following this<strong> </strong><a href="https://share.streamlit.io/nneji123/credit-card-fraud-detection/main"><strong>link</strong></a><strong>.</strong></blockquote><blockquote>The API was deployed on the Heroku platform and can be found <a href="https://credit-fraud-ml-api.herokuapp.com/"><strong>here</strong></a><strong>.</strong></blockquote><blockquote>The repository containing the source code can be found <a href="https://github.com/Nneji123/Credit-Card-Fraud-Detection/"><strong>here</strong></a><strong>.</strong></blockquote><h3>References</h3><p><a href="https://testdriven.io/blog/fastapi-streamlit/">https://testdriven.io/blog/fastapi-streamlit/</a></p><p><a href="https://rihab-feki.medium.com/deploying-machine-learning-models-with-streamlit-fastapi-and-docker-bb16bbf8eb91">Deploying Machine Learning models with Streamlit, FastAPI and Docker | by Rihab Feki | Medium</a></p><p>You made it to the end of the article! Thanks for reading and hope you learned a lot, If You Like My Content and Want To Connect with me You can do that by:</p><ol><li>Following Me On <a href="https://medium.com/@ifeanyinneji777"><em>Medium</em>.</a></li><li>Connecting With Me On <a href="https://www.linkedin.com/in/ifeanyi-nneji"><em>LinkedIn</em></a><em> and on</em><a href="https://twitter.com/Neji_14"><em> Twitter</em></a>.</li><li>Connecting With Zummit Africa On <a href="https://www.linkedin.com/company/zummit-africa/mycompany/verification/">LinkedIn</a></li></ol><p><a href="https://medium.com/mlearning-ai/mlearning-ai-submission-suggestions-b51e2b130bfb">Mlearning.ai Submission Suggestions</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2527ca04c3de" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Write a Proper README.md For Your Project on GitHub]]></title>
            <link>https://faun.pub/how-to-write-a-proper-readme-md-for-your-project-on-github-e8d51ac32e73?source=rss-eb428365def4------2</link>
            <guid isPermaLink="false">https://medium.com/p/e8d51ac32e73</guid>
            <category><![CDATA[documentation]]></category>
            <category><![CDATA[github]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[git]]></category>
            <category><![CDATA[open-source]]></category>
            <dc:creator><![CDATA[Ifeanyi Nneji]]></dc:creator>
            <pubDate>Wed, 15 Jun 2022 10:41:44 GMT</pubDate>
            <atom:updated>2022-06-15T10:41:44.122Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*NYiA-lZD9Py9BjgpGb66Zw.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@glenncarstenspeters?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Glenn Carstens-Peters</a> on <a href="https://unsplash.com/s/photos/writing?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><h3>TABLE OF CONTENTS</h3><ul><li>The Purpose of a README file</li><li>What is a README file?</li><li>What should your README file contain?</li><li>Project Title</li><li>Project Description</li><li>Project Requirements and Dependencies</li><li>How to Set Up and Run the Project</li><li>How to Make Use of The Project</li><li>Credits/Appreciation</li><li>Add a License</li><li>Badges</li><li>How to Contribute To the Project</li><li>Sites that can help you generate README.md files for your Project</li></ul><h3>The Purpose of a README.md</h3><p>Knowing how to document your project by producing a README is vital for you as a developer because:</p><ul><li>It should be the first file a person sees when they come across your project, so it should be concise but comprehensive.</li><li>It will distinguish your project from the crowd. Make certain that your project is also excellent.</li><li>It will assist you in concentrating on what your project must do and how it must accomplish it.</li><li>It will help you develop your writing talents.</li></ul><h3>What is a README.md?</h3><p>In simple terms, a README.md file is a markdown file(.md) that provides users with a full overview of a project on which you have worked.</p><p>It’s also known as documentation that contains instructions on how to use a project. It will usually include instructions on how to set up and run the project.</p><h3>What should your README.md file contain?</h3><p>A good README file should contain the following:</p><ol><li>Your Project’s Title</li><li>Project Description</li><li>Project Requirements and Dependencies</li><li>How to Set up and Run the Project</li><li>How to make use of the Project</li><li>Credits/ Appreciation</li><li>A License</li><li>Badges(Optional)</li><li>How to Contribute to the Project</li></ol><h4>Project Title</h4><p>This is the name of your project. It helps people understand what your project is about.</p><h4>Project Description</h4><p>This is a very important section of your README file as it helps describe in detail what your project does and how it works. You can add an image, video or a gif to the README file which will help demonstrate how the project works.</p><h4>Project Requirements and Dependencies</h4><p>These are the requirements that need to be fulfilled for your project to run. An example is a project made with Python and Pygame library. One of the requirements to run such a project will be to have python installed on the respective machine and also have the Pygame library installed.</p><h4>How to Set Up and Run the Project</h4><p>A detailed overview should be provided on how to set up and run the development environment.</p><h4>How to Make Use of The Project</h4><p>Instructions and examples should be provided so that users/contributors may use the project. This will make it simple for them in the event that they run into an issue because they will always have a reference point for what is expected.</p><p>You can also utilize visual aids(images, videos or gifs can be added to the README file) to display samples of the running project, as well as the structure and design ideas employed in your project, by supplying resources such as screenshots.</p><h4>Credits/Appreciation</h4><p>List your collaborators/team members if you worked on the project as a group or an organization. Include links to their GitHub profiles and social media accounts as well.</p><p>Also, if you used tutorials or referenced a specific piece of content that would be useful to the user in building that project, include links to them as well.</p><h4>Add a License</h4><p>This is often the concluding section of most README files. It informs other developers about the capabilities and limitations of your project.</p><p>Depending on the type of project you’re working on, we have different types of licenses. The contributions to your project will be determined by which option you select.</p><p>The GPL License is the most prevalent, as it permits others to modify your work and use it for commercial purposes.</p><h4>Badges</h4><p>A GitHub Badge is a simple embeddable badge showing your GitHub stats like the number of stars or forks, languages used in the project, CI/CD build status, the license of the project, open issues count for the project, etc.</p><p>Badges aren’t required, but they are a quick and easy method to show other developers that you know what you’re doing.</p><p>This <a href="https://github.com/alexandresanlim/Badges4-README.md-Profile">GitHub Repository </a>has a lot of useful badges which can be added to your README file.</p><h4>How to Contribute To the Project</h4><p>This is most beneficial if you’re working on an open-source project that will require contributions from other developers. You’ll want to include some parameters to let them know how they may help with your project.</p><h4>Sites that can help you generate README files for your Project</h4><p>There are several tools available to help you automatically build a README for your project, but it’s always a good idea to try it out on your own first. If you want to take a look at them, they are as follows:</p><ul><li><a href="https://readme.so/">readme.so</a></li><li><a href="https://github.com/kefranabg/readme-md-generator">GitHub — kefranabg/readme-md-generator</a></li></ul><h4>My GitHub</h4><p><a href="https://github.com/Nneji123/">Nneji123 - Overview</a></p><p>You made it to the end of the article! Thanks for reading, If You Like My Content and Want To Connect with me You can do that by:</p><ol><li>Following Me On <a href="https://medium.com/@ifeanyinneji777"><em>Medium</em>.</a></li><li>Connecting With Me On <a href="https://www.linkedin.com/in/ifeanyi-nneji"><em>LinkedIn</em></a><em> and on</em><a href="https://twitter.com/Neji_14"><em> Twitter</em></a>.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*oy9cSohVrqa3jMUt.png" /></figure><h4>If this post was helpful, please click the clap 👏 button below a few times to show your support for the author 👇</h4><h4>🚀Developers: Learn and grow by keeping up with what matters, <a href="https://faun.to/8zxxd">JOIN FAUN.</a></h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e8d51ac32e73" width="1" height="1" alt=""><hr><p><a href="https://faun.pub/how-to-write-a-proper-readme-md-for-your-project-on-github-e8d51ac32e73">How to Write a Proper README.md For Your Project on GitHub</a> was originally published in <a href="https://faun.pub/">FAUN.dev() 🐾</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to launch a Streamlit app directly from Google Colab]]></title>
            <link>https://faun.pub/how-to-launch-a-streamlit-app-directly-from-google-colab-8014165e0267?source=rss-eb428365def4------2</link>
            <guid isPermaLink="false">https://medium.com/p/8014165e0267</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[google-colab]]></category>
            <category><![CDATA[streamlit-app]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Ifeanyi Nneji]]></dc:creator>
            <pubDate>Wed, 01 Jun 2022 12:21:07 GMT</pubDate>
            <atom:updated>2022-06-03T01:38:32.746Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to create and launch a Streamlit app directly from Google Colab</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DfSMWoWQwJRr901e0Opo5Q.png" /><figcaption>Image from Streamlit</figcaption></figure><p>Streamlit is an open source app framework in Python language. It <strong>helps in creating web apps for data science and machine learning in a short time and </strong>is compatible with major Python libraries such as scikit-learn, Keras, PyTorch, SymPy(latex), NumPy, pandas, Matplotlib etc.</p><p>So I was working on a project with the ResNet50 image classification model in Google colab and I wanted to create a Streamlit app.</p><p>I didn’t want to download the files directly to my physical machine just so I could make the app so I searched for ways on how to do it directly from Google colab and here’s how to do it:</p><ol><li><strong>Install Streamlit in your instance of Google colab by running:</strong></li></ol><pre>!pip install -q streamlit</pre><p>2. <strong>Sign up for a ngrok account: </strong><a href="https://t.co/HBrF7zf18M"><strong>http://ngrok.com</strong></a></p><p>3. <strong>After signing up hit the sidebar and you’d see something like this in the picture.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5HrNFeTE2MtZDf8mAtEE8Q.png" /><figcaption>Image by Author</figcaption></figure><p>Click on “Your Authtoken” then copy your token.</p><p>4. <strong>Then run this in Google colab:</strong></p><pre> !./ngrok authtokens your_token </pre><p>Replace <em>your_token</em> with your copied token.</p><p>5.<strong> Run this next to install the pyngrok package:</strong></p><pre>!pip install pyngrok </pre><p>6. <strong>Run this next:</strong></p><pre>from pyngrok import ngrok <br>public_url = ngrok.connect(port=’8501&#39;)<br>public_url</pre><p>7. <strong>You can now proceed and create a .py file with the contents of your streamlit app.</strong></p><p>To create the .py file run this in the next cell:</p><pre>%%writefile streamlit_app.py <br>import streamlit as st </pre><pre>st.markdown(&quot;&quot;&quot; This is a Streamlit App &quot;&quot;&quot;)</pre><p>In the same cell as the command above you can write all the contents of the app and then when that cell is run the streamlit_app.py file is created in your Google colab instance.</p><p>After all that you can now run the app from Google colab by running this command in another cell:</p><pre>!streamlit run /content/streamlit_app.py &amp; npx localtunnel — port 8501 </pre><p>And the app should be up and running like in the image below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ddf-tNT1LF4KyuWbu3l0rg.png" /><figcaption>Streamlit Running in Google Colab with Localtunnel</figcaption></figure><h4>Advantages of Creating a Streamlit App through Google colab</h4><p>1. It saves time and resources because you don&#39;t have to start installing dependencies on your local machine just to make the app run.</p><p>2. It makes testing the app easier because you can adjust and work with your model directly from Google colab and then make inference from the Streamlit app.</p><p>If you want to check out what I was working on the project link and GitHub links are provided below:</p><p><strong>App Link : </strong><a href="https://share.streamlit.io/nneji123/deep-learning-object-recognition-with-resnet50/main">https://share.streamlit.io/nneji123/deep-learning-object-recognition-with-resnet50/main</a></p><p><strong>GitHub Repository: </strong><a href="https://github.com/Nneji123/Deep-Learning-Object-Recognition-with-ResNet50">Nneji123/Deep-Learning-Object-Recognition-with-ResNet50</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*ScbblioWuntuB82E.png" /></figure><h4>If this post was helpful, please click the clap 👏 button below a few times to show your support for the author 👇</h4><h4>🚀Developers: Learn and grow by keeping up with what matters, <a href="https://faun.to/8zxxd">JOIN FAUN.</a></h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8014165e0267" width="1" height="1" alt=""><hr><p><a href="https://faun.pub/how-to-launch-a-streamlit-app-directly-from-google-colab-8014165e0267">How to launch a Streamlit app directly from Google Colab</a> was originally published in <a href="https://faun.pub/">FAUN.dev() 🐾</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>