How to Index, Slice and Reshape NumPy Arrays for Machine Learning

Last Updated on June 13, 2020

Machine learning data is represented as arrays.

In Python, data is almost universally represented as NumPy arrays.

If you are new to Python, you may be confused by some of the pythonic ways of accessing data, such as negative indexing and array slicing.

In this tutorial, you will discover how to manipulate and access your data correctly in NumPy arrays.

After completing this tutorial, you will know:

  • How to convert your list data to NumPy arrays.
  • How to access data using Pythonic indexing and slicing.
  • How to resize your data to meet the expectations of some machine learning APIs.

Kick-start your project with my new book Linear Algebra for Machine Learning, including step-by-step tutorials and the Python source code files for all examples.

Let’s get started.

  • Update Jul/2019: Fixed small typo related to reshaping 1D data (thanks Rodrigue).
How to Index, Slice and Reshape NumPy Arrays for Machine Learning in Python

How to Index, Slice and Reshape NumPy Arrays for Machine Learning in Python
Photo by Björn Söderqvist, some
To finish reading, please visit source site