Dataset Iris Flower. Final
Dataset Iris Flower. Final
(Spring-2024)
(Spring-2024)
Submitted By
Hassan Mukhtiar
(2023-BME-5)
Submitted To
Procedure:
❖ The Sklearn was first installed in the laptop.
❖ After that the Sklearn was imported as !pip install Sklearn, and the remaining code wrote on jupyter
notebook and run the code.
❖ Then, the following tasks were given to us to achieve the above objectives.
What is Sklearn?
Scikit-learn, often abbreviated as sklearn, is a Python library for machine learning. It offers a wide range of algorithms for
classification, regression, clustering, and dimensionality reduction tasks. Sklearn provides a consistent API, extensive
documentation, and integration with other Python libraries, making it a popular choice for data scientists and machine
learning practitioners.
Example:
Lab Tasks
Task:1
❖ Load _iris is a function from sklearn. The link provides documentation: the iris in your code will be a
dictionary-like object. X and y will be NumPy arrays, and names has the array of possible targets as text
(rather than numeric values as in y ).
❖ First, import datasets from Sklearn and this imported used as csv file.
❖ Datasets of Iris flower store in the Iris variable and then by using list to print in the form of list.
Task: 2
❖ The iris data are a data frame of 150 measurements of iris petal and sepal lengths and widths, with 50
measurements for each species of “setosa,” “versicolor,” and “virginica.”
❖ Second, the task of this lab is to print the whole Iris flower data in the form of arrays.
❖ Then by using python code we also print the whole Iris flower data in the form of arrays.
Task:3
Task:4
Task:5
❖ By using python slice function, slicing the Iris data from 0 to 4 columns.
Task:6
❖ By using python slice function, slicing the Iris data from 0 to 1 column and all rows of its data.
Task:7
❖ By using python slice function, slicing the Iris data from 0 to 2 columns and all rows of its data.
Task:8
• [:, 0] is a form of indexing or slicing. The colon : before the comma indicates that we want to include all rows
(samples) in the dataset, and 0 specifies that we want to select only the values in the first column of the dataset.
Task:9
❖ [:, 0:] is a slicing notation.
❖ : in the first position indicates that we want to select all rows.
❖ 0: in the second position indicates that we want to select all columns starting from index 0.
❖ So, iris['data'][:, 0:] selects all rows and all columns starting from the first column (index 0).
Task:10
❖ From this output, we can see summary statistics like the mean (average), standard deviation, minimum,
maximum, and various percentiles for each numerical column in the DataFrame.
❖ This is useful for quickly understanding the distribution and central tendency of the data.
Task:11
❖ It looks like we're working with the Iris dataset in Python, and we're trying to view the first few rows of the
dataset using the .head( ) method.
❖ This is a common operation when exploring datasets using libraries like pandas.
Task:12
❖ The .tail() method in pandas is used to display the last few rows of a DataFrame.
❖ It's helpful for quickly inspecting the end of your dataset. If we're working with the Iris dataset, running iris.tail()
would show the last few rows of the dataset.
Conclusion:
We concluded that Sklearn, we successfully imported the Iris dataset, performed data manipulation tasks, and printed
the resulting data frame in Python. This exercise provided valuable insights into utilizing Sklearn for dataset handling and
manipulation, essential skills for data analysis and machine learning workflows.