In Python, the Scikit-learn
library (sklearn) is used for machine learning. This library contains different algorithms for classification, SVM, random forests, regression, k-neighbours, etc.
Classification is helpful to create a model which separates your data into multiple classes for prediction based on the dataset.
The Scikit-learn
library contains a pair of sample images (china and flower) that are helpful to test different pipelines and algorithms on two-dimensional data.
load_sample_images()
method is used to load sample images for performing manipulations.load_sample_image(image_name)
is used to load an array containing single image.sklearn.datasets.load_sample_images()
It does not take anything as an argument.
The function returns a dictionary-like object with three attributes.
images
: two sample images, i.e. china and flower.filenames
: a list of the names of the images.DESCR
: a short description of the dataset.In the following code snippet, on line 3, we loaded two sample images from sklearn datasets. It then prints the shape (427, 640, 3)
of sample images in the output.
# Demo code load_sample_images()from sklearn.datasets import load_sample_imagesmydataset = load_sample_images()print("Dataset length:", len(mydataset.images))first_img_data = mydataset.images[0]print("1st image Shape:",first_img_data.shape)second_img_data = mydataset.images[1]print("2nd image Shape:", second_img_data.shape)