Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7789283
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T21:15:06+00:00 2026-06-01T21:15:06+00:00

Numpy newbie here. I’m trying to normalize (aka feature scaling, standardization) my inputs to

  • 0

Numpy newbie here. I’m trying to normalize (aka feature scaling, standardization) my inputs to a neural network. I just doing linear scaling and the formula I’m using is:

I = Imin + (Imax-Imin)*(D-Dmin)/(Dmax-Dmin)

where I is the scaled input value, Imin and Imax are the desired min and max range of the scaled values, D is the original data value, and Dmin and Dmax are the min and max range of the original data values. I want a python method that takes a numpy array and returns an array with all the values normalized. This is what I’m thinking so far.

def get_normalized_values(array):
    """I = Imin + (Imax-Imin)*(D-Dmin)/(Dmax-Dmin)"""
    imin = -1
    imax = 1
    dmin = array.amin()
    dmax = array.amax()

    normalized = imin + (imax - imin)*(array - dmin)/(dmax - dmin)

    return normalized

My question is will this work? Or do I have to loop through each element in the array and perform the math? Can you just do math like this with arrays and scalars? That is, will array - dmin create a new temporary array where each value has dmin subtracted? Not sure if this is the right terminology but I think this is a “vectorized” approach?

Update

Is there a way to have this modify the array in place? That is rather than returning a copy of the array, have the function take the array and modify the original array?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T21:15:07+00:00Added an answer on June 1, 2026 at 9:15 pm

    I believe you need to change the calls amin() and amax() to just be calls to min() and max(), as in my_array.max().

    Otherwise, this should work fine. You can do things in NumPy much like Octave/Matlab, such as adding a scalar to an array, and it automatically knows to map the operation to all elements. Sometimes, you might need slightly different syntax (like knowing the difference between numpy.linalg.dot() and just multiplying two arrays), but in general things like this are as straightforward as you have indicated.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In NumPy, I'm trying to use linalg to compute matrix inverses at each step
I'm a functional programming newbie. I'd like to know how to implement numpy.where() in
Numpy has a basic pxd that declares its c interface to cython. Is there
Using NumPy , a matrix A has n rows and m columns, and I
The numpy.equal function does not work if a list or array contains strings: >>>
import numpy a = numpy.array([20090913, 20101020, 20110125]) Can you explain why numpy.datetime64(a.astype(S8).tolist()) converts correctly
I'm creating a numpy array which is to be filled with objects of a
I have a NumPy array [1,2,3,4,5,6,7,8,9,10,11,12,13,14] and want to have an array structured like
I have a numpy array with positive and negative values in. a = array([1,1,-1,-2,-3,4,5])
I have a numpy array like this a = np.array(1) Now if I want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.