The growing demand for diverse services and applications in 5G networks requires an efficient resource management scheme to optimize the utilization of network resources. Network slicing has emerged as a promising solution to address this issue by enabling the creation of multiple virtual networks that can be customized to specific service requirements. However, the current approach of slice selection is often based on predefined policies or user input, which can lead to sub-optimal resource allocation and potential network congestion. In this paper, we propose a cooperative slicing mechanism for 5G networks based on machine learning. Our solution involves the deployment of a machine learning model in user equipment (UE) to recommend the most suitable slice based on historical network and service usage data. This model is trained on network data to identify patterns and predict future network usage, enabling the UE to make informed slice selection recommendations to the 5G core network. The cooperation between UE and the 5G core network ensures efficient resource allocation and optimal performance for different service requirements. Our proposed mechanism is a promising approach to address the limitations of the current slice selection method and enhance the performance of 5G networks.