This paper proposes an integrated approach to define the best consignment strategy for storing containers in an export yard of a maritime terminal. The storage strategy identifies the rules for grouping homogeneous containers, which are defined simultaneously with the assignment of each group of containers to the available blocks (bay-locations) in the yard. Unlike recent literature, this study focuses specifically on weight classes and their respective limits when establishing the consignment strategy. Another novel aspect of this work is the integration of a data-driven algorithm and operations research. The integrated approach is based on unsupervised learning and optimization models and allows us to solve large instances within a few seconds. Results obtained by spectral clustering are treated as input datasets for the optimization models. Two different formulations are described and compared: the main difference lies in how containers are assigned to bay-locations, shifting from a time-consuming individual container assignment to the assignment of groups of containers, which offers significant advantages in computational efficiency. Experimental tests are organized into three campaigns to evaluate the following: (i) The computational time and solution quality (i.e., space utilization) of the proposed models; (ii) The performance of these models against a benchmark model; (iii) The practical effectiveness of the proposed solution approach.