TP1/TP1.ipynb

109 lines
3.1 KiB
Plaintext

{
"cells": [
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"import pandas as pd\n",
"from sklearn.datasets import load_iris\n"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" sepal length (cm) sepal width (cm) petal length (cm) petal width (cm) \\\n",
"0 5.1 3.5 1.4 0.2 \n",
"1 4.9 3.0 1.4 0.2 \n",
"2 4.7 3.2 1.3 0.2 \n",
"3 4.6 3.1 1.5 0.2 \n",
"4 5.0 3.6 1.4 0.2 \n",
"\n",
" species \n",
"0 setosa \n",
"1 setosa \n",
"2 setosa \n",
"3 setosa \n",
"4 setosa \n"
]
}
],
"source": [
"iris = load_iris()\n",
"df = pd.DataFrame(iris.data,columns=iris.feature_names)\n",
"df['species'] = iris.target\n",
"df[\"species\"] = df[\"species\"].map({0:iris.target_names[0],1:iris.target_names[1],2:iris.target_names[2]})\n",
"print(df.head())"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" sepal length (cm) sepal width (cm) petal length (cm) \\\n",
"count 150.000000 150.000000 150.000000 \n",
"mean 5.843333 3.057333 3.758000 \n",
"std 0.828066 0.435866 1.765298 \n",
"min 4.300000 2.000000 1.000000 \n",
"25% 5.100000 2.800000 1.600000 \n",
"50% 5.800000 3.000000 4.350000 \n",
"75% 6.400000 3.300000 5.100000 \n",
"max 7.900000 4.400000 6.900000 \n",
"\n",
" petal width (cm) \n",
"count 150.000000 \n",
"mean 1.199333 \n",
"std 0.762238 \n",
"min 0.100000 \n",
"25% 0.300000 \n",
"50% 1.300000 \n",
"75% 1.800000 \n",
"max 2.500000 \n"
]
}
],
"source": [
"import matplotlib.pyplot as plt\n",
"import seaborn as sns \n",
"\n",
"#Décrire le jeu de données\n",
"print(df.describe())"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.0"
},
"orig_nbformat": 4
},
"nbformat": 4,
"nbformat_minor": 2
}