How to Load Linnerud dataset?
This dataset is often used for regression analysis and predictive modelling tasks, such as predicting the number of repetitions an athlete can perform based on their physical characteristics. The sklearn.datasets.load_linnerud function is used to load the Linnerud dataset.
Syntax: sklearn.datasets.load_linnerud(*, return_X_y=False, as_frame=False)
Parameters: return_X_y or as_frame : bool, default=False
Returns: Data [Dictionary-like object]
The load_linnerud function in scikit-learn provides a multi-output regression dataset containing exercise and physiological measurements from twenty middle-aged men, useful for fitness-related studies.
Loading Linnerud Dataset using Sklearn
- Importing Libraries: The code starts by importing the necessary libraries,
load_linnerud
fromsklearn.datasets
andpd
frompandas
. - Loading the Dataset:
load_linnerud()
loads the Linnerud dataset, which is a multi-output regression dataset consisting of exercise (data) and physiological (target) variables. - Creating DataFrames: Two DataFrames are created:
features_df
: Contains the input features (exercise data) of the Linnerud dataset. Each row represents a data point, and each column represents a different exercise variable.targets_df
: Contains the target variables (physiological data) of the Linnerud dataset. Each row corresponds to a data point, and each column represents a different physiological variable.
- Printing the Features DataFrame: The code prints the first few rows of the
features_df
DataFrame usinghead()
to show a preview of the dataset.
from sklearn.datasets import load_linnerud
import pandas as pd
# Load the Linnerud dataset
linnerud = load_linnerud()
# Creating DataFrames from the dataset for easier manipulation
# Features DataFrame
features_df = pd.DataFrame(data=linnerud.data, columns=linnerud.feature_names)
# Target DataFrame
targets_df = pd.DataFrame(data=linnerud.target, columns=linnerud.target_names)
# Print the first few rows of the features DataFrame
print("Features DataFrame:")
print(features_df.head())
Output:
Features DataFrame:
Chins Situps Jumps
0 5.0 162.0 60.0
1 2.0 110.0 60.0
2 12.0 101.0 101.0
3 12.0 105.0 37.0
4 13.0 155.0 58.0
Linnerud Dataset – Explain, Implementation, Application
The Linnerud dataset is a classic dataset in machine learning and statistics. It is a foundational resource for exploring the relationships between physical attributes and exercise performance. Understanding the dataset involves grasping its structure, content, and potential applications. In this article, we will see how to use the Linnerud dataset and how to load it with the help of sklearn.
Table of Content
- What is the Linnerud dataset?
- Characteristics of Linnerud Dataset
- Data Structure
- Exploring Linnerud Dataset
- Physiological Variables of Linnerud Dataset
- Exercise Variables of Linnerud Dataset
- How to Load Linnerud dataset?
- Loading Linnerud Dataset using Sklearn
- Application of Linnerud dataset
- Limitation of Linnerud Dataset
- Impact of Limitations
- Conclusion