#NEWLINE# def predict( train ) : #NEWLINE# #INDENT# ( tr_train , tr_test ) = load_ml100k . get_train_test ( train , random_state = 34 ) #NEWLINE# tr_predicted0 = regression . predict ( tr_train ) #NEWLINE# tr_predicted1 = regression . predict ( tr_train . T ) . T #NEWLINE# tr_predicted2 = corrneighbours . predict ( tr_train ) #NEWLINE# tr_predicted3 = corrneighbours . predict ( tr_train . T ) . T #NEWLINE# tr_predicted4 = norm . predict ( tr_train ) #NEWLINE# tr_predicted5 = norm . predict ( tr_train . T ) . T #NEWLINE# stack_tr = np . array ( [ tr_predicted0 [ ( tr_test > 0 ) ] , tr_predicted1 [ ( tr_test > 0 ) ] , tr_predicted2 [ ( tr_test > 0 ) ] , tr_predicted3 [ ( tr_test > 0 ) ] , tr_predicted4 [ ( tr_test > 0 ) ] , tr_predicted5 [ ( tr_test > 0 ) ] ] ) . T #NEWLINE# lr = linear_model . LinearRegression ( ) #NEWLINE# lr . fit ( stack_tr , tr_test [ ( tr_test > 0 ) ] ) #NEWLINE# stack_te = np . array ( [ tr_predicted0 . ravel ( ) , tr_predicted1 . ravel ( ) , tr_predicted2 . ravel ( ) , tr_predicted3 . ravel ( ) , tr_predicted4 . ravel ( ) , tr_predicted5 . ravel ( ) ] ) . T #NEWLINE# return lr . predict ( stack_te ) . reshape ( train . shape )