Activity Recognition and Prediction for Smart IoT Environments