Mastering Machine Learning with Python in Six Steps by Manohar Swamynathan

Mastering Machine Learning with Python in Six Steps by Manohar Swamynathan

Author:Manohar Swamynathan
Language: eng
Format: epub
Publisher: Apress, Berkeley, CA


# create hihger order polynomial for independent variables

order_no = 6

# map the variable 1 & 2 to its higher order polynomial

def map_features(variable_1, variable_2, order=order_no):

assert order >= 1

def iter():

for i in range(1, order + 1):

for j in range(i + 1):

yield np.power(variable_1, i - j) * np.power(variable_2, j)

return np.vstack(iter())

out = map_features(data['x1'], data['x2'], order=order_no)

X = out.transpose()

y = data['class']

# split the data into train and test

X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=0)



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.