A flexible architecture for cognitive sensing of activities in ambient assisted living