Home > Blockchain >  ML: how to normalize values
ML: how to normalize values

Time:12-07

I am following this tutorial and I am trying the provided code. There is this piece of code which normalizes the values of a data frame df:

def normalise_zero_base(df):
    return df / df.iloc[0] - 1
def normalise_min_max(df):
    return (df - df.min()) / (data.max() - df.min())

However, when I run it, I get TypeError: unsupported operand type(s) for /: 'str' and 'str' . The error seems to be caused by the line return df / df.iloc[0] - 1. So my question is: how can I normalize the values of a data frame?

CodePudding user response:

It looks like your data-frame contains strings in one of the columns. String division is undefined in Python/Pandas.

Make sure that all integers were parsed correctly when you read in the data.

Otherwise if they are actual strings, you'll have to remove those columns and add them in later, or find some other way that means you don't end up trying to divide a string.

CodePudding user response:

I have attended this series of wonderful meetup sessions on "Making data useful for machine learning". In this, they have taught various techniques for making data fit for machine learning.

Session 1: https://www.youtube.com/watch?v=98J79omValA&list=PL09hqjrNbGrR9vzhh_V_mKwDCowdGgKQZ&index=2

Session 2: https://www.youtube.com/watch?v=NoE9BAKnClg&list=PL09hqjrNbGrR9vzhh_V_mKwDCowdGgKQZ&index=3

These sessions helped me a lot. Hope they might help you as well!!

  • Related