Photo by Meg Jerrard on Unsplash

Is platypus mammal? -Data Science

Nao Kawakami
3 min readFeb 24, 2021

--

Yes, they are

Summary

  • Problem — Identify what animal class a platypus belongs to in terms of Data Science
  • Dataset — Kaggle
  • Conclusion — Platypus is mammal

Platypus is known as unique mammal. They have fluffy far and a beak so if you hear only this information and have not ever seen them, it sounds like they are one kind of bird. However, they do not have wings but 4 legs.

Are they mammal, even if most of mammals do not have a beak? Somehow, they give birth of eggs and they have cloaca which usually is found in fish, birds, reptiles and amphibians but in mammals.

In recent conclusion, as mammals are defined as animals who feed babies milk, Platypus has organs for milking so that they are categorized as one of mammals.

Besides that, I would like to know what category a platypus belongs to in terms of data science.

I used LogisticRegression to make multinomial classification model and evaluated it with accuracy. This model gives you a result of what animal types an animal is with using animals features as below.

  • Whether they have feather
  • Whether they have eggs
  • Whether they feed milk
  • and more

After all I fed features of platypus then conclude what kind of animal class they belong to.

Dataset

I use a dataset which contains animals and its features downloaded from Kaggle

Entire code is at my Github

animal contains animal names and their biological features.

# animal name and their biological information
animals.head()
animals (DataFrame)

I added unique features for a platypus, which are cloaca, webbed and beak.

  • cloaca -Organ which defecates eggs, urine and feces. This is usually found among fish, birds, reptiles, amphibians
  • webbed -Webbed feet. Mostly found among birds, reptiles and amphibians
  • beak -That one all birds have

I made platypus_female and platypus_male. These are DataFrame to get result of animal class of platypus. I separated it by gender because only male platypus has poison on its claw. Venomous mammal is not common so that this could have significant effect.

This target variable is integer between 1 and 7, and it describes as below respectively

Target value for each animal class
# create multinomial LogisticRegressionlr = LogisticRegression(multi_class='multinomial', solver='newton-cg')
X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=42)
lr.fit(X_train, y_train)
print('Train score: ', lr.score(X_train, y_train))
print('Test score: ', lr.score(X_test, y_test))
Model accuracy

Model lr predicts at 96% accuracy with unseen data. I assume this is trustworthy.

# predict animal class of female platypus
# female platypus is ..
# class_type contains between 1 and 7
class_type = lr.predict(platypus_female.drop(columns={'animal_name', 'class_type'}))
print('Class_Number: ', class_type[0])
print(f"Platypus (female) is {animal_class[animal_class['Class_Number']==class_type[0]]['Class_Type'][0]}")
Result of prediction of female platypus

This model predicted 1 with plutypus_female.

# predict animal class of male platypus
# male platypus is ..
# class_type contains between 1 and 7
class_type = lr.predict(platypus_male.drop(columns={'animal_name', 'class_type'}))
print('Class_Number: ', class_type[0])
print(f"Plutypus (male) is {animal_class[animal_class['Class_Number']==class_type[0]]['Class_Type'][0]}")
Result of prediction of male platypus

I got same result with platypus_male. It looks venomous was not relatively significant feature to determine an animal as mammal.

Conclusion

Refer to the table of animal class above, 1 means the animal belongs to mammal so both of female and male platypus is categorized as mammal by my model.

However this dataset was not very big so it could give different result with bigger dataset.

FYR entire code is at my Github

--

--