Code Monkey home page Code Monkey logo

Comments (10)

kkweon avatar kkweon commented on May 14, 2024 1

It can be done in two lines though.

def MinMaxScaler(data):
    numerator = data - np.min(data, 0)
    denominator = np.max(data, 0) -  np.min(data, 0)
    return numerator/ (denominator + 1e-8) # noise should be added to prevent zero division

from deeplearningzerotoall.

hunkim avatar hunkim commented on May 14, 2024

Thanks. Do you know which numpy calls in the file cause this issue? Perhaps, we can replace it.

from deeplearningzerotoall.

GzuPark avatar GzuPark commented on May 14, 2024

This problem occurred on the line from sklearn.preprocessing import MinMaxScaler.
If we can edit scaler = MinMaxScaler(feature_range=(0, 1)) and xy = scaler.fit_transform(xy), we will solve the problem another way.

from deeplearningzerotoall.

GzuPark avatar GzuPark commented on May 14, 2024
def MinMaxScaler(data):
    num_row = np.shape(data)[0]
    num_col = np.shape(data)[1]
    array = np.zeros((num_row, num_col))
    for i in range(num_col):
        input = data[:,i]
        array[:,i] = (input - np.min(input)) / (np.max(input) - np.min(input))
    return array

If we use above function, we can do it!! Also, we don't need to use sklearn.preprocessing package.
(lab-12-5 and lab-12-6)

from deeplearningzerotoall.

hunkim avatar hunkim commented on May 14, 2024

from deeplearningzerotoall.

GzuPark avatar GzuPark commented on May 14, 2024

#56 #57 Done.

from deeplearningzerotoall.

hunkim avatar hunkim commented on May 14, 2024

from deeplearningzerotoall.

hunkim avatar hunkim commented on May 14, 2024

from deeplearningzerotoall.

kkweon avatar kkweon commented on May 14, 2024

I can do that. The vectorized version is 8 times faster than the loop

In [9]: %timeit -n 1000 MinMaxScaler1(A)
1000 loops, best of 3: 81.8 µs per loop

In [10]: %timeit -n 1000 MinMaxScaler2(A)
1000 loops, best of 3: 11.3 µs per loop

from deeplearningzerotoall.

hunkim avatar hunkim commented on May 14, 2024

from deeplearningzerotoall.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.