Skip to content
Tìm ra tuổi của bào ngư từ các phép đo vật lý
Tính tuổi của bào ngư
#Khai báo library
import numpy as np
import pandas as pd
import requests
import io
import matplotlib.pyplot as plt
import seaborn as sns
# To print version in colab python notebook
print(pd.__version__)
#Xem tập dữ liệu
url='https://code.datasciencedojo.com/datasciencedojo/datasets/raw/master/Abalone/abalone.data.csv'
s=requests.get(url).content
dt=pd.read_csv(io.StringIO(s.decode('utf-8')))
dt.columns= ['Sex','Length','Diameter','Height','Whole_weight','Shucked_weight','Viscera_weight','Shell_weight','Rings']
dt.head(10)
# Kiểm tra bộ dữ liệu
dt.info()
cor_length = np.corrcoef(dt['Length'],dt['Rings'])[0,1]
cor_diameter = np.corrcoef(dt['Diameter'],dt['Rings'])[0,1]
cor_height = np.corrcoef(dt['Height'],dt['Rings'])[0,1]
cor_whole_weight = np.corrcoef(dt['Whole_weight'],dt['Rings'])[0,1]
cor_shucked_weight = np.corrcoef(dt['Shucked_weight'],dt['Rings'])[0,1]
cor_shucked_weight2= np.corrcoef( dt['Shucked_weight'],dt['Whole_weight'])[0,1]
print(cor_length)
print(cor_diameter)
print(cor_height)
print(cor_whole_weight)
#Cơ cấu tuổi của bào ngư
sns. countplot(x='Rings',data= dt)
Tập dữ liệu bào ngư này có tuổi phổ biến từ 7-11 Rings
#Mối quan hệ của Length đến Rings
sns.relplot(x='Rings',y='Length',data= dt,kind='scatter', hue='Diameter')
sns.relplot(x="Ring", y='Diameter',data= data)