use memoryview for predict and apply functions