Prasad Chaskar's other Models Reports

Major Concepts

 

Sign-Up/Login to access Several ML Models and also Deploy & Monetize your own ML solutions for free

Models Home » Domain Usecases » Others » Crab Age Prediction

Crab Age Prediction

Models Status

Model Overview


Crab farming is a major aquaculture activity as there is a huge consumption demand of crabs in India. Commercial crab farming is a growing business in coastal areas of India and is looking profitable. Mud crab is highly popular due to its great demand in the export market. The commercial scale mud crab culture is developing fast along the coastal areas of Andhra Pradesh, Tamil Nadu, Kerala and Karnataka.

Problem Statement : 
For a commercial crab farmer knowing the right age of the crab helps them decide if and when to harvest the crabs. Beyond a certain age, there is negligible growth in crab’s physical characteristics and hence, it is important to time the harvesting to reduce cost and increase profit.

Dataset Link : https://www.kaggle.com/sidhus/crab-age-prediction
About Dataset Features : 












Let's look at the code
Import Libraries :

#pandas
import pandas as pd

#numpy
import numpy as np

#seaborn
import seaborn as sns

#matplotlib
import matplotlib.pyplot as plt

#sklearn
from sklearn.model_selection import train_test_split
from sklearn import metrics
from sklearn.linear_model import LinearRegression​

title_sz = 20
x_ = 10
y_ = 8​

Load Dataset : 


data = pd.read_csv('CrabAgePrediction.csv')
data.head()


Exploratory Data Analysis : 


plt.figure(figsize=(x_,y_))
sns.countplot(x='Sex',data=data);
plt.title("Distribution of Feature Sex",{'fontsize':title_sz});


female_crab = data[data.Sex == 'F']
male_crab = data[data.Sex == 'M']

fig, axes = plt.subplots(1, 3, figsize=(15, 5), sharey=True)
sns.histplot(ax=axes[0], x=female_crab['Length'],color='b');
axes[0].set_title("Length");

sns.histplot(ax=axes[1], x=female_crab['Diameter'],color='b');
axes[1].set_title("Diameter");

sns.histplot(ax=axes[2], x=female_crab['Weight'],color='b');
axes[2].set_title("Weight");




fig, axes = plt.subplots(1, 3, figsize=(15, 5), sharey=True)
sns.histplot(ax=axes[0], x=male_crab['Length'],color='b');
axes[0].set_title("Length");

sns.histplot(ax=axes[1], x=male_crab['Diameter'],color='b');
axes[1].set_title("Diameter");

sns.histplot(ax=axes[2], x=male_crab['Weight'],color='b');
axes[2].set_title("Weight");


Length Vs Age :


plt.figure(figsize=(x_,y_))
plt.scatter(x=data.Length,y=data.Age,c='blue');


Diameter Vs Age :


plt.figure(figsize=(x_,y_))
plt.scatter(x=data.Diameter,y=data.Age,c='blue');


Weight Vs Age :


plt.figure(figsize=(x_,y_))
plt.scatter(x=data.Weight,y=data.Age,c='blue');


Split Data:


X = data.drop(['Age','Sex'],axis=1)
y = data.Age

X_train,X_test,y_train,y_test = train_test_split(X,y,test_size=0.2,random_state=42)​

Model Building:


model = LinearRegression()
model.fit(X_train,y_train)

Model Evalution:

y_pred = model.predict(X_test)​

Mean Squared Error : 


print("Mean Squared Error", metrics.mean_squared_error(y_test, y_pred))

Mean Squared Error 4.714150114949805

Root Mean Squared Error :


print("Root Mean Squared Error", np.sqrt(metrics.mean_squared_error(y_test, y_pred)))

Root Mean Squared Error 2.1712093669081765

Thank You ):


0 comments