Machine learning based IoT system for secure traffic management and accident detection in smart cities