EX NO 11:
MULTIVARIATE ANALYSIS
AIM:
To implement a multivariate tree using python.
ALGORITHM:
1. Import pandas and scikit package.
2. Load the iris dataset.
3. Check datatype.
4. Examine the keys present in the dataset.
5. Collect all the independent and store it as datainddata.
6. Convert the object into a pandas dataframe.
7. Display the features names in the dataset.
8. Create a list with all the column names.
9. Split the datas into training and test dataset.
10. Instantiate the decision tree model.
11. Obtain the Predictions for the model.
12. Visualize the decision tree.
PROGRAM :
# Import libraries
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
# Import the dataset
df = sns.load_dataset('iris')
df.shape
(150, 5)
df.head(100)
43
df.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 150 entries, 0 to 149
Data columns (total 5 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 sepal_length 150 non-null float64
1 sepal_width 150 non-null float64
2 petal_length 150 non-null float64
3 petal_width 150 non-null float64
4 species 150 non-null object
dtypes: float64(4), object(1)
memory usage: 6.0+ KB
df.describe()
43
sns.pairplot(df,hue="species",size=3)
/usr/local/lib/python3.10/dist-packages/seaborn/axisgrid.py:2095: UserWarning: The `size`
parameter has been renamed to `height`; please update your code.
warnings.warn(msg, UserWarning)
<seaborn.axisgrid.PairGrid at 0x7f955752e230>
43
OUTPUT :
RESULT :
Thus multivariate decision tree was implemented successfully
43

machine learning .multivariate...........

  • 1.
    EX NO 11: MULTIVARIATEANALYSIS AIM: To implement a multivariate tree using python. ALGORITHM: 1. Import pandas and scikit package. 2. Load the iris dataset. 3. Check datatype. 4. Examine the keys present in the dataset. 5. Collect all the independent and store it as datainddata. 6. Convert the object into a pandas dataframe. 7. Display the features names in the dataset. 8. Create a list with all the column names. 9. Split the datas into training and test dataset. 10. Instantiate the decision tree model. 11. Obtain the Predictions for the model. 12. Visualize the decision tree. PROGRAM : # Import libraries import pandas as pd import numpy as np import matplotlib.pyplot as plt import seaborn as sns # Import the dataset df = sns.load_dataset('iris') df.shape (150, 5) df.head(100) 43
  • 2.
    df.info() <class 'pandas.core.frame.DataFrame'> RangeIndex: 150entries, 0 to 149 Data columns (total 5 columns): # Column Non-Null Count Dtype --- ------ -------------- ----- 0 sepal_length 150 non-null float64 1 sepal_width 150 non-null float64 2 petal_length 150 non-null float64 3 petal_width 150 non-null float64 4 species 150 non-null object dtypes: float64(4), object(1) memory usage: 6.0+ KB df.describe() 43
  • 3.
    sns.pairplot(df,hue="species",size=3) /usr/local/lib/python3.10/dist-packages/seaborn/axisgrid.py:2095: UserWarning: The`size` parameter has been renamed to `height`; please update your code. warnings.warn(msg, UserWarning) <seaborn.axisgrid.PairGrid at 0x7f955752e230> 43
  • 4.
    OUTPUT : RESULT : Thusmultivariate decision tree was implemented successfully 43