<?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: Agam Singh</title>
    <description>The latest articles on DEV Community by Agam Singh (@agam_singh_2f66d3d454144d).</description>
    <link>https://dev.to/agam_singh_2f66d3d454144d</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2895414%2Fb8013a9e-0f17-43e9-81ea-1ec1f2646c75.jpg</url>
      <title>DEV Community: Agam Singh</title>
      <link>https://dev.to/agam_singh_2f66d3d454144d</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/agam_singh_2f66d3d454144d"/>
    <language>en</language>
    <item>
      <title>Agricultural Product Classification</title>
      <dc:creator>Agam Singh</dc:creator>
      <pubDate>Sun, 23 Feb 2025 11:30:08 +0000</pubDate>
      <link>https://dev.to/agam_singh_2f66d3d454144d/agricultural-product-classification-1nco</link>
      <guid>https://dev.to/agam_singh_2f66d3d454144d/agricultural-product-classification-1nco</guid>
      <description>&lt;p&gt;&lt;strong&gt;Agricultural Product Classification Using Machine Learning&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;🌾 Introduction&lt;br&gt;
Agriculture plays a vital role in feeding the global population, making it essential to improve productivity and efficiency in this sector. One of the key challenges in modern agriculture is the accurate classification of agricultural products, which directly impacts quality control, pricing, and supply chain management. Traditional methods of classification often rely on manual inspection, which can be time-consuming and prone to errors.&lt;/p&gt;

&lt;p&gt;With the rise of data-driven technologies, Machine Learning (ML) offers a powerful alternative to automate and enhance agricultural product classification. By analyzing dimensional and shape factors, ML algorithms can accurately classify various agricultural products, reducing manual labor and increasing efficiency. This project explores how machine learning techniques can be applied to classify agricultural products using real-world data, leading to smarter agricultural practices and better decision-making.&lt;/p&gt;

&lt;p&gt;📊 Project Overview&lt;br&gt;
This project focuses on classifying agricultural products based on dimensional and shape factors using machine learning. The goal is to develop an accurate and efficient classification system by exploring data preprocessing techniques, visualizations, and multiple machine learning algorithms.&lt;/p&gt;

&lt;p&gt;📁 Dataset&lt;br&gt;
Note: The Data was taken from&lt;/p&gt;

&lt;p&gt;&lt;a href="https://docs.google.com/spreadsheets/d/1sSndhD8mKBppcsMw8TiKUR4fzxtTlabK/edit?usp=sharing&amp;amp;ouid=116447350445311431259&amp;amp;rtpof=true&amp;amp;sd=true" rel="noopener noreferrer"&gt;https://docs.google.com/spreadsheets/d/1sSndhD8mKBppcsMw8TiKUR4fzxtTlabK/edit?usp=sharing&amp;amp;ouid=116447350445311431259&amp;amp;rtpof=true&amp;amp;sd=true&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Entries: 13,611&lt;br&gt;
Columns: 17&lt;br&gt;
Data Types: 14 float64, 2 int64, 1 object&lt;br&gt;
The dataset contains detailed information about agricultural plants, including area, perimeter, major axis length, and shape factors. Preprocessing steps included:&lt;/p&gt;

&lt;p&gt;Removing 68 duplicate entries.&lt;br&gt;
Encoding the categorical ‘Class’ column.&lt;br&gt;
Ensuring no missing values.&lt;/p&gt;

&lt;p&gt;📊 Data Preprocessing&lt;br&gt;
Data Cleaning: Removed duplicates and encoded categorical data.&lt;br&gt;
Feature Scaling: Applied standard scaling for improved model performance.&lt;br&gt;
Data Splitting: Divided the dataset into training and testing sets.&lt;/p&gt;

&lt;p&gt;📈 Data Visualization&lt;br&gt;
Utilized Matplotlib and Seaborn for:&lt;/p&gt;

&lt;p&gt;Pair Plots: To visualize feature relationships.&lt;br&gt;
Histograms &amp;amp; Distribution Plots: To understand feature distributions.&lt;br&gt;
Scatter Plots: To observe trends and correlations.&lt;br&gt;
Heatmap: To display feature correlation.&lt;br&gt;
Box Plots: To examine feature distribution across classes.&lt;/p&gt;

&lt;p&gt;🤖 Machine Learning Models Used&lt;br&gt;
Random Forest Classifier&lt;br&gt;
Accuracy: 91.47%&lt;br&gt;
Precision: 92.65%&lt;br&gt;
Recall: 91.59%&lt;br&gt;
F1-Score: 92.12%&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;K-Nearest Neighbors (KNN) (Best Performer)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Accuracy: 91.95%&lt;br&gt;
Precision: 92.62%&lt;br&gt;
Recall: 92.20%&lt;br&gt;
F1-Score: 92.41%&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Support Vector Classifier (SVC)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Accuracy: 87.93%&lt;br&gt;
Precision: 92.62%&lt;br&gt;
Recall: 92.20%&lt;br&gt;
F1-Score: 92.41%&lt;/p&gt;

&lt;p&gt;⚖️ Model Comparison&lt;br&gt;
KNN outperformed the other models, making it the most suitable for classifying agricultural products in this project.&lt;br&gt;
Random Forest followed closely, while SVC showed comparatively lower accuracy.&lt;/p&gt;

&lt;p&gt;🤖 Model Training &amp;amp; Evaluation&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
from sklearn.ensemble import RandomForestClassifier
from sklearn.neighbors import KNeighborsClassifier
from sklearn.svm import SVC
from sklearn.metrics import accuracy_score, precision_score, recall_score, f1_score, confusion_matrix

# Feature and target split
X = df.drop(['Class_BO', 'Class_CA', 'Class_DE', 'Class_HO', 'Class_SE', 'Class_SI'], axis=1)
y = df[['Class_BO', 'Class_CA', 'Class_DE', 'Class_HO', 'Class_SE', 'Class_SI']]

# Train-test split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)

# Scaling
scaler = StandardScaler()
X_train = scaler.fit_transform(X_train)
X_test = scaler.transform(X_test)

# Random Forest
rf = RandomForestClassifier(random_state=42)
rf.fit(X_train, y_train)
y_pred_rf = rf.predict(X_test)
print("Random Forest Accuracy:", accuracy_score(y_test, y_pred_rf))

# KNN
knn = KNeighborsClassifier()
knn.fit(X_train, y_train)
y_pred_knn = knn.predict(X_test)
print("KNN Accuracy:", accuracy_score(y_test, y_pred_knn))

# SVC
svc = SVC(kernel='linear')
svc.fit(X_train, y_train)
y_pred_svc = svc.predict(X_test)
print("SVC Accuracy:", accuracy_score(y_test, y_pred_svc))

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

&lt;/div&gt;



&lt;p&gt;✅ Conclusion&lt;br&gt;
This project demonstrates how machine learning can be applied to classify agricultural products based on shape and dimensional factors. The KNN model proved to be the most effective, showcasing strong performance across all evaluation metrics.&lt;/p&gt;

&lt;p&gt;🛠️ Tools &amp;amp; Technologies Used&lt;br&gt;
Python&lt;br&gt;
Jupyter Notebook&lt;br&gt;
Pandas &amp;amp; NumPy: Data preprocessing&lt;br&gt;
Matplotlib &amp;amp; Seaborn: Data visualization&lt;br&gt;
Scikit-learn: Machine learning algorithms and evaluation&lt;/p&gt;

</description>
      <category>programming</category>
      <category>python</category>
      <category>machinelearning</category>
      <category>datascience</category>
    </item>
  </channel>
</rss>
