<?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: Tharun Prakash</title>
    <description>The latest articles on DEV Community by Tharun Prakash (@tharun801).</description>
    <link>https://dev.to/tharun801</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%2F3104122%2Feaa5063e-800d-4fbd-af1f-75e536d74a78.png</url>
      <title>DEV Community: Tharun Prakash</title>
      <link>https://dev.to/tharun801</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/tharun801"/>
    <language>en</language>
    <item>
      <title>Dockerize and Share Your ML Model</title>
      <dc:creator>Tharun Prakash</dc:creator>
      <pubDate>Tue, 29 Apr 2025 04:50:41 +0000</pubDate>
      <link>https://dev.to/tharun801/dockerize-and-share-your-ml-model-2did</link>
      <guid>https://dev.to/tharun801/dockerize-and-share-your-ml-model-2did</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;
Here’s the Dockerfile we’re using:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# 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;p&gt;Use a slim Python base image&lt;br&gt;
Copy your local files&lt;br&gt;
Install all dependencies&lt;br&gt;
Run model.py on container start&lt;br&gt;
🧪 What model.py Does&lt;/p&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;🔨 Step-by-Step: Build, Tag, and Push to DockerHub&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 tharun801/24mcr116: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 tharun801/24mcr116:latest&lt;/code&gt;&lt;/p&gt;

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

&lt;p&gt;📚 Resources&lt;/p&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;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;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;

</description>
    </item>
    <item>
      <title>Git-Hub Commands</title>
      <dc:creator>Tharun Prakash</dc:creator>
      <pubDate>Tue, 29 Apr 2025 04:42:25 +0000</pubDate>
      <link>https://dev.to/tharun801/git-hub-commands-5dpf</link>
      <guid>https://dev.to/tharun801/git-hub-commands-5dpf</guid>
      <description>&lt;p&gt;Initialize a Git repository:&lt;br&gt;
&lt;code&gt;git init&lt;/code&gt;&lt;br&gt;
Creates a new Git repository in the folder 24MCR116.&lt;/p&gt;

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

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

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

&lt;p&gt;View commit log:&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;Add remote GitHub repository:&lt;br&gt;
&lt;code&gt;git remote add origin https://github.com/tharunp242/24MCR116.git&lt;/code&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;
&lt;code&gt;git branch&lt;/code&gt;&lt;br&gt;
Shows the current branch is master.&lt;/p&gt;

&lt;p&gt;Rename branch from master to main:&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;Set Git global config for email and username:&lt;br&gt;
&lt;code&gt;git config --global user.email "tharunp242@gmail.com"&lt;/code&gt;&lt;br&gt;
&lt;code&gt;git config --global user.name "tharunp242"&lt;/code&gt;&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;
&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;Then , Again We will Modify or add new file means we need to follow the same steps, like&lt;/p&gt;

&lt;p&gt;&lt;code&gt;git add .&lt;/code&gt;&lt;br&gt;
&lt;code&gt;git commit -m “message”&lt;/code&gt;&lt;br&gt;
&lt;code&gt;git push origin main&lt;/code&gt;&lt;/p&gt;

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