define feature extraction function in python