Downloads · 30 days
0
mltrev23/xgboost_rice_model
xgboost_rice_model is a machine learning model from mltrev23. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
This repository contains an XGBoost-based model trained to classify rice grains using the mltrev23/Rice-classification dataset. The model is designed to predict the type of rice grain based on various geometric and mo…
Downloads · 30 days
0
Access
Public
Updated Sep 4, 2024
Repo size
112 KB
Likes
0
Public
Click a slice to open those files.
.pkl112 KB · 96%
From the Hugging Face model README
This repository contains an XGBoost-based model trained to classify rice grains using the mltrev23/Rice-classification dataset. The model is designed to predict the type of rice grain based on various geometric and morphological features. XGBoost (eXtreme Gradient Boosting) is a powerful, efficient, and scalable machine learning algorithm that excels at handling structured data.
mltrev23/Rice-classification dataset.
Area, MajorAxisLength, MinorAxisLength, Eccentricity, ConvexArea, EquivDiameter, Extent, Perimeter, Roundness, and AspectRation.Class, a binary label indicating the type of rice grain.(Replace the placeholders with actual values after evaluating the model on your test data.)
To run the model, you'll need the following Python libraries:
pip install xgboost
pip install pandas
pip install numpy
pip install scikit-learn
You can load the trained model using the following code snippet:
import xgboost as xgb
# Load the trained model
model = xgb.Booster()
model.load_model('rice_classification_xgboost.model')
To make predictions with the model, use the following code:
import pandas as pd
# Example input data (replace with your actual data)
data = pd.DataFrame({
'Area': [4537, 2872],
'MajorAxisLength': [92.23, 74.69],
'MinorAxisLength': [64.01, 51.40],
'Eccentricity': [0.72, 0.73],
'ConvexArea': [4677, 3015],
'EquivDiameter': [76.00, 60.47],
'Extent': [0.66, 0.71],
'Perimeter': [273.08, 208.32],
'Roundness': [0.76, 0.83],
'AspectRation': [1.44, 1.45]
})
# Convert DataFrame to DMatrix for XGBoost
dtest = xgb.DMatrix(data)
# Predict class
predictions = model.predict(dtest)
You can evaluate the model's performance on a test dataset using standard metrics like accuracy, precision, recall, and F1-score:
from sklearn.metrics import accuracy_score, precision_score, recall_score, f1_score
# Assuming you have ground truth labels and predictions
y_true = [1, 0] # Replace with your actual labels
y_pred = predictions.round() # XGBoost predictions may need to be rounded
print("Accuracy:", accuracy_score(y_true, y_pred))
print("Precision:", precision_score(y_true, y_pred))
print("Recall:", recall_score(y_true, y_pred))
print("F1 Score:", f1_score(y_true, y_pred))
For understanding feature importance in the XGBoost model:
import matplotlib.pyplot as plt
# Plot feature importance
xgb.plot_importance(model)
plt.show()
If you use this model in your research, please cite the dataset and the following reference for XGBoost:
mltrev23/Rice-classification