<?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 kush bhatt on Medium]]></title>
        <description><![CDATA[Stories by kush bhatt on Medium]]></description>
        <link>https://medium.com/@bhattkush30?source=rss-3a326a1fc907------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*TTvTlfTptHdjbNIAndc-Gw.jpeg</url>
            <title>Stories by kush bhatt on Medium</title>
            <link>https://medium.com/@bhattkush30?source=rss-3a326a1fc907------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 00:02:41 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@bhattkush30/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[Building a Real-Time Face Emotion Detection System with Python, Deep Face, and OpenCV]]></title>
            <link>https://medium.com/@bhattkush30/building-a-real-time-face-emotion-detection-system-with-python-deep-face-and-opencv-aca6f31f994f?source=rss-3a326a1fc907------2</link>
            <guid isPermaLink="false">https://medium.com/p/aca6f31f994f</guid>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[retinaface]]></category>
            <category><![CDATA[deepface]]></category>
            <category><![CDATA[opencv]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[kush bhatt]]></dc:creator>
            <pubDate>Sun, 07 Jun 2026 11:25:10 GMT</pubDate>
            <atom:updated>2026-06-07T11:25:10.086Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Introduction</strong></h3><p>Facial expressions are one of the most important ways humans communicate emotions. Computers can now analyze these expressions using Artificial Intelligence and Computer Vision techniques. In this project, I developed a real-time Face Emotion Detection System that can detect human faces through a webcam and predict emotions such as happiness, sadness, anger, surprise, fear, and neutrality.</p><p>The project combines powerful technologies including Python, OpenCV, RetinaFace, and DeepFace to create an intelligent emotion recognition application.</p><h3><strong>Project Overview</strong></h3><p>This project demonstrates a <strong>Real-Time Face Emotion Detection System</strong> built using <strong>Python</strong>, <strong>OpenCV</strong>, <strong>DeepFace</strong>, and <strong>RetinaFace</strong>. The system performs <strong>Facial Emotion Recognition</strong> by analyzing facial expressions and predicting emotions such as happiness, sadness, anger, surprise, fear, and neutrality.</p><p>Using modern <strong>Computer Vision</strong> and <strong>Deep Learning</strong> techniques, the application can detect faces from a live webcam feed and perform <strong>AI-powered Emotion Detection</strong> in real time. The project showcases how <strong>Machine Learning</strong> and <strong>Artificial Intelligence</strong> can be applied to create intelligent systems capable of understanding human emotions.</p><p>Whether you are interested in <strong>Emotion Recognition Systems</strong>, <strong>Facial Expression Recognition</strong>, <strong>Computer Vision Projects</strong>, or <strong>Python AI Projects</strong>, this implementation provides a practical example of building a real-world application using state-of-the-art deep learning models.</p><h3><strong>Project Objective</strong></h3><p>The main goal of this project is to:</p><ul><li>Detect faces in real time using a webcam.</li><li>Analyze facial expressions using deep learning.</li><li>Predict human emotions accurately.</li><li>Display detected emotions directly on the video stream.</li></ul><p>Potential applications include:</p><ul><li>Human-Computer Interaction</li><li>Mental Health Monitoring</li><li>Smart Surveillance Systems</li><li>Customer Experience Analysis</li><li>Educational Technologies</li></ul><h3><strong>Technologies Used</strong></h3><p><strong>Python:- </strong>Python was used as the primary programming language because of its extensive support for AI and computer vision libraries.</p><p><strong>OpenCV</strong></p><p>OpenCV handles:</p><ul><li>Webcam access</li><li>Video frame processing</li><li>Drawing bounding boxes</li><li>Displaying emotion labels</li></ul><p><strong>RetinaFace</strong></p><p>RetinaFace is an advanced face detection model that provides:</p><ul><li>High face detection accuracy</li><li>Landmark detection</li><li>Better performance in different lighting conditions</li></ul><p><strong>DeepFace</strong></p><p>DeepFace is a deep learning-based facial analysis framework capable of:</p><ul><li>Emotion Detection</li><li>Face Verification</li><li>Age Prediction</li><li>Gender Detection</li><li>Race Analysis</li></ul><p>In this project, DeepFace was specifically used for emotion recognition.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7E-or6Tr6dsQPqzYakj-6w.jpeg" /><figcaption>how to work this project</figcaption></figure><p>The workflow follows these steps:</p><ol><li>Capture video frames using OpenCV.</li><li>Detect faces using RetinaFace.</li><li>Extract the detected face region.</li><li>Pass the face image to DeepFace.</li><li>Predict the dominant emotion.</li><li>Display the emotion label on the screen.</li></ol><h3>Implementation</h3><p><strong>Step 1: Capture Webcam Frames</strong></p><p>OpenCV continuously reads frames from the webcam.</p><pre>cap = cv2.VideoCapture(0)</pre><p><strong>Step 2: Face Detection</strong></p><p>RetinaFace identifies the location of faces within the frame.</p><pre>faces = RetinaFace.detect_faces(frame)</pre><p><strong>Step 3: Emotion Analysis</strong></p><p>The cropped face is analyzed using DeepFace.</p><pre>result = DeepFace.analyze(<br>    face_img,<br>    actions=[&#39;emotion&#39;],<br>    enforce_detection=False<br>)</pre><p><strong>Step 4: Display Results</strong></p><p>The predicted emotion is shown on the video feed.</p><pre>cv2.putText(frame, emotion, (x, y-10),<br>            cv2.FONT_HERSHEY_SIMPLEX,<br>            0.8, (0,255,0), 2)</pre><h3>Challenges Faced</h3><p>During development, several challenges were encountered:</p><h3>1. Face Detection Accuracy</h3><p>Detecting faces under poor lighting conditions affected prediction quality.</p><h3>2. Dependency Issues</h3><p>One common issue was:</p><pre>ModuleNotFoundError: No module named &#39;tf_keras&#39;</pre><p>This occurred because some versions of DeepFace require TensorFlow-compatible Keras packages.</p><h3>3. Real-Time Performance</h3><p>Emotion analysis on every frame can be computationally expensive. Optimizations were necessary to maintain smooth performance.</p><h3>4. Emotion Ambiguity</h3><p>Human emotions can be subtle and sometimes overlap, making accurate classification difficult.</p><h3>Limitations of DeepFace Emotion Detection</h3><p>Although DeepFace provides strong performance, it has several limitations:</p><ul><li>Performance decreases with poor image quality.</li><li>Sensitive to lighting variations.</li><li>Occlusions such as masks or sunglasses affect accuracy.</li><li>Cultural differences in emotional expressions may impact predictions.</li><li>Real emotions may not always match visible facial expressions.</li><li>Requires significant computational resources for real-time analysis.</li></ul><h3>Results</h3><p>The system successfully detects faces and predicts emotions in real time. Testing showed reliable performance for common emotions such as:</p><ul><li>Happy</li><li>Sad</li><li>Angry</li><li>Surprise</li><li>Fear</li><li>Neutral</li><li>Disgust</li></ul><p>The integration of RetinaFace improved face detection quality, while DeepFace provided accurate emotion classification.</p><h3>Future Improvements</h3><p>Future enhancements may include:</p><ul><li>Emotion tracking over time</li><li>Multi-person emotion detection</li><li>Emotion analytics dashboard</li><li>Deployment using FastAPI and React</li><li>Mobile application support</li><li>Custom-trained emotion recognition models</li></ul><h3>Conclusion</h3><p>This project demonstrates how Artificial Intelligence and Computer Vision can be combined to analyze human emotions in real time. By leveraging DeepFace, RetinaFace, and OpenCV, it is possible to build an effective emotion recognition system capable of understanding facial expressions through a webcam feed.</p><p>As AI continues to evolve, emotion recognition systems will play an increasingly important role in creating more intelligent and human-centered applications.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=aca6f31f994f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is Supervised Learning in Machine Learning? Types, Algorithms & Examples]]></title>
            <link>https://medium.com/@bhattkush30/what-is-supervised-learning-in-machine-learning-types-algorithms-examples-b60600ac76ff?source=rss-3a326a1fc907------2</link>
            <guid isPermaLink="false">https://medium.com/p/b60600ac76ff</guid>
            <category><![CDATA[scikit-learn]]></category>
            <category><![CDATA[supervised-learning]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[predictive-modeling]]></category>
            <dc:creator><![CDATA[kush bhatt]]></dc:creator>
            <pubDate>Sat, 28 Feb 2026 04:41:02 GMT</pubDate>
            <atom:updated>2026-02-28T04:41:02.112Z</atom:updated>
            <content:encoded><![CDATA[<h4>What is Supervised Learning? A Complete Beginner-Friendly Guide</h4><p>Machine Learning is transforming industries — from <strong>Netflix recommendations</strong> to <strong>fraud detection in banking</strong>. At the heart of many intelligent systems lies <strong>Supervised Learning</strong>, one of the most fundamental and widely used approaches in Machine Learning.</p><p>In this article, you’ll learn:</p><ul><li>What Supervised Learning is</li><li>Why it is called “supervised”</li><li>Types of Supervised Learning</li><li>Popular algorithms</li><li>Real-world applications</li><li>Advantages and disadvantages</li></ul><p>Let’s break it down in a simple yet professional way.</p><p><strong><em>What is Supervised Learning?</em></strong></p><p>Supervised Learning is a type of Machine Learning where a model is trained using <strong>labeled data</strong>.</p><p>This means:</p><ul><li>Each input data point has a corresponding correct output</li><li>The algorithm compares its predictions with actual answers</li><li>The model improves by minimizing errors</li></ul><h3>In Simple Words:</h3><blockquote><strong><em>Supervised Learning = Learning with a teacher.</em></strong></blockquote><p>The “teacher” is the labeled dataset that guides the model toward the correct prediction.</p><p><strong><em>Why Is It Called “Supervised” Learning?</em></strong></p><p>It is called <em>supervised</em> because the training process is guided by known answers.</p><p>Imagine a student solving math problems:</p><ul><li>The teacher provides questions</li><li>The teacher also provides correct answers</li><li>The student learns by correcting mistakes</li></ul><p>Similarly, in supervised learning:</p><p>Input → Model → Predicted Output<br> Predicted Output → Compared with Actual Output<br> Error → Model adjusts itself</p><p>The presence of correct labels acts as supervision.</p><p><strong><em>🧠 How Supervised Learning Works</em></strong></p><ul><li>Collect labeled dataset</li><li>Split data into training and testing sets</li><li>Choose a machine learning algorithm</li><li>Train the model</li><li>Evaluate performance</li><li>Make predictions on new data</li></ul><p><strong><em>📂 Types of Supervised Learning</em></strong></p><p>.Supervised Learning is mainly divided into <strong>two types</strong>:</p><h3>1️⃣ Regression</h3><p>🔹 <strong><em>What is Regression?</em></strong></p><p>Regression is a statistical method used in machine learning to model the relationship between a dependent variable (target) and one or more independent variables (features), where the output is <strong>continuous (numerical)</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/902/1*5w2Jruzs8pwkXG6AXkWJug.jpeg" /><figcaption><strong>Example of Linear Regression</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/539/1*OLM_PhxsOgPj3_VCQl238g.png" /><figcaption>Example of Linear Regression</figcaption></figure><h3>📌 Examples:</h3><ul><li>House price prediction</li><li>Salary prediction</li><li>Stock price forecasting</li><li>Temperature prediction</li></ul><h3>🧮 Types of Regression Algorithms:</h3><ul><li>Linear Regression</li><li>Polynomial Regression</li><li>Decision Tree Regressor</li><li>Random Forest Regressor</li><li>Support Vector Regressor (SVR)</li></ul><h3>2️⃣ Classification</h3><p><strong><em>🔹 What is Classification?</em></strong></p><p>Classification is a machine learning technique that learns from labeled data to assign new observations into predefined classes or categories.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/565/1*gwybTUiP5SmyZpfIqHx2ZQ.png" /><figcaption><strong>Example of classification</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PSwLXrhb8X72VItInbj6CA.png" /><figcaption><strong>Example of classification</strong></figcaption></figure><h3>📊 Examples:</h3><ul><li>Spam or Not Spam (Email filtering)</li><li>Positive or Negative (Sentiment analysis)</li><li>Disease or No Disease (Medical diagnosis)</li><li>Cat or Dog (Image classification)</li></ul><h3>🤖 Types of Classification Algorithms:</h3><ul><li>Logistic Regression</li><li>K-Nearest Neighbors (KNN)</li><li>Decision Tree</li><li>Random Forest</li><li>Support Vector Machine (SVM)</li><li>Naive Bayes</li></ul><h3>🔥 Popular Supervised Learning Algorithms</h3><p>Here are some widely used algorithms explained briefly:</p><h3>1. Linear Regression</h3><p>Used for predicting continuous values.<br> Best for simple relationships between variables.</p><h3>2. Logistic Regression</h3><p>Despite the name, it’s used for <strong>classification problems</strong>.</p><h3>3. Decision Tree</h3><ul><li>Works like a flowchart.</li><li>Easy to visualize and interpret.</li></ul><h3>4. Random Forest</h3><ul><li>Collection of multiple decision trees.</li><li>More accurate and reduces overfitting.</li></ul><h3>5. Support Vector Machine (SVM)</h3><ul><li>Finds the optimal boundary between classes.</li><li>Effective in high-dimensional spaces.</li></ul><p><strong>🎯 Real-World Examples of Supervised Learning</strong></p><p>Healthcare like Disease Prediction</p><p>Finance like Credit Risk Analysis</p><p>Education like Student Performance Prediction</p><h3>📊 Advantages of Supervised Learning</h3><p>✅ High accuracy when labeled data is available<br> ✅ Clear evaluation metrics (Accuracy, MSE, F1-score)<br> ✅ Easy to understand conceptually<br> ✅ Works well for structured data</p><h3>⚠️ Disadvantages</h3><p>❌ Requires large labeled datasets<br> ❌ Labeling data can be expensive<br> ❌ Overfitting risk<br> ❌ Not ideal when data is unlabeled</p><h3>🏠 Project Example: House Price Prediction using Multiple Linear Regression</h3><p>This project demonstrates how <strong>Multiple Linear Regression in Python</strong> can be used to predict house prices based on features such as:</p><ul><li>Area (square feet)</li><li>Number of bedrooms</li><li>House age</li></ul><p>It covers the complete machine learning workflow:</p><ul><li>Data preparation using Pandas &amp; NumPy</li><li>Model training using Scikit-Learn</li><li>Model evaluation using MAE, MSE, and R² Score</li><li>Making predictions on new data</li></ul><p>This project is ideal for beginners transitioning to intermediate-level Machine Learning projects and helps build a strong GitHub portfolio.</p><p>💻 <strong>Full Source Code Available Here:</strong><br> 👉 <a href="https://github.com/Bhattkush/housepricepridiction">https://github.com/Bhattkush/housepricepridiction</a></p><h3>🚀 Final Thoughts</h3><p>Supervised Learning is the foundation of modern AI systems.<br> If you’re starting your ML journey, master:</p><ul><li>Regression</li><li>Classification</li><li>Evaluation Metrics</li><li>Model Optimization</li></ul><p>Once you understand supervised learning deeply, building projects like:</p><ul><li>Movie Recommendation System</li><li>House Price Prediction</li><li>Disease Detection Model</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b60600ac76ff" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Pandas Library in Python]]></title>
            <link>https://medium.com/@bhattkush30/pandas-library-in-python-f66a8c116228?source=rss-3a326a1fc907------2</link>
            <guid isPermaLink="false">https://medium.com/p/f66a8c116228</guid>
            <category><![CDATA[pandas-dataframe]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[python-pandas]]></category>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[pandas]]></category>
            <dc:creator><![CDATA[kush bhatt]]></dc:creator>
            <pubDate>Mon, 22 Sep 2025 16:38:29 GMT</pubDate>
            <atom:updated>2025-09-22T16:38:29.234Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Introduction</strong></h3><p>In the age of data, extracting meaningful insights is more important than ever. From business analytics to machine learning, data manipulation is the first step in any project. Python provides several libraries for working with data, but the <strong>Pandas library</strong> has become the most popular and powerful tool for handling structured data.</p><p>In this blog, we’ll explore Pandas from scratch with <strong>simple examples</strong>, a <strong>real-time sales analysis use case</strong>, a <strong>technical data cleaning example</strong>, and finally look at the <strong>advantages and disadvantages</strong> of using Pandas.</p><h3><strong>Why Pandas?</strong></h3><p>So, why do developers and data scientists rely on Pandas?</p><ul><li><strong>Fast and efficient</strong> for data manipulation</li><li>Handles structured data (like CSV, Excel, SQL tables) with easly.</li><li>Integrates seamlessly with<strong> NumPy , Matplotlib , and Scikit-learn.</strong></li><li>Excellent for<strong> data cleaning, filtering, transformation, and grouping.</strong></li><li>Built-in functions for quick analysis.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/284/1*NuTr5NJkxpG4uwHCTQtggQ.png" /><figcaption>pandas</figcaption></figure><h3>Installation Step of Pandas Library in Python</h3><ol><li><strong>Check Python Installation</strong></li></ol><pre>#Run This Command in Terminal<br>python --version</pre><p>2. <strong>Install pip (Python Package Manager)</strong></p><p>Check if pip is installed</p><pre>pip --version</pre><p>If not installed, install pip with:</p><pre>python -m ensurepip --upgrade</pre><p>3. <strong>Install Pandas</strong></p><p>Now install <strong>Pandas</strong> using pip</p><pre>pip install pandas</pre><p>4. <strong>Install Along with NumPy</strong></p><p>Bcause Pandas depends on <strong>NumPy </strong>you can install both:</p><pre>pip install pandas numpy</pre><p>5. <strong>Verify Installation</strong></p><pre>#Then inside Python shell:<br>import pandas as pd<br>print(pd.__version__)</pre><h3><strong>Core Concepts of Pandas</strong></h3><p><strong>What is Core Concepts?</strong></p><p>When it comes to <strong>data analysis and manipulation in Python</strong>, one library always stands out — <strong>Pandas</strong>.<br> It is widely used in <strong>data science, machine learning, and analytics projects</strong> because of its simplicity and power.</p><p>But before diving into advanced operations, let’s explore the <strong>core concepts of Pandas</strong> that make it so popular.</p><h3><strong>Pandas Data Structures</strong></h3><p>Pandas provides two primary data structures:</p><h4>Series</h4><ul><li>A <strong>1-dimensional labeled array</strong> (similar to an Excel column).</li><li>Stores data of any type: integers, strings, floats, Python objects, etc.</li></ul><h4><strong>DataFrame</strong></h4><ul><li>A <strong>2-dimensional table</strong> with rows and columns (like an Excel sheet or SQL table).</li><li>The most used object in Pandas.</li></ul><h3><strong>2. Indexing and Data Alignment</strong></h3><ul><li>&gt; Pandas aligns data based on <strong>row and column labels</strong> rather than just index positions.</li></ul><p>-&gt; This makes merging, joining, and performing operations much easier.</p><h3>3. Data Selection and Filtering</h3><ul><li>Select column: df[&quot;Age&quot;]</li><li>Select row: df.loc[0] or df.iloc[0]</li><li>Filter rows: df[df[&quot;Age&quot;] &gt; 21]</li></ul><h3><strong>4. Handling Missing Data</strong></h3><p>Real-world datasets often have missing values. Pandas makes it easy to handle them:</p><ul><li>Check nulls → df.isnull()</li></ul><pre>import pandas as pd<br><br>#Example of df.isnull() <br>#Returns True if the value is missing, otherwise False.<br><br>data = {<br>    &quot;Name&quot;: [&quot;Kush&quot;, &quot;Ravi&quot;, None],<br>    &quot;Age&quot;: [20, None, 22],<br>    &quot;City&quot;: [&quot;Ahmedabad&quot;, &quot;Delhi&quot;, None]<br>}<br>df = pd.DataFrame(data)<br><br>print(df.isnull())<br><br>#expected Output<br>#  Name    Age   City<br># 0  False  False  False<br># 1  False   True  False<br># 2   True  False   True</pre><ul><li>Remove nulls → df.dropna()</li></ul><pre># Removes any row (or column) that contains NaN values.<br><br># By default, it removes entire rows where any column is missing.<br><br>print(df.dropna())<br><br>#Excepted Output<br># Name   Age       City<br>#0  Kush  20.0  Ahmedabad</pre><ul><li>Fill nulls → df.fillna(value)</li></ul><pre>#Replaces all NaN values with a specific value<br><br>print(df.fillna(&quot;Unknown&quot;))<br><br>#Excepted Output<br> # Name   Age       City<br># 0    Kush  20.0  Ahmedabad<br># 1    Ravi  Unknown     Delhi<br># 2  Unknown  22.0   Unknown</pre><h3><strong>5. GroupBy Operations</strong></h3><p>Pandas provides a powerful <strong>groupby()</strong> function to perform <strong>split–apply–combine</strong> operations</p><pre>df.groupby(&quot;City&quot;)[&quot;Age&quot;].mean()</pre><h4><strong>Advantages Of Pandas</strong></h4><ul><li>&gt; Easy to learn and use<br> -&gt; Fast and efficient data handling<br> -&gt; Supports multiple file formats<br> -&gt; Works seamlessly with NumPy, Matplotlib, and Scikit-learn.</li></ul><h4>Disadvantages of Pandas</h4><p>-&gt; Not the best for <strong>very large datasets</strong> (memory-heavy).<br> -&gt; Slower than specialized big data tools like <strong>Spark</strong> or <strong>Dask.</strong><br> -&gt; Requires practice to master advanced indexing and operations.</p><p><a href="https://github.com/Bhattkush/pandas">GitHub - Bhattkush/pandas</a></p><p><a href="https://www.linkedin.com/in/kush-bhatt-63765b2a6?utm_source=share&amp;utm_campaign=share_via&amp;utm_content=profile&amp;utm_medium=android_app">https://www.linkedin.com/in/kush-bhatt-63765b2a6?utm_source=share&amp;utm_campaign=share_via&amp;utm_content=profile&amp;utm_medium=android_app</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f66a8c116228" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Singleton Pattern In Java]]></title>
            <link>https://medium.com/@bhattkush30/singleton-pattern-in-java-66550883f74f?source=rss-3a326a1fc907------2</link>
            <guid isPermaLink="false">https://medium.com/p/66550883f74f</guid>
            <category><![CDATA[desgin-patterns]]></category>
            <category><![CDATA[design-patterns-in-java]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[singleton-pattern]]></category>
            <dc:creator><![CDATA[kush bhatt]]></dc:creator>
            <pubDate>Fri, 20 Jun 2025 05:21:13 GMT</pubDate>
            <atom:updated>2025-06-20T05:21:13.072Z</atom:updated>
            <content:encoded><![CDATA[<p>If you’re learning Java and heard about design patterns, the Singleton Pattern is one of the easiest and most useful to start with. It helps you make sure that only one object of a class is created during the entire program.</p><p>— —</p><p><strong>What is Singleton Pattern?</strong></p><p>&gt; Singleton means “only one”.</p><p>The Singleton Pattern makes sure that:</p><p>Only one object of a class is created<br> That object is shared everywhere in the program</p><p>Think of it like having only one TV remote in a room — everyone shares it instead of creating new ones!</p><p>— -</p><p><strong>Where Do We Use Singleton?</strong></p><p>Some real-life examples in programming:</p><p>Logging (write to a single log file)</p><p>App settings or configuration (read once, use everywhere)</p><p>Database connection (one connection, reused)</p><p>— -</p><p><strong>How to Create Singleton in Java?</strong></p><p>You need 3 simple steps:</p><p>1. Make constructor private (no one can create object from outside)</p><p>2. Create a static object of the class</p><p>3. Give a public method to access that object</p><p>— -</p><p>Easy Example to Explain</p><pre>// logger.java to save this file<br><br>public class Logger {<br><br>    // Step 1: Create a static variable to hold single object<br>    private static Logger instance;<br><br>    // Step 2: Make the constructor private<br>    private Logger() {<br>        System.out.println(&quot;Logger Started!&quot;);<br>    }<br><br>    // Step 3: Create a method to return the single object<br>    public static Logger getInstance() {<br>        if (instance == null) {<br>            instance = new Logger(); // Create object only once<br>        }<br>        return instance;<br>    }<br><br>    public void log(String message) {<br>        System.out.println(&quot;LOG: &quot; + message);<br>    }<br>}<br></pre><pre>// Main.java – Use the Singleton<br><br>public class Main {<br>    public static void main(String[] args) {<br>        // Get the logger object<br>        Logger logger1 = Logger.getInstance();<br>        logger1.log(&quot;First message&quot;);<br><br>        // Try again<br>        Logger logger2 = Logger.getInstance();<br>        logger2.log(&quot;Second message&quot;);<br><br>        // Check if both are same object<br>        if (logger1 == logger2) {<br>            System.out.println(&quot;Same logger used (Singleton works!)&quot;);<br>        }<br>    }<br>}<br><br>// OUTPUT <br>Logger Started!<br>LOG: First message<br>LOG: Second message<br>Same logger used (Singleton works!)</pre><p>&gt; <strong>Notice:</strong> Logger Started! printed only once — object created only one time!</p><p>— -</p><h3><strong>Remember</strong></h3><p>Only one object is made</p><p>Everyone uses the same object</p><p>Saves memory and controls resources</p><h3>Conclusion</h3><p>The <strong>Singleton Pattern</strong> is a fundamental design pattern that ensures <strong>only one instance</strong> of a class exists in the entire application, and provides a <strong>global access point</strong> to that instance.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=66550883f74f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How Does Algorithms Work with Tuple and Dictionary]]></title>
            <link>https://medium.com/@bhattkush30/how-does-algorithms-work-with-tuple-and-dictionary-280d963177e6?source=rss-3a326a1fc907------2</link>
            <guid isPermaLink="false">https://medium.com/p/280d963177e6</guid>
            <dc:creator><![CDATA[kush bhatt]]></dc:creator>
            <pubDate>Fri, 16 May 2025 04:24:09 GMT</pubDate>
            <atom:updated>2025-05-23T06:49:53.286Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>What is Algorithm?</strong></p><p>When you hear the word <strong>“algorithm,”</strong> it might sound complicated, but in reality, it’s something we use every day — in coding and even outside of it! Simply put, <strong>an algorithm is a step-by-step process to solve a problem or perform a task.</strong></p><p><strong>Why use Algorithm in coding?</strong></p><p>In coding, algorithms are the heart of every program. They tell the computer exactly what to do, and in what order. Example of them like a recipe: if you follow the steps correctly, you get the perfect dish (or in our case, a working program).</p><p><strong>How Does an Algorithm Work?</strong></p><p>Here’s the basic step follow:</p><ul><li>Understand the problem you’re trying to solve.</li><li>Plan a step-by-step solution.</li><li>Write the solution in code.</li><li>Test and optimize it if necessary.</li></ul><p><strong>An Algorithm Must Be</strong>:</p><ul><li><strong>Clear:</strong> Every step is defined.</li><li><strong>Correct:</strong> It solves the problem.</li><li><strong>Efficient:</strong> It works quickly and doesn’t waste resources.</li></ul><h3><strong>Tuple</strong></h3><p><strong>What is a Tuple?</strong></p><ul><li>An <strong>immutable</strong>, <strong>ordered</strong> collection.</li><li>Ideal for storing fixed-size, read-only data.</li><li>Access elements using <strong>indexing</strong>.</li><li>It is Represented by () parentheses Brackets.</li></ul><pre>def two_sum(nums, target):<br>    &quot;&quot;&quot;<br>    Returns a tuple of indices of the two numbers in &#39;nums&#39; that add up to &#39;target&#39;.<br>    &quot;&quot;&quot;<br>    seen = {}  # Dictionary to store number: index<br>    for i, num in enumerate(nums):<br>        complement = target - num<br>        if complement in seen:<br>            return (seen[complement], i)  # Return indices as a tuple<br>        seen[num] = i<br><br># Generate the list [1, 2, ..., 1_000_000]<br>nums = list(range(1, 1_000_001))<br><br># Set the target such that 2 + 1_000_000 = 1_000_002<br>target = 1_000_002<br><br># Call the function<br>result = two_sum(nums, target)<br><br># Print the result<br>print(&quot;Indices of numbers that add up to&quot;, target, &quot;:&quot;, result)<br><br>#Output <br>Indices of numbers that add up to 1000002 : (1, 999999)</pre><ul><li><strong>Time Complexity</strong>: O(n)-Must Check Each Element.</li><li><strong>Memory Usage: Low — </strong>Very efficient due to no overhead<strong>.</strong></li></ul><h3>Dictionary</h3><p><strong>What is a Dictionary ?</strong></p><ul><li>A <strong>mutable</strong>, <strong>unordered</strong> collection of key-value pairs.</li><li>Ideal for <strong>fast data lookup</strong> using keys.</li><li>Access elements using keys.</li><li>It is Represented {} Curly Brackets.</li></ul><pre><br>def two_sum_dict(nums, target):<br>    seen = {}<br>    for i, num in enumerate(nums):<br>        complement = target - num<br>        if complement in seen:<br>            # Return the result as a dictionary instead of a tuple<br>            return {&quot;index1&quot;: seen[complement], &quot;index2&quot;: i}<br>        seen[num] = i<br><br># Generate the list [1, 2, ..., 1_000_000]<br>nums = list(range(1, 1_000_001))<br><br># Set the target such that 2 + 1_000_000 = 1_000_002<br>target = 1_000_002<br><br># Call the function<br>result = two_sum_dict(nums, target)<br><br># Print the result in dictionary format<br>print(&quot;Indices of numbers that add up to&quot;, target, &quot;:&quot;, result)<br><br>#output <br>Indices of numbers that add up to 1000002 : {&#39;index1&#39;: 499999, &#39;index2&#39;: 500001}</pre><ul><li><strong>Time Complexity</strong>: O(n) – Must check each element.</li><li><strong>Memory Usage</strong>: <strong>Low</strong> — Very efficient due to no overhead.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/699/1*cc8Hc9_dpyPwQA389Ov_iA.png" /><figcaption>Dictionary and Tuple Summary</figcaption></figure><h3>Conclusion</h3><p><strong>Use a Tuple</strong> when:</p><ul><li>Data is simple and fixed.</li><li>1 million numbers <strong>Estimated total memory usage: ~80–90 MB</strong></li><li>You don’t need to frequently search or modify.</li></ul><p><strong>Use a Dictionary</strong> when:</p><ul><li>You need <strong>fast lookups</strong>, insertions, or updates.</li><li>You’re dealing with <strong>key-based data</strong>.</li><li>Memory Usage ≈ 50–60 MB for 1 million items.</li></ul><p>[1] Stack overflow : <em>How Much Memory Store Dictionary and Tuple :-</em></p><p><a href="https://stackoverflow.com/questions/15641344/python-memory-consumption-dict-vs-list-of-tuples">https://stackoverflow.com/questions/15641344/python-memory-consumption-dict-vs-list-of-tuples</a></p><p>[2] GitHub: this article, I walk through how I built a high-performance solution for the Two Sum problem in Python.</p><p><a href="https://github.com/Bhattkush/programing">https://github.com/Bhattkush/programing</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=280d963177e6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Physical Memory V/S Virtual Memory]]></title>
            <link>https://medium.com/@bhattkush30/physical-memory-v-s-virtual-memory-6665814f3710?source=rss-3a326a1fc907------2</link>
            <guid isPermaLink="false">https://medium.com/p/6665814f3710</guid>
            <category><![CDATA[physical-memory]]></category>
            <category><![CDATA[virtual-memory]]></category>
            <dc:creator><![CDATA[kush bhatt]]></dc:creator>
            <pubDate>Tue, 07 Jan 2025 16:05:13 GMT</pubDate>
            <atom:updated>2025-01-07T16:05:13.597Z</atom:updated>
            <content:encoded><![CDATA[<h3>What is Physical Memory?</h3><p><em>Physical memory is a hardware component that stores data and instructions that the processor can directly access. It’s faster than secondary storage devices, but more expensive and limited in capacity.</em></p><p><em>Physical memory, also known as RAM (random access memory), is a computer’s short-term memory that stores data being actively used by the CPU.</em></p><figure><img alt="This image shows a computer memory module (RAM stick). It is a long, rectangular circuit board with a green base and several black chips mounted on one side. Along the bottom edge, there is a row of gold connector pins used to insert the module into a computer’s motherboard. The black chips store temporary data to help the computer perform tasks quickly." src="https://cdn-images-1.medium.com/max/300/1*BtaFmmJUnhhOYUrvlfGFEQ.jpeg" /></figure><h3>About Physical Memory?</h3><p><strong><em>Physical memory</em></strong><em> refers to the </em><strong><em>hardware component in a computer or laptop used to store data temporarily</em></strong><em>, commonly known as </em><strong><em>RAM (Random Access Memory)</em></strong><em>. It is one of the most important parts of a computer that directly affects its performance and speed</em>.</p><h3>History of Physical Memory ?</h3><ul><li><strong><em>1940s</em></strong><em> — Early memory like </em><strong><em>Williams Tube</em></strong><em> and </em><strong><em>Magnetic Drum</em></strong><em> used electrostatic and magnetic storage.</em></li><li><strong><em>1950s</em></strong><em> — </em><strong><em>Magnetic Core Memory</em></strong><em> became the first widely used non-volatile memory.</em></li><li><strong><em>1960s</em></strong><em> — </em><strong><em>Semiconductor Memory</em></strong><em> (SRAM and DRAM) emerged, faster and more compact.</em></li><li><strong><em>1970</em></strong><em> — </em><strong><em>Intel 1103</em></strong><em> launched the first </em><strong><em>commercial DRAM chip</em></strong><em>, replacing core memory.</em></li><li><strong><em>1980s</em></strong><em> — Introduction of </em><strong><em>SIMMs</em></strong><em> and </em><strong><em>CMOS Memory</em></strong><em>, making upgrades easier.</em></li><li><strong><em>1990s</em></strong><em> — </em><strong><em>SDRAM</em></strong><em> and </em><strong><em>DIMMs</em></strong><em> standardized faster memory with synchronized clock cycles.</em></li><li><strong><em>2000s</em></strong><em> — </em><strong><em>DDR (Double Data Rate)</em></strong><em> memory improved speed and bandwidth (DDR, DDR2, DDR3).</em></li><li><strong><em>2010s</em></strong><em> — </em><strong><em>DDR4</em></strong><em> became mainstream, with high capacity and low power consumption.</em></li><li><strong><em>2020s</em></strong><em> — </em><strong><em>DDR5</em></strong><em>, </em><strong><em>HBM</em></strong><em>, and </em><strong><em>MRAM</em></strong><em> brought faster speeds and new non-volatile technologies.</em></li></ul><h3>How Physical Memory Works ?</h3><ul><li><strong><em>Temporary Storage</em></strong><em>: Physical memory holds data that the CPU needs quickly.</em></li><li><strong><em>Volatile</em></strong><em>: Physical memory is </em><strong><em>volatile</em></strong><em>, meaning it loses all data when the computer is turned off. That’s why your open programs disappear when you restart the computer.</em></li><li><strong><em>Fast Access</em></strong><em>: RAM is much faster than permanent storage (like SSDs or hard drives) because it provides </em><strong><em>quick access to frequently used data</em></strong>.</li></ul><h3>Why Use Physical Memory ?</h3><p><em>Physical memory, or </em><strong><em>RAM (Random Access Memory)</em></strong><em>, is essential for a computer to </em><strong><em>process data quickly and efficiently</em></strong><em>. Without physical memory, a computer would be extremely slow because it would have to rely only on its storage drives (SSD or HDD), which are much slower.</em></p><h3>Characteristics of Physical Memory</h3><ul><li><em>Volatile in nature, meaning data is lost when the power is turned off.</em></li><li><em>Offers high-speed data access, ensuring quick processing.</em></li><li><em>Serves as temporary storage, holding data and programs currently in use.</em></li><li><em>Supports multitasking by enabling simultaneous program execution.</em></li></ul><h3>. &gt; Virtual Memory</h3><h3>What is Virtual Memory</h3><p><strong><em>Virtual memory</em></strong><em> is a </em><strong><em>temporary storage space</em></strong><em> on a computer’s hard drive (HDD) or solid-state drive (SSD) that acts as </em><strong><em>an extension of physical memory (RAM)</em></strong><em> when the system runs out of available RAM. It allows the computer to handle more tasks or larger applications than the installed physical memory can accommodate.</em></p><p><em>In simple terms, virtual memory </em><strong><em>uses storage space</em></strong><em> as </em><strong><em>“extra RAM”</em></strong><em> to keep the computer running smoothly when physical RAM is full.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/753/1*wteLp4ygSVJ11Ba2vaKZBA.png" /></figure><h3>About Virtual Memory?</h3><p><strong><em>Virtual memory</em></strong><em> is a computer system feature that allows the operating system to </em><strong><em>use storage space (HDD or SSD) as if it were RAM</em></strong><em> when the physical memory (RAM) is full. It acts as </em><strong><em>an extension of physical memory</em></strong><em>, helping the system manage large tasks, run more applications simultaneously, and avoid performance issues like system crashes or slowdowns.</em></p><p><em>In simple terms, virtual memory </em><strong><em>temporarily stores data on the hard drive or SSD</em></strong><em> when the computer’s RAM cannot handle the workload. This enables the computer to run smoothly even when there isn’t enough physical memory available.</em></p><h3>History of Virtual Memory</h3><p><em>Before virtual memory, computers used RAM and secondary memory for data storage. Early computers used magnetic core in place of main memory and magnetic drums in place of secondary memory. In the 1940s and 1950s, computer memory was very expensive and limited in size. As programs became larger and more complex, developers had to worry that their programs might use up all the available memory and cause the computer to run out of space to work.</em></p><p><em>In those early days, if program was larger than available space then programmers use the concept of overlaying. If some portion of the code that is not currently used move to overlying if needed it back overwritten to memory this cause extensive programming. This is the reason for developing virtual memory.</em></p><p><em>In 1956, German physicist </em><strong><em>Fritz-Rudolf Güntsch</em></strong><em> develop virtual memory. The first real example of a virtual memory system was created at the University of Manchester in England while developing the Atlas computer. This system used a method called paging, which allowed virtual addresses (used by programs) to be mapped to the computer’s main memory. The Atlas computer was built in 1959 and started working in 1962.</em></p><p><em>The first computer with virtual memory was released by Burroughs Corp in 1961. This version of virtual memory do not using paging it oppose paging but support segmentation.</em></p><h3><strong>Types of Virtual Memory</strong></h3><p><strong><em>Paging</em></strong></p><ul><li><em>Divides memory into fixed-size blocks (pages).</em></li><li><em>Efficient memory management by swapping pages between RAM and disk.</em></li></ul><p><strong><em>Segmentation</em></strong></p><ul><li><em>Divides memory into variable-size segments based on logical structures (e.g., code, data).</em></li><li><em>Provides more logical view but is more complex than paging.</em></li></ul><p><strong><em>Paged Segmentation</em></strong></p><ul><li><em>Combines paging and segmentation.</em></li><li><em>Segments are divided into pages for more flexibility and better memory usage.</em></li></ul><p><strong><em>Demand Paging</em></strong></p><ul><li><em>Loads pages into memory only when needed.</em></li><li><em>Reduces the need for large physical memory.</em></li></ul><p><strong><em>Swapping</em></strong></p><ul><li><em>Entire processes are swapped between disk and RAM.</em></li><li><em>Used when the system runs out of physical memory.</em></li></ul><h3>Why Use Virtual Memory</h3><p><strong><em>Allows Running Large Programs</em></strong></p><ul><li><em>Programs can be larger than the available physical RAM.</em></li><li><em>Virtual memory enables the system to load only the required parts of a program into RAM, storing the rest on disk.</em></li></ul><p><strong><em>Increases Multitasking</em></strong></p><ul><li><em>Virtual memory allows multiple applications to run simultaneously by managing memory allocation efficiently.</em></li><li><em>It ensures that each program gets its required memory without conflict.</em></li></ul><p><strong><em>Efficient Use of Physical Memory</em></strong></p><ul><li><em>Virtual memory allows better utilization of limited physical memory by dynamically allocating memory as needed.</em></li><li><em>Unused parts of programs are stored on disk to free up RAM.</em></li></ul><h3><em>Characteristics of Virtual Memory</em></h3><ul><li><strong><em>Memory Abstraction</em></strong><em> — Provides more memory than physically available.</em></li><li><strong><em>Uses Secondary Storage</em></strong><em> — Extends RAM using disk space swap.</em></li><li><strong><em>Demand Paging</em></strong><em> — Loads data into RAM only when needed.</em></li><li><strong><em>Address Translation</em></strong><em> — Converts virtual addresses to physical addresses.</em></li><li><strong><em>Memory Isolation</em></strong><em> — Separates memory spaces for different processes.</em></li><li><strong><em>Memory Protection</em></strong><em> — Prevents unauthorized access to memory.</em></li></ul><h3>Why Secure Virtual Memory</h3><p><em>Secure virtual memory is important because it adds an extra layer of security by encrypting data that is temporarily stored on the hard drive as part of the virtual memory process, preventing unauthorized access to sensitive information even if someone were to physically access the hard drive, essentially protecting data that is swapped between RAM and the hard disk when system memory is full.</em></p><h3>Conclusions</h3><p><em>Physical memory (RAM) is the fast, limited storage directly accessed by the CPU to run active processes. It is volatile, meaning data is lost when the power is turned off. Virtual memory, on the other hand, extends the available memory by using disk space when physical memory is full. While it allows for running more programs than physically possible, it is slower since disk access is much slower than RAM. Virtual memory manages this through techniques like paging or swapping, moving data between RAM and disk to ensure processes continue running smoothly, although this comes with a performance trade-off due to slower data access. Together, physical and virtual memory balance system performance and multitasking capabilities.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6665814f3710" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>