How can Tensorflow be used to display sample data from abalone dataset?

PythonServer Side ProgrammingProgrammingTensorflow

Once the abalone dataset has been downloaded using the google API, a few samples of the data can be displayed on the console using the ‘head’ method. If a number is passed to this method, that many rows would be displayed. It basically displays the rows from the beginning.

Read More: What is TensorFlow and how Keras work with TensorFlow to create Neural Networks?

We will be using the abalone dataset, which contains a set of measurements of abalone. Abalone is a type of sea snail. The goal is to predict the age based on other measurements.

We are using the Google Colaboratory to run the below code. Google Colab or Colaboratory helps run Python code over the browser and requires zero configuration and free access to GPUs (Graphical Processing Units). Colaboratory has been built on top of Jupyter Notebook.

print("Few samples of abalone data")
print("The abalone dataset is copied to another memory location")
abalone_features = abalone_train.copy()
print("The age column is deleted")
abalone_labels = abalone_features.pop('Age')
abalone_features = np.array(abalone_features)
print("The features are displayed")

Code credit:


Few samples of abalone data
The abalone dataset is copied to another memory location
The age column is deleted
The features are displayed
[[0.435 0.335 0.11   ... 0.136 0.077 0.097]
[0.585 0.45   0.125 ... 0.354 0.207 0.225]
[0.655 0.51   0.16   ... 0.396 0.282 0.37 ]
[0.53   0.42   0.13   ... 0.374 0.167 0.249]
[0.395 0.315 0.105 ... 0.118 0.091 0.119]
[0.45   0.355 0.12   ... 0.115 0.067 0.16 ]]


  • A few samples of data is displayed on the console using the 'head' method.
  • The dataset is coped to another memory location so that changes can be made to one of the dataset and still retain the originality of the dataset in the other memory location.
  • We consider that the column 'Age' is irrelevant, hence it is deleted from the dataset.
  • The features are displayed as vectors.
Published on 11-Feb-2021 06:44:45