" df.loc[df.species == i, \"species\"] = iris_target_names[i]\n",
" \n",
"df.head(5)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**2. Plot the data to get a better feel for it. (Scattermatrix would be a good idea)**"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%matplotlib inline\n",
"from pandas.plotting import scatter_matrix\n",
"\n",
"# to get a nice plot we're gonna use some colors\n",
"species_to_color = { 'setosa': '#377eb8',\n",
" 'versicolor': '#4eae4b',\n",
" 'virginica': '#e41a1c'}\n",
"\n",
"colors = [species_to_color[s] for s in df.species]\n",
"\n",
"scatter_matrix(df,c=colors, figsize=(16,16))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**3. Now plot the data _grouped_ by target_name.**"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"df.groupby(\"species\").plot()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**4. Create a multidimensional linear model that tries to guess the petal width depending on petal_length, sepal_width, sepal_length and check how well it fits!**"
" df.loc[df.species == i, \"species\"] = iris_target_names[i]\n",
" \n",
"df.head(5)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**2. Plot the data to get a better feel for it. (Scattermatrix would be a good idea)**"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"%matplotlib inline\n",
"from pandas.plotting import scatter_matrix\n",
"\n",
"# to get a nice plot we're gonna use some colors\n",
"species_to_color = { 'setosa': '#377eb8',\n",
" 'versicolor': '#4eae4b',\n",
" 'virginica': '#e41a1c'}\n",
"\n",
"colors = [species_to_color[s] for s in df.species]\n",
"\n",
"scatter_matrix(df,c=colors, figsize=(16,16))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**3. Now plot the data _grouped_ by target_name.**"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"df.groupby(\"species\").plot()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"**4. Create a multidimensional linear model that tries to guess the petal width depending on petal_length, sepal_width, sepal_length and check how well it fits!**"