How to see the imported sklearn datasets
I recently started learning Machine Learning, and importing datasets is the first set to take. ScikitLearn offers many datasets, so this time, I am going to use it.
from sklearn.datasets import load_boston
import pandas as pd
import matplotlib.pyplot as plt
boston = load_boston()
df = pd.DataFrame(boston.data, columns=boston.feature_names)
print(df.head())
we create a pandas
DataFrame from the Boston Housing dataset using the pd.DataFrame()
function. We pass in the boston.data
array as the data, and use boston.feature_names
to set the column names.
boston.feature_names has name of each feature, in another word, each column.
boston.data has an array on arrays that has data of each feature. This is what I got by printing boston.data.
head()
method is used to display the first few rows of the DataFrame. You can modify the number of rows displayed by passing in a different argument to the head()
method. If I set df.head(100), the first 100 records are displayed.