<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Gowtham</title>
    <description>The latest articles on DEV Community by Gowtham (@gowtham_001).</description>
    <link>https://dev.to/gowtham_001</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3082060%2Fb2db74b5-c9fb-49f8-8de4-5946c8dfc4cd.jpg</url>
      <title>DEV Community: Gowtham</title>
      <link>https://dev.to/gowtham_001</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/gowtham_001"/>
    <language>en</language>
    <item>
      <title>How to Create a Docker Image and Push It to DockerHub</title>
      <dc:creator>Gowtham</dc:creator>
      <pubDate>Mon, 28 Apr 2025 17:52:55 +0000</pubDate>
      <link>https://dev.to/gowtham_001/how-to-create-a-docker-image-and-push-it-to-dockerhub-3f6c</link>
      <guid>https://dev.to/gowtham_001/how-to-create-a-docker-image-and-push-it-to-dockerhub-3f6c</guid>
      <description>&lt;p&gt;Perfect!&lt;br&gt;&lt;br&gt;
You updated the Python file to hello_world_ml.py and added a &lt;em&gt;machine learning&lt;/em&gt; logic using Iris dataset, logistic regression, and saving a model.&lt;/p&gt;

&lt;p&gt;I'll now update the full Dev.to article accordingly.&lt;br&gt;&lt;br&gt;
Here’s the new polished version ready for your post: 🚀&lt;/p&gt;




&lt;h1&gt;
  
  
  🚀 How to Dockerize a Simple Machine Learning App and Push It to DockerHub
&lt;/h1&gt;

&lt;p&gt;Hey devs! 👋&lt;/p&gt;

&lt;p&gt;In this post, I'll show you how to create a Docker image for a simple &lt;em&gt;Machine Learning&lt;/em&gt; Python app and push it to DockerHub. 🚀&lt;/p&gt;

&lt;p&gt;We’ll create a small ML project using the Iris dataset, logistic regression, and model saving.&lt;/p&gt;

&lt;p&gt;Let’s get started! 🐳&lt;/p&gt;




&lt;h2&gt;
  
  
  1️⃣ Create a Python App
&lt;/h2&gt;

&lt;p&gt;First, create a Python file named hello_world_ml.py with the following code:&lt;/p&gt;

&lt;p&gt;python&lt;br&gt;
from pandas import read_csv&lt;br&gt;
from matplotlib import pyplot&lt;br&gt;
from sklearn.linear_model import LogisticRegression&lt;br&gt;
from sklearn.model_selection import train_test_split&lt;br&gt;
import joblib&lt;/p&gt;

&lt;h1&gt;
  
  
  Step 1: Load dataset
&lt;/h1&gt;

&lt;p&gt;filename = "Iris.csv"&lt;br&gt;
data = read_csv(filename)&lt;/p&gt;

&lt;h1&gt;
  
  
  Step 2: Display data shape and preview
&lt;/h1&gt;

&lt;p&gt;print("Shape of the dataset:", data.shape)&lt;br&gt;
print("First 20 rows:\n", data.head(20))&lt;/p&gt;

&lt;h1&gt;
  
  
  Step 3: Plot and save histograms silently
&lt;/h1&gt;

&lt;p&gt;data.hist()&lt;br&gt;
pyplot.savefig("histograms.png")&lt;br&gt;
pyplot.close()&lt;/p&gt;

&lt;h1&gt;
  
  
  Step 4: Plot and save density plots silently
&lt;/h1&gt;

&lt;p&gt;data.plot(kind='density', subplots=True, layout=(3,3), sharex=False)&lt;br&gt;
pyplot.savefig("density_plots.png")&lt;br&gt;
pyplot.close()&lt;/p&gt;

&lt;h1&gt;
  
  
  Step 5: Convert to NumPy array and extract features/labels
&lt;/h1&gt;

&lt;p&gt;array = data.values&lt;br&gt;
X = array[:, 1:5]  # Features&lt;br&gt;
Y = array[:, 5]    # Labels&lt;/p&gt;

&lt;h1&gt;
  
  
  Step 6: Split data into training and testing
&lt;/h1&gt;

&lt;p&gt;test_size = 0.33&lt;br&gt;
seed = 7&lt;br&gt;
X_train, X_test, Y_train, Y_test = train_test_split(X, Y, test_size=test_size, random_state=seed)&lt;/p&gt;

&lt;h1&gt;
  
  
  Step 7: Create and train logistic regression model
&lt;/h1&gt;

&lt;p&gt;model = LogisticRegression(max_iter=200)&lt;br&gt;
model.fit(X_train, Y_train)&lt;/p&gt;

&lt;h1&gt;
  
  
  Step 8: Evaluate and display accuracy
&lt;/h1&gt;

&lt;p&gt;result = model.score(X_test, Y_test)&lt;br&gt;
print("Accuracy: {:.2f}%".format(result * 100))&lt;/p&gt;

&lt;h1&gt;
  
  
  Step 9: Save the trained model to a file
&lt;/h1&gt;

&lt;p&gt;joblib.dump(model, "logistic_model.pkl")&lt;/p&gt;

&lt;p&gt;✅ Make sure you also have the Iris.csv dataset in the same folder.&lt;/p&gt;




&lt;h2&gt;
  
  
  2️⃣ Create a Dockerfile
&lt;/h2&gt;

&lt;p&gt;Next, create a file named Dockerfile in the same directory:&lt;/p&gt;

&lt;p&gt;dockerfile&lt;/p&gt;

&lt;h1&gt;
  
  
  Use a lightweight Python image
&lt;/h1&gt;

&lt;p&gt;FROM python:3.12-slim&lt;/p&gt;

&lt;h1&gt;
  
  
  Set the working directory
&lt;/h1&gt;

&lt;p&gt;WORKDIR /app&lt;/p&gt;

&lt;h1&gt;
  
  
  Copy all files into the container
&lt;/h1&gt;

&lt;p&gt;COPY . .&lt;/p&gt;

&lt;h1&gt;
  
  
  Install required libraries
&lt;/h1&gt;

&lt;p&gt;RUN pip install pandas matplotlib scikit-learn joblib&lt;/p&gt;

&lt;h1&gt;
  
  
  Define the command to run the app
&lt;/h1&gt;

&lt;p&gt;CMD ["python", "hello_world_ml.py"]&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Explanation:&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Base image: Python 3.12 slim.&lt;/li&gt;
&lt;li&gt;Working directory: /app.&lt;/li&gt;
&lt;li&gt;Installs all necessary Python libraries.&lt;/li&gt;
&lt;li&gt;Runs the hello_world_ml.py script when container starts.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  3️⃣ Build the Docker Image
&lt;/h2&gt;

&lt;p&gt;Open your terminal, navigate to your project folder, and run:&lt;/p&gt;

&lt;p&gt;bash&lt;br&gt;
docker build -t your-dockerhub-username/ml-docker-app:latest .&lt;/p&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;p&gt;bash&lt;br&gt;
docker build -t myusername/ml-docker-app:latest .&lt;/p&gt;

&lt;p&gt;✅ This command builds the Docker image and tags it.&lt;/p&gt;




&lt;h2&gt;
  
  
  4️⃣ Login to DockerHub
&lt;/h2&gt;

&lt;p&gt;If not already logged in, run:&lt;/p&gt;

&lt;p&gt;bash&lt;br&gt;
docker login&lt;/p&gt;

&lt;p&gt;Enter your &lt;em&gt;DockerHub username&lt;/em&gt; and &lt;em&gt;password&lt;/em&gt; when prompted.&lt;/p&gt;




&lt;h2&gt;
  
  
  5️⃣ Push the Docker Image to DockerHub
&lt;/h2&gt;

&lt;p&gt;After building and logging in, push the image:&lt;/p&gt;

&lt;p&gt;bash&lt;br&gt;
docker push your-dockerhub-username/ml-docker-app:latest&lt;/p&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;p&gt;bash&lt;br&gt;
docker push Gowtham/ml-docker-app:latest&lt;/p&gt;

&lt;p&gt;✅ This uploads your image to your DockerHub repository.&lt;/p&gt;




&lt;h2&gt;
  
  
  6️⃣ Pull and Run the Image from Anywhere
&lt;/h2&gt;

&lt;p&gt;Anyone can now pull and run your ML app like this:&lt;/p&gt;

&lt;p&gt;bash&lt;br&gt;
docker pull Gowtham/ml-docker-app:latest&lt;br&gt;
docker run Gowtham/ml-docker-app:latest&lt;/p&gt;

&lt;p&gt;🎯 The container will load the Iris dataset, train a logistic regression model, save graphs, and display model accuracy!&lt;/p&gt;

&lt;p&gt;Example output:&lt;/p&gt;

&lt;p&gt;Shape of the dataset: (150, 6)&lt;br&gt;
First 20 rows:&lt;br&gt;
    Id  SepalLengthCm  SepalWidthCm  PetalLengthCm  PetalWidthCm      Species&lt;br&gt;
0   1            5.1           3.5            1.4           0.2  Iris-setosa&lt;br&gt;
...&lt;br&gt;
Accuracy: 94.00%&lt;/p&gt;

&lt;p&gt;—&lt;/p&gt;

&lt;h1&gt;
  
  
  🔥 Final Tips
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;Add .dockerignore to avoid copying unnecessary files.&lt;/li&gt;
&lt;li&gt;Keep your Docker images lightweight.&lt;/li&gt;
&lt;li&gt;Make sure your Iris.csv is included while copying files (COPY . . does this).&lt;/li&gt;
&lt;li&gt;You can extend this with Flask API for serving predictions!&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;—&lt;/p&gt;

&lt;h1&gt;
  
  
  📢 That's it!
&lt;/h1&gt;

&lt;p&gt;You now know how to Dockerize a Machine Learning Python app and share it worldwide via DockerHub. 🐳✨&lt;br&gt;&lt;br&gt;
If you found this helpful, smash that ❤ and share it with your dev friends!&lt;/p&gt;

&lt;p&gt;Until next time, Happy Coding! 🚀&lt;/p&gt;




&lt;p&gt;Would you also like me to give you some bonus ideas 💡 to extend this post (like "how to serve the trained model using Flask inside Docker") to make an even bigger article series on Dev.to? 🎯&lt;br&gt;&lt;br&gt;
It could really help you build a following! 🚀&lt;/p&gt;

</description>
    </item>
    <item>
      <title>ML day2</title>
      <dc:creator>Gowtham</dc:creator>
      <pubDate>Mon, 28 Apr 2025 17:48:03 +0000</pubDate>
      <link>https://dev.to/gowtham_001/ml-day2-moc</link>
      <guid>https://dev.to/gowtham_001/ml-day2-moc</guid>
      <description>&lt;h2&gt;
  
  
  1 GenAI Certification
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Add the certification screenshot here:
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/.%2Fimages%2Fimage.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/.%2Fimages%2Fimage.png" alt="GenAI Certificate" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Certification Screenshot: &lt;em&gt;Uploaded Successfully&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Add the Accredible badge link here:
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://credentials.databricks.com/c755fd26-e756-4276-9718-0aaa546575d7#acc.PSEF70tk" rel="noopener noreferrer"&gt;Accredible Badge Link&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  2 Environment Setup
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Git Installation:
&lt;/h3&gt;

&lt;p&gt;brew install git&lt;/p&gt;

&lt;p&gt;Git installed successfully (Verified with git --version).&lt;/p&gt;

&lt;h3&gt;
  
  
  GitHub Account Username
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;Gowthamm&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  VSCode Installation
&lt;/h3&gt;

&lt;p&gt;brew install --cask visual-studio-code&lt;/p&gt;

&lt;p&gt;code&lt;/p&gt;

&lt;p&gt;VSCode installed successfully (Verified opening the editor).&lt;/p&gt;

&lt;h3&gt;
  
  
  Python Installation
&lt;/h3&gt;

&lt;p&gt;brew update&lt;/p&gt;

&lt;p&gt;brew install python&lt;/p&gt;

&lt;p&gt;Python installed successfully (Verified with python --version).&lt;/p&gt;

&lt;h3&gt;
  
  
  Docker Desktop Installation
&lt;/h3&gt;

&lt;p&gt;brew update&lt;/p&gt;

&lt;p&gt;brew install --cask docker&lt;/p&gt;

&lt;p&gt;docker --version&lt;/p&gt;

&lt;p&gt;Docker Desktop installed successfully (Verified Docker is running).&lt;/p&gt;

&lt;h3&gt;
  
  
  DockerHub Account Username
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;Gowthamm&lt;/em&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  3 Impromptu Learning
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Add the Impromptu Learning topic that you shared in the classroom:
&lt;/h3&gt;

&lt;p&gt;ML Model Training Explained With Practical&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Understanding Git Internals: How Git Tracks Changes at the Backend&lt;/em&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  4 Dev.to Blog
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Share the Dev.to blog URL for the Git / GitHub documentation:
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://dev.to/Gowthamm/step-by-step-git-commands-for-first-time-repo-setup-with-github-42ik"&gt;My Dev.to Blog on Git and GitHub&lt;/a&gt;&lt;/p&gt;




</description>
    </item>
    <item>
      <title>ML day1</title>
      <dc:creator>Gowtham</dc:creator>
      <pubDate>Thu, 24 Apr 2025 03:55:46 +0000</pubDate>
      <link>https://dev.to/gowtham_001/ml-day1-4ipe</link>
      <guid>https://dev.to/gowtham_001/ml-day1-4ipe</guid>
      <description>&lt;p&gt;Step-by-Step Git Commands Execution:&lt;br&gt;
Initialize a Git repository:&lt;br&gt;
    git init&lt;br&gt;
Creates a new Git repository in the folder 24MCR028.&lt;/p&gt;

&lt;p&gt;Add a file to staging area:&lt;br&gt;
    git add 24MCR028.txt&lt;br&gt;
Adds 24MCR028.txt to the staging area.&lt;/p&gt;

&lt;p&gt;Commit the file:&lt;br&gt;
    git commit -m "Added Personal Details"&lt;br&gt;
Creates a commit with the message "Added Personal Details".&lt;/p&gt;

&lt;p&gt;Check Git status:&lt;br&gt;
     git status&lt;br&gt;
Shows that 24MCR028.txt has been modified but not staged.&lt;/p&gt;

&lt;p&gt;View commit log:&lt;br&gt;
     git log&lt;br&gt;
Displays the commit history (one commit at this point).&lt;/p&gt;

&lt;p&gt;Add remote GitHub repository:&lt;br&gt;
     git remote add origin &lt;a href="https://github.com/gowthammady/24MCR028.git" rel="noopener noreferrer"&gt;https://github.com/gowthammady/24MCR028.git&lt;/a&gt;&lt;br&gt;
Links the local repository to a remote GitHub repo.&lt;/p&gt;

&lt;p&gt;Check current branch:&lt;br&gt;
     git branch&lt;br&gt;
Shows the current branch is master.&lt;/p&gt;

&lt;p&gt;Rename branch from master to main:&lt;br&gt;
     git branch -M main&lt;br&gt;
Renames the current branch to main.&lt;/p&gt;

&lt;p&gt;Set Git global config for email and username:&lt;br&gt;
    git config --global user.email "&lt;a href="mailto:gowtimady@gmail.com"&gt;gowtimady@gmail.com&lt;/a&gt;"&lt;br&gt;
git config --global user.name "gowthammady"&lt;br&gt;
Sets your global Git identity.&lt;/p&gt;

&lt;p&gt;Push code to remote repo for the first time:&lt;br&gt;
     git push -u origin main&lt;/p&gt;

&lt;p&gt;Pushes the main branch to GitHub and sets upstream tracking.&lt;br&gt;
Then , Again We will Modify or add new file means we need to follow the same steps, like&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git add .
git commit -m “message”
git push origin main
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
    </item>
  </channel>
</rss>
