Network slicing is widely regarded as the most critical technique for allocating network resources to varied user needs in 5G networks. A Software Defined Networking (SDN) and Network Function Virtualization (NFV) are two extensively used strategies for slicing the physical infrastructure according to use cases. The most efficient use of virtual networks is realized by the application of optimal resource allocation algorithms. Numerous research papers on 5G network resource allocation focus on network slicing or on the best resource allocation for the sliced network. This study uses network slicing and optimal resource allocation to achieve performance optimization using requirement-based network slicing. The proposed approach includes three phases: (1) Slice Creation by Machine Learning methods (SCML), (2) Slice Isolation through Resource Allocation (SIRA) of requests via a multi-criteria decision-making approach, and (3) Slice Management through Resource Transfer (SMART). We receive a set of Network Service Requests (NSRs) from users. After receiving the NSRs, the SCML is used to form slices, and SIRA and SMART are used to allocate resources to these slices. Accurately measuring the acceptance ratio and resource efficiency helps to enhance overall performance. The simulation results show that the SMART scheme can dynamically change the resource allocation according to the test conditions. For a range of network situations and Network Service Requests (NSRs), the performance benefit is studied. The findings of the simulation are compared to those of the literature in order to illustrate the usefulness of the proposed work.