Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
MaxAbsScaler | Scaling Numerical Data
Introduction to Scikit Learn
course content

Contenido del Curso

Introduction to Scikit Learn

Introduction to Scikit Learn

1. The Very First Steps
2. Scaling Numerical Data
3. Models in Scikit Learn

MaxAbsScaler

To bring values into range [-1, 1] we have to use the next formula:

[object Object]

Here we have the following values:

  • x_scaled - normalized feature element,
  • x - unnormalized feature element,
  • max(x) -- maximum feature element.

There is a function in the sklearn library that normalizes data according to the formula given above: MaxAbsScaler(). In order to work with this function, it must first be imported in such a way:

1
from sklearn.preprocessing import MaxAbsScaler
copy

Let's look at an example of how we apply this normalization to a very simple array.

12345678910
from sklearn.preprocessing import MaxAbsScaler data = [[10, 5, -6],[11, -9, 4],[-10, 0, 1]] # Normalizer initialization scaler = MaxAbsScaler() # Dataset transfer and transformation scaler.fit(data) scaled_data = scaler.transform(data) print('Data before normalization', data) print('Data after normalization', scaled_data)
copy

If you run this code you will get two different arrays: before and after normalization. And this function really works, because you can make sure that data after using MaxAbsScaler() function really lie within an interval [-1, 1]. Look below.v

[object Object]

[object Object]

It's time to practice!

Tarea

You have a numpy array. Please, normalize this array into range [-1, 1].

Tarea

You have a numpy array. Please, normalize this array into range [-1, 1].

Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones

¿Todo estuvo claro?

Sección 2. Capítulo 2
toggle bottom row

MaxAbsScaler

To bring values into range [-1, 1] we have to use the next formula:

[object Object]

Here we have the following values:

  • x_scaled - normalized feature element,
  • x - unnormalized feature element,
  • max(x) -- maximum feature element.

There is a function in the sklearn library that normalizes data according to the formula given above: MaxAbsScaler(). In order to work with this function, it must first be imported in such a way:

1
from sklearn.preprocessing import MaxAbsScaler
copy

Let's look at an example of how we apply this normalization to a very simple array.

12345678910
from sklearn.preprocessing import MaxAbsScaler data = [[10, 5, -6],[11, -9, 4],[-10, 0, 1]] # Normalizer initialization scaler = MaxAbsScaler() # Dataset transfer and transformation scaler.fit(data) scaled_data = scaler.transform(data) print('Data before normalization', data) print('Data after normalization', scaled_data)
copy

If you run this code you will get two different arrays: before and after normalization. And this function really works, because you can make sure that data after using MaxAbsScaler() function really lie within an interval [-1, 1]. Look below.v

[object Object]

[object Object]

It's time to practice!

Tarea

You have a numpy array. Please, normalize this array into range [-1, 1].

Tarea

You have a numpy array. Please, normalize this array into range [-1, 1].

Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones

¿Todo estuvo claro?

Sección 2. Capítulo 2
toggle bottom row

MaxAbsScaler

To bring values into range [-1, 1] we have to use the next formula:

[object Object]

Here we have the following values:

  • x_scaled - normalized feature element,
  • x - unnormalized feature element,
  • max(x) -- maximum feature element.

There is a function in the sklearn library that normalizes data according to the formula given above: MaxAbsScaler(). In order to work with this function, it must first be imported in such a way:

1
from sklearn.preprocessing import MaxAbsScaler
copy

Let's look at an example of how we apply this normalization to a very simple array.

12345678910
from sklearn.preprocessing import MaxAbsScaler data = [[10, 5, -6],[11, -9, 4],[-10, 0, 1]] # Normalizer initialization scaler = MaxAbsScaler() # Dataset transfer and transformation scaler.fit(data) scaled_data = scaler.transform(data) print('Data before normalization', data) print('Data after normalization', scaled_data)
copy

If you run this code you will get two different arrays: before and after normalization. And this function really works, because you can make sure that data after using MaxAbsScaler() function really lie within an interval [-1, 1]. Look below.v

[object Object]

[object Object]

It's time to practice!

Tarea

You have a numpy array. Please, normalize this array into range [-1, 1].

Tarea

You have a numpy array. Please, normalize this array into range [-1, 1].

Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones

¿Todo estuvo claro?

To bring values into range [-1, 1] we have to use the next formula:

[object Object]

Here we have the following values:

  • x_scaled - normalized feature element,
  • x - unnormalized feature element,
  • max(x) -- maximum feature element.

There is a function in the sklearn library that normalizes data according to the formula given above: MaxAbsScaler(). In order to work with this function, it must first be imported in such a way:

1
from sklearn.preprocessing import MaxAbsScaler
copy

Let's look at an example of how we apply this normalization to a very simple array.

12345678910
from sklearn.preprocessing import MaxAbsScaler data = [[10, 5, -6],[11, -9, 4],[-10, 0, 1]] # Normalizer initialization scaler = MaxAbsScaler() # Dataset transfer and transformation scaler.fit(data) scaled_data = scaler.transform(data) print('Data before normalization', data) print('Data after normalization', scaled_data)
copy

If you run this code you will get two different arrays: before and after normalization. And this function really works, because you can make sure that data after using MaxAbsScaler() function really lie within an interval [-1, 1]. Look below.v

[object Object]

[object Object]

It's time to practice!

Tarea

You have a numpy array. Please, normalize this array into range [-1, 1].

Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
Sección 2. Capítulo 2
Cambia al escritorio para practicar en el mundo realContinúe desde donde se encuentra utilizando una de las siguientes opciones
We're sorry to hear that something went wrong. What happened?
some-alt