<?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: SATHISH</title>
    <description>The latest articles on DEV Community by SATHISH (@sathish_11a006c343cb71763).</description>
    <link>https://dev.to/sathish_11a006c343cb71763</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%2F3082363%2Ffe06e768-c5e9-4d04-93a3-abfe2e68fa22.jpg</url>
      <title>DEV Community: SATHISH</title>
      <link>https://dev.to/sathish_11a006c343cb71763</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sathish_11a006c343cb71763"/>
    <language>en</language>
    <item>
      <title>🚀 Dockerizing a Machine Learning Model 🧠🐳Creating Dockerfile 📄Building Image 🏗️ and Pushing to Docker Hub ☁️📦</title>
      <dc:creator>SATHISH</dc:creator>
      <pubDate>Sat, 26 Apr 2025 04:16:41 +0000</pubDate>
      <link>https://dev.to/sathish_11a006c343cb71763/dockerizing-a-machine-learning-model-creating-dockerfile-building-image-and-pushing-to-3pm0</link>
      <guid>https://dev.to/sathish_11a006c343cb71763/dockerizing-a-machine-learning-model-creating-dockerfile-building-image-and-pushing-to-3pm0</guid>
      <description>&lt;p&gt;📦 Project Structure&lt;br&gt;
Here’s what our folder looks like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ml-docker-project/
         ├── Dockerfile
         ├── model.py
         └── Iris.csv
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;🐳 Dockerfile Breakdown&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Here’s the Dockerfile we’re using:
# Use the official Python image as a base
FROM python:3.12-slim

# Set working directory inside the container
WORKDIR /app

# Copy all files from the local machine to the container
COPY . .

# Install required Python packages
RUN pip install --no-cache-dir pandas scikit-learn matplotlib

# Command to run your Python script
CMD ["python", "model.py"]

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use a slim Python base image&lt;/li&gt;
&lt;li&gt;Copy your local files&lt;/li&gt;
&lt;li&gt;Install all dependencies&lt;/li&gt;
&lt;li&gt;Run model.py on container start
🧪 What model.py Does&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The script:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
from pandas import read_csv
from matplotlib import pyplot
from sklearn.linear_model import LogisticRegression
from sklearn.model_selection import train_test_split
import joblib

# Step 1: Load dataset
filename = "Iris.csv"
data = read_csv(filename)

# Step 2: Display data shape and preview
print("Shape of the dataset:", data.shape)
print("First 20 rows:\n", data.head(20))

# Step 3: Plot and save histograms silently
data.hist()
pyplot.savefig("histograms.png")
pyplot.close()  # Close the plot so it doesn't show up in prompt

# Step 4: Plot and save density plots silently
data.plot(kind='density', subplots=True, layout=(3,3), sharex=False)
pyplot.savefig("density_plots.png")
pyplot.close()

# Step 5: Convert to NumPy array and extract features/labels
array = data.values
X = array[:, 1:5]  # Features: Sepal/Petal measurements
Y = array[:, 5]    # Target: Species

# Step 6: Split data into training (67%) and testing (33%)
test_size = 0.33
seed = 7
X_train, X_test, Y_train, Y_test = train_test_split(X, Y, test_size=test_size, random_state=seed)

# Step 7: Create and train logistic regression model
model = LogisticRegression(max_iter=200)
model.fit(X_train, Y_train)

# Step 8: Evaluate and display accuracy
result = model.score(X_test, Y_test)
print("Accuracy: {:.2f}%".format(result * 100))

# Step 9: Save the trained model to a file
joblib.dump(model, "logistic_model.pkl")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Visualizes the data (and saves plots)&lt;/p&gt;

&lt;p&gt;Trains a Logistic Regression model&lt;/p&gt;

&lt;p&gt;Evaluates it&lt;/p&gt;

&lt;p&gt;Saves the model as logistic_model.pkl&lt;/p&gt;

&lt;p&gt;It’s a full training pipeline, ready to be reproduced in any environment that runs Docker. 💪&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🔨 Step-by-Step: Build, Tag, and Push to DockerHub&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;1️⃣ Build the Docker Image&lt;br&gt;
From your project directory:&lt;br&gt;
&lt;code&gt;docker build -t sathishs021/24mcr093:latest .&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;2️⃣ Log in to DockerHub&lt;br&gt;
&lt;code&gt;docker login&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;3️⃣ Push the Image&lt;br&gt;
&lt;code&gt;docker push sathishs021/24mcr093:latest&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;4️⃣ Then create the Dockerfile&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7j9ut7oosoom0ox55dtu.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/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7j9ut7oosoom0ox55dtu.png" alt="Image description" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;📚 Resources&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;🐳 Docker for ML Projects&lt;br&gt;
&lt;a href="https://docs.docker.com/language/python/" rel="noopener noreferrer"&gt;https://docs.docker.com/language/python/&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;🤖 scikit-learn Docs&lt;br&gt;
&lt;a href="https://scikit-learn.org/stable/" rel="noopener noreferrer"&gt;https://scikit-learn.org/stable/&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;📊 matplotlib Gallery&lt;br&gt;
&lt;a href="https://matplotlib.org/stable/gallery/index.html" rel="noopener noreferrer"&gt;https://matplotlib.org/stable/gallery/index.html&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
    <item>
      <title>GITHUB COMMANDS</title>
      <dc:creator>SATHISH</dc:creator>
      <pubDate>Thu, 24 Apr 2025 08:13:54 +0000</pubDate>
      <link>https://dev.to/sathish_11a006c343cb71763/github-commands-88p</link>
      <guid>https://dev.to/sathish_11a006c343cb71763/github-commands-88p</guid>
      <description>&lt;p&gt;&lt;strong&gt;Initialize a Git repository:&lt;/strong&gt;&lt;br&gt;
    &lt;code&gt;git init&lt;/code&gt;&lt;br&gt;
Creates a new Git repository in the folder 24MCR093.&lt;/p&gt;

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

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

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

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

&lt;p&gt;&lt;strong&gt;Add remote GitHub repository:&lt;/strong&gt;&lt;br&gt;
    &lt;code&gt;git remote add origin https://github.com/sathish-s704/24MCR093.git&lt;/code&gt;&lt;br&gt;
Links the local repository to a remote GitHub repo.&lt;/p&gt;

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

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

&lt;p&gt;&lt;strong&gt;Set Git global config for email and username:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git config --global user.email "sathishsathish75363@gmail.com"&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git config --global user.name "sathish-s704"&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Sets your global Git identity.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Push code to remote repo for the first time:&lt;/strong&gt;&lt;br&gt;
    &lt;code&gt;git push -u origin main&lt;/code&gt;&lt;br&gt;
Pushes the main branch to GitHub and sets upstream tracking.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw33qifxeu4ueghsc8v80.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/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fw33qifxeu4ueghsc8v80.png" alt="Image description" width="800" height="693"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqlwnh178qvi083x6chv4.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/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqlwnh178qvi083x6chv4.png" alt="Image description" width="800" height="404"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;p&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>
