Applying various log function to full data frame in H2O

The follow code shows how to apply various log function to a full data frame or a particular column into data frame:

// Use h2o
import h2o

// Creating a new data frame and then converting it to H2O data frame
c_names = [‘Num’, ‘Prediction’]
data1 = np.array([[1, 0.12],
 [2, 0.43],
df = h2o.H2OFrame().from_python(data1, destination_frame=‘df’, column_names=c_names)

// Printing H2O Dataframe
print “df:\n”,df

// Applying log1p
df = df.log1p()

// Applying log()
df = df.log()

// Applying log2
df = df.log2()

// Applying log10
df = df.log10()

// Applying log 10 to only a column
df['Num'] = df['Num'].log10()


Thats it, Enjoy!!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s