0% found this document useful (0 votes)
9 views1 page

Program

The document outlines a Python program that uses pandas and scikit-learn to load and describe the Iris dataset. It includes commands for data encoding using LabelEncoder and OneHotEncoder, transforming the target names into numerical and one-hot encoded formats. The program also displays the first few rows, data information, and descriptive statistics of the dataset.

Uploaded by

Adhil E S
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views1 page

Program

The document outlines a Python program that uses pandas and scikit-learn to load and describe the Iris dataset. It includes commands for data encoding using LabelEncoder and OneHotEncoder, transforming the target names into numerical and one-hot encoded formats. The program also displays the first few rows, data information, and descriptive statistics of the dataset.

Uploaded by

Adhil E S
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

part A

1. Write a program to describe the dataset using pandasdataframe commands and


encode the
same.
Program Code :
fromsklearn import datasets
importnumpy as np
import pandas as pd
[Link] import LabelEncoder, OneHotEncoder
data=pd.read_csv(r"C:\Users\jackw\Downloads\[Link]")
iris=datasets.load_iris()
data=[Link](data=np.c_[iris['data'],iris['target']],
columns=iris['feature_names']+['target'])
data['target_names']=data['target'].replace(dict(enumerate(iris.target_names)))
print([Link]())
[Link]()
print([Link]())
Label_encoder=LabelEncoder()
data['target_names']=Label_encoder.fit_transform(data['target_names'])
print(data['target_names'])
print(Label_encoder.classes_)
print(data['target_names'].value_counts())
One_hot=OneHotEncoder()
transformed_data=One_hot.fit_transform(data['target_names'].[Link](-
1,1)).toarray()
print(One_hot.categories_)
transformed_data=[Link](transformed_data,
columns=['setosa','versicolor','virginica'])
print(transformed_data.head())

You might also like