- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
- Python Advanced Tutorial
- Python - Classes/Objects
- Python - Reg Expressions
- Python - CGI Programming
- Python - Database Access
- Python - Networking
- Python - Sending Email
- Python - Multithreading
- Python - XML Processing
- Python - GUI Programming
- Python - Further Extensions
How can scikit-learn library be used to load data in Python?
Scikit-learn, commonly known as sklearn is an open-source library in Python that is used for the purpose of implementing machine learning algorithms.
This includes classification, regression, clustering, dimensionality reduction, and much more with the help of a powerful, and stable interface in Python. This library is built on Numpy, SciPy and Matplotlib libraries.
Let us see an example to load data −
from sklearn.datasets import load_iris my_data = load_iris() X = my_data.data y = my_data.target feature_name = my_data.feature_names target_name = my_data.target_names print("Feature names are : ", feature_name) print("Target names are : ", target_name) print("\nFirst 8 rows of the dataset are : \n", X[:8])
Feature names are : ['sepal length (cm)', 'sepal width (cm)', 'petal length (cm)', 'petal width (cm)'] Target names are : ['setosa' 'versicolor' 'virginica'] First 8 rows of the dataset are : [[5.1 3.5 1.4 0.2] [4.9 3. 1.4 0.2] [4.7 3.2 1.3 0.2] [4.6 3.1 1.5 0.2] [5. 3.6 1.4 0.2] [5.4 3.9 1.7 0.4] [4.6 3.4 1.4 0.3] [5. 3.4 1.5 0.2]]
- The required packages are imported.
- The dataset required for this is also loaded into the environment.
- The features and the target values are separated from the dataset.
- These features and target are printed on the console.
- Also, to see a sample of the data, the first 8 rows of the data is printed on the console.
- Related Articles
- How can scikit learn library be used to preprocess data in Python?
- How can data be scaled using scikit-learn library in Python?
- How can scikit learn library be used to upload and view an image in Python?
- How can scikit-learn library be used to get the resolution of an image in Python?
- Explain how L1 Normalization can be implemented using scikit-learn library in Python?
- Explain how L2 Normalization can be implemented using scikit-learn library in Python?
- Explain how scikit-learn library can be used to split the dataset for training and testing purposes in Python?
- How can scikit-learn be used to convert an image from RGB to grayscale in Python?
- Explain the basics of scikit-learn library in Python?
- How can FacetGrid be used to visualize data in Python Seaborn Library?
- How to binarize the data using Python Scikit-learn?
- How can the countplot be used to visualize data in Python Seaborn Library?
- How can a specific tint be added to grayscale images in scikit-learn in Python?
- How to eliminate mean values from feature vector using scikit-learn library in Python?
- Learning Model Building in Scikit-learn: A Python Machine Learning Library