Abstract
Intermediate cities concentrate the services on which their regions depend, yet their attractiveness is rarely defined or measured. For Tetouan, northern Morocco, this study defines a Territorial Attractiveness Index (TAI) as a geometric mean of city-to-reference ratios, computes it from census, administrative and field data, and prepares the unit-level typology that future data will allow. For that typology, it develops SR-IDEC, a deep embedded clustering model whose spatial penalty is a scale-invariant Rayleigh quotient. We prove that, unlike the Laplacian penalty, this term cannot be reduced by shrinking the latent space, and we characterize how the Laplacian version contracts and collapses. Tetouan’s basic-network index is 1.138 (regional parity ), driven by networked water and sanitation, whereas physician density is 20% below the national level. Compared with nine baselines under a pre-specified protocol, SR-IDEC outperforms IDEC and its Laplacian variant and, on noisy lattices, matches K-means with more coherent maps; on a Tetouan-calibrated territory of 640 irregular units, however, classical methods are more accurate. The evidence therefore favors classical clustering for the future typology unless a deep model proves superior on calibrated data. The diagnosis is cross-sectional: services and inbound flows co-occur, but causality is not established.
1. Introduction
Urban attractiveness and basic services are more than a stock of physical assets. They shape access to opportunities, influence residential and economic location choices, sustain daily mobility, and structure the functional relations between a city and its surrounding territory. In Morocco, intermediate cities play this role for large rural and peri-urban hinterlands: they concentrate the administrative, health, educational and commercial functions that their regions do not provide elsewhere, while absorbing the pressure that this concentration creates [1,2]. Tetouan, a city of 419,038 inhabitants in 2024 [3] in the Tangier–Tetouan–Al Hoceima region, is a characteristic case: it is a historical center of northern Morocco, the seat of regional institutions and of a university, and the destination of daily and seasonal flows from the coastal and mountain municipalities that surround it. Rapid coastal urbanization and land-use change in the Tangier–Tetouan corridor over the last two decades [2,4] make the question of how this centrality is distributed, and at what cost, a practical planning question.
The notion that answers this question, territorial attractiveness, is widely used but rarely defined with precision. Policy documents use it as a synonym of competitiveness or quality of place, whereas the scholarly literature treats it as the capacity of a territory to draw and retain residents, users and activities through what it offers [5]. Empirically, it is approached through accessibility to opportunities [6,7,8], through the attraction of observed flows [9,10], or through composite indicators whose weighting and aggregation choices are seldom made explicit [11]. Three weaknesses recur. Attractiveness is measured one indicator at a time, so its multidimensional structure is lost; it is measured by the presence of facilities rather than by their capacity or quality; and it is inferred from cross-sectional co-occurrence, which cannot distinguish services that structure a territory from services that merely co-vary with it.
1.1. Problem Statement and Research Gap
Two gaps follow, one substantive and one methodological. The substantive gap is that, for Moroccan intermediate cities, there is no multi-sector diagnosis that defines attractiveness quantitatively, separates endowment from capacity and from revealed flows, and states the reference against which a city is judged attractive. Existing Moroccan studies are sectoral: urban growth and land-use change [2,4], accessibility of green space [12], or health coverage [13].
The methodological gap concerns the next analytical step. A city-level index summarizes a city; it does not reveal where, inside the city, attractiveness and deprivation are located. That requires a unit-level typology: a partition of census districts or grid cells into profiles that combine many heterogeneous indicators and that respect the spatial organization of the city. The two families of methods available for this task address only half of the problem each (Section 2). Regionalization methods enforce spatial contiguity but operate on linear dissimilarities and, when the constraint is hard, cannot represent a profile that recurs in disconnected parts of a city [14,15,16]. Deep clustering learns nonlinear representations [17,18,19] but ignores space or, when a graph-smoothness penalty is added, inherits a penalty that is minimized by shrinking the latent representation, a degenerate solution that is invisible on the loss curve [20,21]. In addition, comparisons between such methods in territorial studies rarely follow good benchmarking practice: single runs, hyperparameters tuned on the evaluation data and a number of clusters supplied to the methods that need it [22].
A data constraint shapes the design of this study and must be stated at the outset. For Tetouan, harmonized indicators at the level of census districts do not yet exist; the available evidence consists of city-level and regional aggregates. The clustering model proposed here is therefore not applied to observed unit-level Tetouan data, and no claim in this article rests on such an application. Instead, the two parts of the study are connected in three explicit ways: the indicators, profiles and spatial structure that the method must handle are derived from the city-level diagnosis; the method is evaluated on a Tetouan-calibrated territory, made of irregular units drawn inside the digitized municipal outline, whose heterogeneous indicators reproduce the observed city-level values; and the evaluation protocol is fixed before the unit-level data exist, so that its future application cannot be tuned to the results.
1.2. Objectives and Research Questions
The study has three objectives, each tied to a research question and to a deliverable that the article actually provides.
- RQ1.
- How attractive is Tetouan relative to its region and to the country, in which service dimensions, and how concentrated is its higher-order provision? Deliverable: a quantitative definition of territorial attractiveness, its computation for Tetouan, and a city-level diagnosis of service polarization (Section 3.3 and Section 4).
- RQ2.
- Can the spatial term of a deep embedded clustering model be formulated so that it cannot be minimized by contracting the latent representation, and what does such a formulation guarantee? Deliverable: the SR-IDEC model and its theoretical properties (Section 3.5 and Section 3.6, Appendix A).
- RQ3.
- Under which conditions (noise, spatial geometry, number of profiles, known or unknown number of clusters, heterogeneous indicators on irregular units) does spatially regularized deep clustering recover territorial profiles better than classical, spatially constrained and deep baselines, and when does it not? Deliverable: a pre-specified, statistically controlled evaluation (Section 3.9 and Section 5).
1.3. Contributions
- A quantitative definition of territorial attractiveness. The Territorial Attractiveness Index (TAI) aggregates city-to-reference endowment ratios geometrically within and across service dimensions, separates presence, capacity and revealed flows, and is accompanied by a sensitivity analysis of its weights and by an audit of the temporal consistency of its sources.
- A spatial penalty with guarantees. The spatial term of SR-IDEC is a Rayleigh quotient of the row-normalized deviation operator. We prove that it is invariant to scaling, translation and rotation of the latent space, that its gradient has no radial component, that it is bounded by the spectrum of the spatial graph, and that it remains well defined when the latent dispersion vanishes. For the conventional Laplacian penalty we prove that every positive weight contracts the latent space and derive a sufficient condition for the collapse of its scale; the experiments confirm the contraction and show that the partition degenerates even earlier.
- A pre-specified evaluation. SR-IDEC, its reduced variant SR-DEC, IDEC and a Laplacian-regularized IDEC are compared with K-means, X-means, BIRCH, Ward clustering with and without contiguity, a ClustGeo-type soft spatial Ward method and HDBSCAN* under two protocols (number of clusters known or estimated), on lattice benchmarks, a 24-condition robustness grid and a Tetouan-calibrated irregular territory, with nonparametric tests whose assumptions are checked, convergence diagnostics and full-batch scaling to units.
- A bridge between diagnosis and typology. The calibrated territory turns the city-level evidence into a controlled test of the unit-level analysis that the data will eventually allow, and the article states which results transfer to that analysis and which do not.
Section 2 reviews and positions the related work. Section 3 presents the data, the attractiveness index, the model, its theory and the evaluation design. Section 4 reports the diagnosis of Tetouan and Section 5 the evaluation of the clustering framework. Section 6, Section 7 and Section 8 discuss the results, their limitations and their implications.
2. Related Work and Positioning
This section is organized around the three decisions that the study has to make: how to define and measure attractiveness (Section 2.1), how to build a spatially coherent typology from many indicators (Section 2.2 and Section 2.3), and how to compare the candidate methods credibly (Section 2.4). For each, we state what the literature offers and what it leaves unresolved for the present problem.
2.1. Territorial Attractiveness: Concept and Measurement
Servillo et al. [5] show that, in European urban and spatial policy, attractiveness is used with at least three meanings: the competitive capacity to attract investment, the quality of place valued by residents, and the capacity to draw flows of users. The three meanings call for different indicators, and conflating them is a major source of ambiguity. The measurement literature offers three operational routes. Accessibility measures the ease of reaching opportunities given the land-use and transport systems [6]; floating-catchment methods correct facility-to-population ratios for the overlap of catchments [7], and global travel-time surfaces quantify access to health care at scale [8]. Proximity-based planning concepts such as the 15-minute city [23] translate accessibility into a normative target. Revealed attraction infers attractiveness from observed flows: mobility traces identify urban attractors [9], and points of interest combined with human activity delineate functional regions [10] and explain neighborhood vibrancy [24]. Composite indicators combine several dimensions into a single score, at the price of normalization, weighting and aggregation choices that determine the result and whose robustness must be shown [11].
Three limitations of this literature matter here. First, most indicators measure the presence or density of facilities, not their capacity or quality, so that a city with many establishments but few staff per inhabitant appears attractive by construction (this limitation is addressed in Section 3.3). Second, composite indices are typically aggregated arithmetically, which lets a surplus in one dimension compensate a deficit in another; geometric aggregation limits that compensability [11]. Third, almost all evidence is cross-sectional and cannot separate services that structure a territory from services that co-vary with population and income. For Morocco, the available studies remain sectoral: land-use change in the north [2,4], park accessibility in Tangier [12], the progress of health coverage [13] and national urban policy [1]. None defines attractiveness quantitatively for an intermediate city or provides the unit-level typology that would locate it within the city.
2.2. Spatially Constrained Clustering and Regionalization
Regionalization groups spatial units into regions that are internally homogeneous and, in most formulations, contiguous [25]. SKATER prunes a minimum spanning tree of the contiguity graph [14]; REDCAP builds regions by contiguity-constrained agglomeration and partitioning [26]; the max-p-regions problem chooses the number of regions endogenously under a threshold constraint [15]. Aydin et al. [16] compared these families quantitatively and found that no method dominates: performance depends on the shape and size of the true regions and on the noise. Soft formulations relax contiguity: ClustGeo mixes a feature dissimilarity with a geographical dissimilarity through a single mixing parameter [27], and STICC models multivariate spatial patterns that repeat across space with a contiguity term [28]. Wolf et al. [29] proposed geographical versions of the silhouette to assess spatial fit.
Two properties of these methods are critical for an urban typology. Hard contiguity forces each profile to occupy a single connected region, whereas urban profiles such as peripheral service-deficit areas or mobility corridors typically recur in several disconnected places; the constraint then displaces boundaries rather than removing noise, as our results confirm (Section 5.2). Soft methods avoid this, but ClustGeo-type approaches require dense dissimilarity matrices, and all of these methods operate on linear dissimilarities of the raw indicators, so they cannot learn the nonlinear combinations in which heterogeneous indicators (proportions, counts, distances, flows) carry their information.
2.3. Deep Clustering, Graph Regularization and Spatial Domains
Deep embedded clustering (DEC) learns a latent representation with an autoencoder [30] and refines it with a self-training objective that sharpens soft cluster assignments [17]; IDEC adds the reconstruction loss during clustering to preserve local structure [18]; DCN couples the representation with a K-means loss [31]; and DeepCluster alternates clustering and representation learning at scale [32]. Recent surveys organize the field by the source of the clustering signal and identify degenerate solutions and the absence of ground truth as open problems [19,33]. When the observations are nodes of a graph, graph neural encoders propagate features along edges [34]: DAEGC uses graph attention [35] and SDCN fuses an autoencoder with a graph convolutional network [36]. The closest analog of territorial typologies is the detection of spatial domains in spatially resolved transcriptomics, where SpaGCN [37] and STAGATE [38] combine expression profiles with spatial neighborhoods; more broadly, spatially explicit machine learning is the program of GeoAI [39]. The simplest way to inject space is a graph-smoothness penalty derived from Laplacian eigenmaps [40].
Three issues remain open for the present problem. First, a smoothness penalty of the form is homogeneous of degree two in the representation Z and is therefore reduced by shrinking Z; in self-supervised learning this dimensional collapse is well documented [20] and is prevented by explicit variance terms [21], but in deep clustering the issue is rarely examined, and when the decoder can compensate the shrinkage, the reconstruction term offers no protection (Section 3.6). Second, the self-training target of DEC can amplify early assignment errors, a form of confirmation bias known from pseudo-labeling [41]. Third, graph neural encoders and spatial-domain methods were designed for thousands of nodes with hundreds of features and for training regimes very different from a city of a few hundred districts with a dozen indicators; their full-graph training also raises memory issues that motivated mini-batch schemes such as Cluster-GCN [42]. Efficient nearest-neighbor search, for instance with cover trees [43], reduces the cost of building the sparse neighborhood graphs that these methods require.
2.4. Benchmarking Clustering Methods
A white paper on benchmarking in cluster analysis [22] lists the practices that make comparisons credible: a neutral and pre-specified design, data-generating processes that vary the conditions of interest, tuning separated from evaluation, several replications, and reporting of failures. Paired nonparametric tests over replications are standard for comparing algorithms [44], but post hoc tests based on mean ranks make the comparison of two methods depend on the other methods in the pool and should be replaced by paired tests [45]. Stability under resampling assesses whether clusters are reproducible [46,47]. Applied territorial studies rarely meet these standards: they usually report one run per method, select the number of clusters with the method under evaluation, or tune on the data used for evaluation.
2.5. Positioning of This Study
Table 1 compares the families above on the six properties that a unit-level typology of Tetouan requires. SR-IDEC is designed to occupy the empty cell of that table: a nonlinear representation of heterogeneous indicators, a soft spatial term that allows profiles to recur in disconnected places, and a penalty that cannot be satisfied by contracting the representation. The table states design properties, not performance; whether the design pays off is an empirical question answered in Section 5.
Table 1.
Positioning of the method families with respect to the requirements of a unit-level territorial typology. “Recurrent” indicates that a profile may occupy several disconnected places; “collapse-safe” that the spatial term cannot be reduced by contracting the representation; memory refers to the dominant term in the number of units n ( = number of adjacent pairs).
3. Materials and Methods
3.1. Study Area
Tetouan lies in northern Morocco, about 10 from the Mediterranean Sea and 40 from Ceuta, at the foot of the northern Rif. Its position has historically favored economic, social and cultural exchange and supported a diversified service economy. The municipality is functionally linked to Martil and to Mallalienne, Azla, Zaitoune, Dar Bni Karrich and Saddina (Figure 1). These territories take part in a system of reciprocal but asymmetrical exchange: Tetouan concentrates administrative, educational, medical and commercial services, while the surrounding areas supply agricultural, natural, environmental and tourism resources.
Figure 1.
Geographical location of Tetouan in its local, regional and national context. The study area (orange) is bounded by Mallalienne and Martil to the north, Azla and Zaitoune to the southeast, and Dar Bni Karrich and Saddina to the southwest; the insets locate the Tangier–Tetouan–Al Hoceima region within Morocco. The municipal outline of this map is the one digitized to build the Tetouan-calibrated territory (Section 3.9.3). Source: adapted from the administrative division of Morocco.
3.2. Data Sources and Temporal Consistency
The study combines official statistics and field information (Table 2). All secondary indicators reported below (ratios, growth rates, percentage-point gaps, shares, concentration measures and seasonal differences) are recomputed from the primary values rather than quoted from intermediate sources. Five of the sources are primary administrative records or field data; they are not peer-reviewed publications and are cited as data sources, not as scientific evidence.
Table 2.
Data sources, reference periods and the comparisons they support. The last column states how temporal consistency is ensured for each source.
Because the sources refer to different periods, we applied three rules to protect temporal consistency. (i) Every comparison between territories is made within one source and one reference period: city–region endowment ratios use the two levels of the same 2024 census, and the city–national physician ratio comes from a single report of the regional health delegation. (ii) Every change over time is computed within one series: education growth uses the 2016–2022 series of a single directorate, and the seasonal comparison of traffic uses two campaigns of the same 2022 survey at the same entrances with the same protocol. (iii) Per-capita normalizations use the 2024 census population, which is at most two years apart from the numerators (2022–2024); at plausible growth rates for the city, this gap shifts the ratios by a few percent at most, far less than the differences interpreted. The last column of Table 2 states the comparison that each source supports. Indicators from different periods are never combined arithmetically; they are assembled only in the synthesis of Section 4.6, which is read as a cross-sectional profile of a structure that changes slowly relative to the 2022–2025 window.
3.3. Territorial Attractiveness: Definition and Index
Following the distinction drawn by Servillo et al. [5], we adopt the following definition.
Definition 1 (Territorial attractiveness).
The territorial attractiveness of a territory c is its capacity to draw and retain residents, users and activities from a wider area through the services and accessibility it offers. It is assessed relative to a reference territory r (here the region or the nation) along service dimensions , and it has three observable components: endowment (the presence and coverage of services), capacity (the human and physical resources per inhabitant that determine how much service is delivered), and revealed attraction (the flows of users that the territory actually draws).
Endowment and capacity are measured by ratios to the reference. For indicator j of dimension d, oriented so that larger values are better,
where an indicator for which smaller is better (for example, inhabitants per physician) enters through the inverse ratio . denotes parity with the reference and a relative advantage. The index is unit-free, invariant to the measurement unit of each indicator, and additive in logarithms, , which gives an exact decomposition of the contribution of each dimension. Geometric aggregation is chosen because it limits compensation between dimensions: a deficit in one dimension is not fully offset by an equal surplus in another [11]. Because no weighting scheme is neutral, results are reported for equal weights and as a function of the weights, together with leave-one-out and arithmetic aggregation checks (Section 4.6).
The definition separates three levels of evidence that are often conflated. Presence (the number or density of facilities) indicates that a function exists; capacity (staff, beds or places per inhabitant) indicates how much of it can be delivered; quality (outcomes, waiting times, user satisfaction) indicates how well it is delivered. The available sources measure presence for all sectors and capacity for health only; no source measures quality. The index therefore uses presence and coverage ratios for basic networks and the physician ratio for health capacity, and the article draws no conclusion about the quality of services (Section 7).
Revealed attraction cannot be expressed as a ratio, because no comparable flow measurement exists for the reference territories. It is therefore reported alongside the index, not inside it, through three descriptors computed from the entrance counts: the total hourly flow at the three surveyed entrances in window t, its intensity per 1000 residents , and the share of each entrance.
The concentration of private hospital capacity is measured by the Herfindahl–Hirschman index
where is the number of beds of private hospital k. The index is computed for the city, across the six private hospitals located in Tetouan, not for the region. It is a descriptive indicator of the city-level diagnosis; it does not enter the attractiveness index, which is ratio-based, and it is not a feature of the clustering stage, which operates on unit-level indicators (Section 3.4).
3.4. From the City-Level Diagnosis to a Unit-Level Typology
A territorial unit cannot be characterized by a single indicator. For the unit-level analysis that the framework prepares, the observation unit is a consistent spatial entity (census district, neighborhood, planning zone or grid cell), and the feature vector of unit i takes the form
where collects basic-service indicators, health, education, administrative and commercial accessibility, mobility and demographic or urban-pressure indicators. These indicators are heterogeneous by nature: proportions bounded in , counts of rare facilities, distances, densities, growth rates and traffic exposures, with different distributions and noise levels. Pre-processing therefore applies a transformation adapted to each type: logits for proportions; catchment-based accessibility ratios for facility counts, which avoid the instability of per-unit counts of rare facilities [7]; logarithms for right-skewed densities and flows; and standardization of all variables. The Tetouan-calibrated territory (Section 3.9.3) implements exactly this pipeline. Structural zeros are distinguished from missing observations, extreme values are retained when centrality is the phenomenon of interest, and a sparse spatial weights matrix is built from contiguity. For irregular administrative polygons, two units are neighbors when they share a boundary; the row normalization used by the spatial penalty (Section 3.5) makes the penalty insensitive to the large variation of the number of neighbors between small central units and large peripheral ones. The index of Equation (1) applies unchanged at this level, with the city as reference, so that each recovered profile can be characterized by its endowment relative to the city as a whole.
Table 3 states the profiles that the unit-level analysis is designed to separate, the indicator signature that would identify each, and the planning question each answers. It is an a priori typology to be tested, not a result: in an application, cluster labels must be assigned after the empirical profiles have been examined. In this study, the typology has a second role: it defines the six profiles of the Tetouan-calibrated territory (Section 3.9.3).
Table 3.
A priori territorial typology for the unit-level application to Tetouan. Each profile is defined by the indicator signature that would identify it, not by a location. The same six profiles generate the Tetouan-calibrated territory (Section 3.9.3).
3.5. Proposed Model: SR-IDEC
SR-IDEC combines representation learning with an autoencoder, embedded clustering in the learned latent space, and a spatial penalty between neighboring units. It follows DEC [17] and IDEC [18]; the spatial term is the contribution of this study. Table 4 fixes the notation.
Table 4.
Notation.
3.5.1. Autoencoder Representation
Let be an encoder and a decoder. For each input ,
Both networks are multilayer perceptrons with ReLU hidden layers and linear output layers (architecture p–128–64–d and its mirror, ).
3.5.2. Embedded Soft Assignment and Target Distribution
With the latent centroid of cluster j, a Student-t kernel gives the soft assignment, which is sharpened into the target distribution and compared with it by the Kullback–Leibler divergence [17]:
The self-enhanced target P deserves justification, because it is indeed the mechanism through which early errors can be amplified, a form of the confirmation bias known from pseudo-labeling [41]. It is retained because it provides the only clustering signal of the objective that does not require labels: raising to the power emphasizes confident assignments, and the division by the soft cluster size prevents large clusters from absorbing small ones. Four design choices limit the amplification of spurious clusters. (i) The centroids are initialized by K-means on the pre-trained representation, so self-training starts from a partition that has not been produced by self-training. (ii) The target is held fixed for epochs between refreshes, which prevents the target from chasing its own noise at every step. (iii) Training stops as soon as fewer than of the labels change between two refreshes. (iv) The spatial penalty pulls the representations of neighboring units together and thereby opposes clusters that are not spatially supported. Whether these safeguards suffice is tested empirically rather than assumed: the ablation compares the self-trained models with K-means on the same pre-trained representation (no self-training), and the sensitivity analysis varies and (Section 5.6 and Section 5.8).
3.5.3. Spatial Penalties
Adjacent urban units share transport networks, service catchments, land uses and development pressures. The conventional way to encode this is the graph-smoothness penalty of Laplacian eigenmaps [40],
which is minimized not only by smooth representations but also by small ones: . SR-IDEC uses instead the scale-invariant form
a Rayleigh quotient whose numerator measures the deviation of each unit from the mean of its neighbors and whose denominator is the total latent dispersion. The constant keeps the quotient defined when the denominator vanishes; Proposition 3 shows that this can happen only when all latent vectors coincide, that the quotient is then exactly zero and smooth, and that has no measurable effect otherwise. The properties that motivate Equation (7) are established in Section 3.6.
The complete objective is
with weighting the clustering term and the spatial term. Three further members of the same family share the backbone and differ only in the objective: IDEC [18] (), the Laplacian-regularized IDEC, Lap-IDEC ( replaced by ), and the reduced variant SR-DEC ( removed from the joint stage). Comparing the four isolates the effect of each component of Equation (8). Figure 2 shows the architecture.
Figure 2.
Architecture of SR-IDEC. The objective combines reconstruction, embedded clustering and the scale-invariant spatial penalty of Equation (7); the three terms are backpropagated jointly through the encoder, the decoder and the latent centroids. SR-DEC removes the decoder from the joint stage. Blue boxes: inputs (territorial indicators and spatial graph) and total objective; orange boxes: learned components (encoder, decoder and soft assignment); green box: latent space; gray boxes: weighted loss terms. Solid arrows: forward computation; dashed orange arrow: backpropagation of the gradient of the objective.
3.5.4. Training and Convergence
Algorithm 1 states the procedure. Convergence is monitored, not assumed. At every epoch we record the three loss components, the latent dispersion and, at every target refresh, the share of units whose label changed. A run is declared converged when that share falls below , and the number of epochs, the convergence status and the full traces are reported (Section 5.9). Because the target P changes at each refresh, the total loss is a moving objective; the relevant criteria are its decrease between refreshes and the stabilization of the labels.
| Algorithm 1 SR-IDEC training (SR-DEC: omit in line 10) |
|
3.6. Theoretical Properties of the Spatial Penalties
This section answers two questions: why the Rayleigh quotient of Equation (7) should replace the Laplacian penalty of Equation (6), and under which regimes the latter actually collapses. Throughout, W is symmetric and nonnegative with zero diagonal, every unit has at least one neighbor, and the contiguity graph is connected (as are all graphs used here). Proofs are given in Appendix A; every statement was also verified numerically (Appendix B).
Proposition 1 (Invariances and absence of a radial force).
Let and . Then (a) for every ; (b) for every ; (c) for every orthogonal U; and (d) and . Consequently, a gradient step on the penalty cannot reduce the size of the representation: .
Proposition 2 (Bounds and interpretation).
The subspace is invariant under ; let and be the smallest and largest eigenvalues of on that subspace. For a connected graph and, for , , the lower bound being attained by the smoothest nonconstant configurations. If the rows of Z are independent and identically distributed with covariance Σ (no spatial structure), then , which equals for binary contiguity.
Proposition 2 makes the penalty interpretable as a multivariate analog of Geary’s ratio: it is close to (1.27 on the lattice and 1.20 on the calibrated territory) for a representation without spatial structure and falls toward (of order on both graphs) as the representation becomes smooth. Because it is dimensionless and bounded, the weight has the same meaning whatever the scale of the representation and the density of the graph, which is not the case for the Laplacian penalty, whose value grows with and with the degrees.
Proposition 3
(Role of ). For , is infinitely differentiable on and . Its denominator vanishes if and only if , that is, if all latent vectors coincide; the numerator then vanishes as well, so that . For , .
Proposition 4 (Contraction and collapse under the Laplacian penalty).
(a) For every Z, : every adds to the latent dynamics an inward radial force of magnitude . (b) Consider the reparameterization path that multiplies the last (linear) encoder layer and the centroids by and divides the weights of the first decoder layer by c. Along it, , the reconstruction and therefore are unchanged, is unchanged and . With the target P held fixed, the Lap-IDEC objective restricted to the path, , satisfies as , with
The collapsed state is therefore locally attracting along the path if and only if .
Proposition 4 answers the question of whether collapse is guaranteed. It is not, but contraction is: any positive Laplacian weight shrinks the representation, and the decoder absorbs the shrinkage, so that the reconstruction loss does not signal it. Part (b) gives a sufficient condition for the scale itself to collapse along one path with the target held fixed; it is conservative for the partition. As the representation contracts, the Student-t soft assignments, which depend on absolute distances, flatten, and the self-training target can then gather all units into a single cluster before the scale vanishes. Section 5.7 estimates on the data and shows that this degeneration indeed occurs at weights below . Along the same path the SR-IDEC objective is with constant, and near zero: the spatial term exerts no contracting force and the clustering term repels the collapsed state.
3.7. Baselines
Nine baselines are retained (Table 5). They cover the three families of Section 2 and include the original IDEC and a Laplacian-regularized IDEC as the primary deep baselines, because these differ from SR-IDEC by exactly one term of the objective.
Table 5.
Models compared, information used, selected hyperparameters and dominant costs. I: K-means iterations; E: joint-stage epochs; : network weights; m: leaves of the clustering-feature tree. Hyperparameters were selected on tuning seeds disjoint from every evaluation seed (Section 3.11).
Classical partitional and hierarchical methods. K-means [52] with k-means++ seeding [53] and 20 restarts minimizes within-cluster squared Euclidean distances; variants that change the metric, such as random normed K-means in probabilistic metric spaces [54], were not included, because all indicators are standardized and Euclidean geometry is the common reference of the other baselines. BIRCH [55] summarizes the data in a clustering-feature tree before a global clustering step. Ward clustering [56,57] merges the pair of clusters that least increases within-cluster variance.
Methods that estimate the number of clusters. X-means [58] splits K-means centroids while the Bayesian information criterion improves (). HDBSCAN* [59,60] extracts stable clusters from a density hierarchy and labels the remaining units as noise; its minimum cluster size is chosen in by the silhouette of the assigned units subject to at most 30% unassigned units, with a documented fallback to the solution with the fewest unassigned units when no candidate satisfies the constraint.
Spatially constrained methods. Ward-spatial restricts Ward merges to adjacent clusters and therefore produces contiguous regions, the hard-constraint analog of regionalization. The ClustGeo-type soft spatial Ward method [27] applies Ward linkage to the mixed dissimilarity , where contains squared feature distances and contains squared distances between unit centroids; the mixing parameter is tuned like the deep models. It uses the same information as SR-IDEC, features and locations, but through a linear dissimilarity, and it does not force contiguity.
Deep embedded methods. IDEC, Lap-IDEC, SR-IDEC and SR-DEC share one pre-trained autoencoder per dataset and the same joint-stage settings (Section 3.5); they differ only in their objective.
3.8. Computational Complexity and Memory
One epoch of the joint stage costs one forward and one backward pass through the two networks, with , the soft assignment, , and the spatial penalty, which requires the sparse products and , . For contiguity graphs , so the time per epoch is linear in n. Linear asymptotics, however, do not imply practical memory efficiency under full-batch training. Full-batch backpropagation stores the activations of every layer for every unit, about floating-point numbers per unit with the present architecture, that is several kilobytes per unit and hundreds of megabytes at , in addition to the data and the sparse graph. The constant, not the exponent, is what limits full-batch training: at the scale of a national grid (– cells) it would require mini-batch training on spatially contiguous blocks, in the spirit of Cluster-GCN [42], with the denominator of Equation (7) estimated across blocks, an extension that we leave to future work. Pre-training is already performed on mini-batches and its memory does not grow with n. Section 5.10 reports measured time and peak resident memory of full-batch SR-IDEC up to , against unconstrained Ward clustering, whose condensed distance matrix requires bytes in double precision, that is 400 at and 40 at .
3.9. Evaluation Design
The evaluation is designed to answer RQ3 without favoring any method: it varies the conditions under which methods are expected to differ, separates tuning from evaluation, and applies the same statistical treatment to all comparisons [22]. It rests on three data-generating designs (Section 3.9.3), two protocols for the number of clusters (Section 3.9.1) and a common set of metrics (Section 3.9.2).
3.9.1. Two Protocols for the Number of Clusters
Comparing models that receive the true number of clusters with models that estimate it mixes two different tasks, so the evaluation separates them. Protocol A (number of clusters known) supplies the true K to every model that requires it; X-means and HDBSCAN*, which cannot use it, are excluded. Protocol B (number of clusters unknown) requires every model to estimate K: the models that need K are fitted for and the partition with the largest silhouette in the standardized indicator space is retained, a criterion external to all the objectives being compared; X-means uses its information criterion and HDBSCAN* uses its density hierarchy. Protocol B is the situation of a real application.
3.9.2. Metrics
External validity is measured by the adjusted Rand index (ARI) [61] and normalized mutual information (NMI) [62]; internal quality by the silhouette [63], Calinski–Harabasz [64] and Davies–Bouldin [65] indices are computed on the assigned units in the standardized indicator space; and stability by the mean pairwise ARI between partitions of five spatial-block subsamples (each retaining 80% of square blocks of units) computed on the units they share [46,47].
Spatial coherence requires care when methods leave units unassigned. The share of adjacent pairs in the same cluster among pairs whose two units are assigned ignores unassigned units; it is therefore not comparable between a method that assigns every unit and one, such as HDBSCAN*, that leaves a large share unassigned, and it rewards partitions with few clusters. We report the coverage (share of assigned units) and a chance-corrected coherence computed over all adjacent pairs,
where an unassigned unit never agrees with a neighbor and E is, approximately, the agreement expected if the labels were permuted at random over the units with the cluster sizes held fixed. The measure is zero for a partition without spatial organization and one for a partition in which all neighbors agree; unlike the assigned-pairs share, it is comparable across numbers of clusters and across levels of coverage.
3.9.3. Data-Generating Designs
Lattice Benchmark
Units are the cells of a rook lattice (). Six profiles are defined by the pointwise maximum of six smoothed Gaussian random fields, so that profiles are spatially autocorrelated and can recur in disconnected places. Three latent factors are drawn around profile means, mapped linearly to ten indicators and transformed by five nonlinear functions; additive noise with standard deviation times that of each indicator is added (, moderate; , high), and 2% of the units receive a large perturbation, the analog of atypical enclaves. Each regime is replicated 30 times (seeds 0–29).
Robustness Grid
Two noise regimes cannot establish generality, and the generator hyperparameters are themselves choices. The grid therefore varies one factor at a time around a base configuration (, Gaussian noise, six profiles, smoothing three cells, strong nonlinearity, three latent factors, profile separation 2.2): the noise level (); the noise distribution (Laplace, Student-t with three degrees of freedom, centered , all scaled to unit variance); the number of profiles (); the spatial geometry (finer and coarser random fields, contiguous convex blocks that favor contiguity constraints, an aspatial design in which labels are assigned at random and space carries no information, and fields aggregated on the irregular tessellation of the Tetouan-calibrated territory); the nonlinearity of the observation model (linear, moderate); the number of latent factors (2, 5); and the separation of the profiles (, ). The 24 conditions are replicated ten times each (seeds 200–209) under Protocol A. The aspatial and block conditions are deliberately unfavorable and favorable to spatial methods, respectively; they bound the range of conditions in which a spatial term can help or hurt.
Tetouan-Calibrated Territory
This design addresses a common limitation of synthetic benchmarks, which are rarely calibrated to the study area or representative of irregular administrative units. The municipal outline of Figure 1 is digitized and partitioned into 640 irregular units by a discrete Voronoi tessellation whose seeds are denser near a stylized center, so that units are small and numerous in the center and large in the periphery, as census districts are; two units are neighbors when they share a boundary (mean degree 5.5, range 1–12). The six profiles are those of the a priori typology that the clustering stage is meant to test (Table 3): multifunctional core, specialized institutional, mobility corridor, well-served residential, peri-urban transitional and peripheral service-deficit. They are placed by six spatial suitability surfaces (a central core, four institutional poles near the center, three corridors following the western, southern and eastern entrances of the city, two concentric residential and peri-urban rings, and an outer deficit belt) perturbed by smooth noise, so that profiles are irregular and some recur in disconnected places. Each unit carries twelve heterogeneous indicators generated by type-specific mechanisms: three household-coverage proportions (drinking water, wastewater, private bathroom) drawn on the logit scale; counts of medical practices, pharmacies, schools and regional institutions drawn from negative binomial distributions and converted into catchment accessibility ratios (facilities per 10,000 residents within 0.8 to 1.0 ); the distance to the nearest regional institution; road density; traffic exposure drawn from a log-normal distribution; population density; population growth; and the distance to the nearest central unit. Measurement noise with an indicator-specific standard deviation is added on the analysis scale, multiplied by 1.25 (moderate) or 2.0 (high), and the indicators are pre-processed as in Section 3.4. The generator is calibrated on the observations of Section 4: the population totals the 2024 census count (419,038); the population-weighted coverage rates equal the observed city values (97.4%, 98.6% and 70.6%); the expected facility totals equal the observed counts (411 practices, 175 pharmacies, 160 schools, 16 regional institutions); and the road length totals 468 . Appendix C lists all parameters and the calibration check. Each regime is replicated 30 times (seeds 300–329) under both protocols. Calibration fixes the city-level aggregates, not the within-city distribution, which remains a hypothesis encoded in the profile parameters. The calibrated territory therefore tests the methods under the data structure that a Tetouan application will present (irregular units, heterogeneous indicators, realistic magnitudes) and is not a reconstruction of the true spatial structure of the city.
3.10. Statistical Protocol
For each design and metric, models are compared over paired replications: in each replication every model is applied to the same dataset. The omnibus test is the Friedman test [66] with the Iman–Davenport correction and Kendall’s W as effect size [44]. Pairwise comparisons of a reference model with every other model use Wilcoxon signed-rank tests [67] with Holm’s adjustment [68], the median paired difference with a bias-corrected and accelerated (BCa) bootstrap interval (10,000 resamples) [69], the matched-pairs rank-biserial correlation and Cliff’s [70].
The assumptions of these tests were verified rather than presumed. The Friedman test requires mutually independent blocks, a within-block ranking and, under the null hypothesis, exchangeability of the models within each block. Independence holds by construction, because each replication is generated from its own seed and no data are shared between replications; the metrics are continuous and ties, handled by midranks, are counted and reported; and exchangeability is the only distributional assumption, so we confirm every asymptotic p-value with a permutation version of the test (10,000 permutations of the model labels within blocks), which is exact in distribution. For the Wilcoxon test, whose interpretation as a test of the median difference assumes a symmetric distribution of paired differences, we also report the numbers of wins and losses and Cliff’s , which require no symmetry. Following Benavoli et al. [45], inference relies on these paired tests rather than on post hoc tests of mean ranks, whose outcome depends on the other models in the pool; the Nemenyi critical difference is shown for description only. No equivalence test is performed. A nonsignificant difference therefore means that the two models could not be separated at this sample size. It does not mean that they are equivalent [71].
3.11. Implementation, Tuning and Reproducibility
All models are implemented in Python (version 3.13.18) with NumPy (version 2.5.3), SciPy (version 1.18.1) and scikit-learn (version 1.9.1) [72,73,74]. The deep models are written directly in NumPy with analytical gradients, which were checked against finite differences (Appendix B); the autoencoder is pre-trained for 400 epochs on mini-batches of 128 units with Adam [75] (learning rate ), and the joint stage runs for at most 300 full-batch epochs. All computations use a single CPU core.
Hyperparameters were selected on five tuning seeds (101–105) in both noise regimes of the lattice generator, disjoint from every evaluation seed, by the mean ARI over the ten tuning datasets. The grids were for IDEC; for Lap-IDEC; for SR-IDEC and SR-DEC; and for the ClustGeo-type method (Table 5; full results in Appendix D). The selected values are used unchanged in every design, including the calibrated territory, which therefore also tests how well the tuning transfers to a different data structure. For IDEC, Lap-IDEC and SR-IDEC the selected lies at the upper end of the grid. This is not an artifact that a wider grid would remove: because Adam is nearly invariant to a common rescaling of the loss, increasing and at a fixed ratio is equivalent to down-weighting , and the limit of SR-IDEC as at fixed is SR-DEC. The tuning thus already indicates that the reconstruction term should be weakened, which is the comparison that SR-DEC makes explicit.
The question of how internal quality, stability and spatial smoothness are balanced in tuning has two answers. In the benchmarks, they are not balanced: selection uses a single external criterion, available only in simulation, and the three internal properties are reported as outcomes, so that none of them is optimized at the expense of the others. In an application, where no external criterion exists, the weight must be selected from internal information. Section 5.8 therefore evaluates label-free selection rules (maximum silhouette, maximum stability, maximum chance-corrected coherence, and the rank sum of silhouette and stability) by how closely the they select approaches the oracle choice. The same section reports a one-at-a-time sensitivity analysis around the selected values: , , the refresh period T, the target power , the kernel parameter , the latent dimension, the learning rate, the number of pre-training epochs and the network width (ten seeds, 400–409, high noise).
Table 6 summarizes the reproducibility protocol; every element is applied in the present study. All seeds are stated in the text, and the code and the generators are available from the corresponding author on reasonable request.
Table 6.
Reproducibility protocol and its status in the present study.
4. Results I: The Attractiveness of Tetouan
This section delivers the city-level diagnosis announced in RQ1. Each subsection reports one service dimension, distinguishing presence, capacity and revealed attraction as defined in Section 3.3; Section 4.6 combines them into the attractiveness index and a diagnosis of polarization.
4.1. Basic Networks: A Selective Advantage
Tetouan records high access to basic infrastructure, but its advantage over the regional average is markedly uneven (Table 7). Electricity, private toilets and private kitchens are close to universal at both scales, with differentials of 1.1 to 1.7 percentage points. The large gaps concern networked water services: 28.6 points for public-network wastewater disposal and 21.7 points for drinking water, with private bathrooms in between at 9.2 points. Expressed as endowment ratios, the city exceeds the region by factors of 1.409 for wastewater and 1.287 for drinking water, against less than 1.02 for electricity, kitchens and toilets. The resulting basic-network sub-index is ; networked wastewater and water account for 76% of its logarithm, and leaving out any single indicator keeps it between 1.091 and 1.166.
Table 7.
Basic service indicators in Tetouan and at the regional level, 2024. The endowment ratio is the first term of Equation (1).
The evidence supports a selective rather than uniform reading of infrastructure-based centrality. The city has moved from a historically localized dependence on springs and wells to an integrated distribution system, and delegated distribution has extended urban coverage. Urban growth nevertheless raises continuing challenges of demand, production cost, rainfall variability and the cost of extending networks after unplanned construction.
4.2. Health: Presence, Concentration and Capacity
Tetouan’s health system comprises the Saniat Rmel regional hospital, the Ar-Razi mental-health hospital, urban health centers, specialized public facilities, private hospitals, medical practices, laboratories and pharmacies, which give the city a reach well beyond its municipal boundaries. The three levels of evidence point in different directions. In terms of presence, the private inventory counts 411 medical and dental practices, 11 laboratories and 175 pharmacies (Table 8, Figure 3). In terms of concentration, six private hospitals hold 371 beds; the International Clinic alone holds 37.7% of them and the two largest establishments 58.0%. The Herfindahl–Hirschman index of Equation (2), computed across these six establishments of the city, is 2304, equivalent to 4.3 establishments of equal size and well inside the conventional “highly concentrated” range. This value describes the internal structure of private hospital supply in Tetouan; it is not a regional measure and is not used as a clustering feature. In terms of capacity, the ratios reported by the regional health delegation [49] place the city at 2.55 physicians per 10,000 inhabitants against 3.18 nationally, a deficit of 20%, with 7.7 nurses per 10,000 inhabitants and 0.80 hospital beds per 1000. Because these ratios combine public and private provision from records whose reference years are not fully homogeneous, they are reported as orders of magnitude. Taken together, the city is a regional destination for health care by presence and concentration, but not by capacity per inhabitant: concentration improves access to specialized services at the regional scale while transferring part of the unmet regional demand onto a small number of establishments and a comparatively thin medical workforce, consistent with the national debate on effective access to care [13]. None of these indicators measure the quality of care.
Table 8.
Private medical and paramedical facilities in Tetouan, 2023.
Figure 3.
Private health provision in Tetouan. (a) Distribution of the 371 private beds across the six private hospitals, with the cumulative share and the Herfindahl–Hirschman index; (b) counts of practices, pharmacies and laboratories. Panels (a,b) measure concentration and presence; capacity per inhabitant is reported in the text.
4.3. Education: Slow Public Expansion, Faster Private Growth
Public institutions remained essentially stable from 2016 to 2019 and then rose to 90 in 2022, an increase of 4.7% over the period (compound annual growth rate 0.76%). The private sector grew from 54 to 70 institutions, by 29.6% (4.42% per year), and the private share of all institutions rose from 38.6% in 2016 to 43.8% in 2022 (Figure 4). Faster private growth suggests that part of the increase in educational demand is being absorbed outside the public sector. The measure counts institutions, which is presence, not enrollment, capacity or quality, and it is not an assessment of either sector. Abdelmalek Essaadi University, the Higher School of Technology, the National Institute of Fine Arts, health training institutes and vocational establishments give the city a diversified higher-education function that extends its regional attraction for students.
Figure 4.
Educational institutions in Tetouan, 2016–2022. (a) Public and private counts with the growth recorded over the period; (b) private share of all institutions. Source: [48].
4.4. Administrative Centrality
Tetouan hosts sixteen institutions whose jurisdiction extends beyond the municipality (Table 9). Their importance lies in their jurisdictional reach: they generate recurring trips for administrative procedures, employment and complementary services, which is how the city operates as a higher-order service center in the regional urban system. The count is a presence indicator without a regional reference, so it enters the diagnosis but not the ratio-based index.
Table 9.
Higher-order administrative and institutional facilities identified by the field inventory (November 2025).
4.5. Road Supply and Inbound Mobility
The urban road network totals 468 , of which 364 (77.8%) are internal neighborhood roads, 57 (12.2%) connect neighborhoods and 47 (10.0%) are main axes (Figure 5a) [51]. A small share of the network thus performs the structuring function. For 419,038 residents, the network represents 1.12 km per 1000 inhabitants, served by 1852 taxis (4.42 per 1000 inhabitants) and 18 urban bus lines [50].
Figure 5.
Road supply and inbound mobility. (a) Composition of the 468 urban road network; (b) average hourly vehicle flows at the three surveyed entrances in the July and December observation windows. The three entrances do not form a complete cordon; the coastal accesses were not surveyed.
The field census at the three principal entrances gives a direct, if partial, indicator of revealed attraction (Table 10, Figure 5b). Summer evening flow exceeds the December evening total by 1003 vehicles per hour, a 75.1% premium, against 19.8% in the morning; over the two windows combined, the July count reaches 3882 vehicles against 2624 in December (+47.9%). Per 1000 residents, the evening intensity is 5.58 vehicles per hour in July and 3.19 in December. The Tangier entrance at Louzienne carries 45.3% of the combined July flow and 46.1% of the December flow, while the strongest seasonal reductions occur in the evening at Lawha () and Kouilma (), against at Louzienne.
Table 10.
Average hourly vehicle flows at the three main entrances to Tetouan, 2022. Morning window 08:00–09:00; evening window 19:00–20:00.
Three limits govern the interpretation of these counts. First, the sampling is thin: two one-hour windows on four consecutive days in each of two months, averaged by window, with no day-level variance available, so that no confidence interval can be attached to the premiums. Second, the three entrances are not a complete cordon. The coastal accesses from Martil and from the M’diq–Fnideq corridor, as well as secondary rural roads, were not observed, so the share of total inbound traffic captured by the three entrances is unknown; the counts are a lower bound of the inbound flow, and the 45–46% share of the Tangier entrance refers to the surveyed entrances only. Third, the seasonal difference cannot be attributed to tourism. The July campaign (10–13 July 2022) began on the day of Eid al-Adha, which generates exceptional family travel; summer also brings the return visits of Moroccans living abroad, coastal tourism and school holidays, which remove school trips from the morning window; and the evening window (19:00–20:00) falls in daylight in July but after dark in December, when one of the four evenings (14 December) preceded the World Cup semi-final played by Morocco. The concentration of the premium in the evening is consistent with leisure and visiting trips rather than commuting, but without origin–destination and trip-purpose data none of these components can be separated. For these reasons the counts are reported as revealed-attraction descriptors and are excluded from the attractiveness index. Congestion is reported at the Moulay El Mehdi roundabout, FAR Street, Massira and Abdelkhalek Torres during peak periods: service concentration produces attraction and congestion externalities together.
4.6. Attractiveness Index and Polarization Diagnosis
Two dimensions of the index can be computed with a reference value: basic networks (, regional reference) and health capacity (, national reference; Figure 6a). With equal weights, : the advantage in networked services is more than offset by the physician deficit. The conclusion depends on the weight given to health capacity, which no data can fix: exceeds parity whenever that weight is below 0.37 (Figure 6b). The basic-network sub-index itself is robust to the aggregation rule (arithmetic mean 1.148) and to the omission of any indicator (range 1.091–1.166). Because the other dimensions lack a reference, the index is necessarily partial, and we report it as such rather than filling the missing dimensions with assumptions.
Figure 6.
Territorial attractiveness of Tetouan. (a) Endowment ratios of the basic networks (city/region, 2024 census) and the health-capacity ratio (city/nation), on a logarithmic scale; the dashed line marks parity. (b) Attractiveness index as a function of the weight given to health capacity (Equation (1)); the index exceeds parity for weights below 0.37.
Table 11 assembles the dimensions into the diagnosis that RQ1 asks for. Three findings characterize the polarization of Tetouan. (i) The endowment advantage is selective: it rests on networked water and sanitation, not on household facilities, which are near-universal regionally. (ii) The higher-order functions that give the city its regional reach (administration, private health care, higher education) are those for which the evidence also documents concentration or pressure: sixteen supra-municipal institutions, a highly concentrated private hospital sector and a physician density 20% below the national level. Reach and pressure are thus two readings of the same concentration rather than independent dimensions. (iii) Revealed attraction is corridor-structured and seasonal: nearly half of the counted inbound flow uses the Tangier entrance in both seasons, and the summer premium is concentrated in the evening. Tetouan is therefore a selectively endowed, functionally concentrated pole whose attraction exceeds its service capacity per inhabitant.
Table 11.
Synthesis of the city-level diagnosis. “Component” refers to Definition 1; “reference” indicates whether a ratio to a reference territory exists and hence whether the indicator enters the index.
This diagnosis describes co-occurrence. It shows that, in Tetouan, networked services, concentrated higher-order functions and inbound flows are found together; it does not show that the services cause the flows, nor that they structure the territory rather than co-varying with population, income and history (Section 6.4).
5. Results II: Evaluation of the Clustering Framework
5.1. Scope of the Evaluation
The city-level indicators of Section 4 are single values for the city and for its region or the nation. They contain no set of spatial units on which a partition could be formed, and this is why no clustering metric, internal or external, can be computed on Tetouan data in this study: internal indices such as the silhouette do not require a reference partition, but they do require units to partition. The evaluation that follows therefore establishes three things and only these. It verifies that the implementation is correct (gradient and invariance checks, Appendix B). It measures how each method recovers known structure under controlled conditions, including a territory calibrated on Tetouan. And it identifies which internal criteria can be trusted when no reference partition exists, which is the situation of the future application. It does not establish that any model is correctly specified for Tetouan; that question can only be answered with unit-level data.
5.2. Lattice Benchmark with a Known Number of Clusters
Table 12 and Figure 7 report Protocol A on the lattice. The Friedman test rejects the equality of the nine models in both regimes (moderate noise: , , permutation , Kendall’s ; high noise: , , permutation , ). Table 13 gives the paired comparisons, from which three results emerge.
Table 12.
Lattice benchmark, Protocol A (number of clusters known).
Figure 7.
Lattice benchmark, Protocol A (30 paired replications per regime). (a) Distribution of the ARI under moderate noise; (b) distribution of the ARI under high noise; boxes show the interquartile range and points the replications. Gray: classical and spatially constrained methods; green: IDEC and Lap-IDEC; blue: SR-IDEC; orange: SR-DEC. (c) Median and interquartile range of the chance-corrected spatial coherence of Equation (10) (circles: moderate noise; squares: high noise).
Table 13.
Paired comparisons of SR-IDEC and SR-DEC with every other model on the lattice benchmark (Protocol A, ARI).
First, against the primary deep baselines, the spatial term helps, and its scale-invariant form helps more than the Laplacian form. SR-IDEC exceeds IDEC by a median paired ARI difference of under moderate noise and under high noise, winning in 30 of the 30 high-noise replications; it exceeds Lap-IDEC by and (all ). Second, against the classical methods, the result depends on the noise. Under moderate noise, neither SR-IDEC nor SR-DEC can be separated from K-means, BIRCH, Ward clustering or the ClustGeo-type method (all ), and K-means has the highest median ARI (0.846 against 0.796 and 0.814). Under high noise, SR-IDEC and SR-DEC remain inseparable from K-means (, , and , ) but exceed BIRCH and Ward clustering by about 0.10 with large effect sizes, and SR-DEC also exceeds the ClustGeo-type method (, ). Third, the spatial deep models produce more coherent maps (Figure 7c). Under high noise the chance-corrected coherence of SR-DEC exceeds that of K-means by () and that of IDEC by ; only the contiguity-constrained Ward method is more coherent, at the price of the lowest ARI (0.440 and 0.418), because forcing contiguity displaces boundaries when a profile recurs in disconnected places.
5.3. Lattice Benchmark with an Unknown Number of Clusters
When every model must estimate the number of clusters (Table 14, Figure 8), the selection of K dominates the result. Applied to the partitions of the models that need K, the silhouette underestimates it in almost every replication: the median estimate is four under moderate noise and two or three under high noise, against a true value of six, and the true value is selected in at most 13% of the replications under moderate noise and never under high noise. X-means, whose information criterion selects and in median, therefore obtains the highest ARI (0.723 and 0.641), whereas HDBSCAN* assigns only 0.746 and 0.359 of the units. Among the models whose K is selected by the silhouette, SR-DEC is ahead of K-means in both regimes (, ; , ), as well as of BIRCH, Ward clustering and the ClustGeo-type method (Appendix E, Table A5).
Table 14.
Lattice benchmark, Protocol B (number of clusters estimated).
Figure 8.
Lattice benchmark, Protocol B: number of clusters estimated by each model and median ARI (right margin). (a) Moderate noise; (b) high noise. Marker area is proportional to the number of replications out of 30; the dashed line marks the true value.
Two conclusions follow for an application in which K is unknown. The choice of the number of clusters is a larger source of error than the choice of the algorithm, and the silhouette, which favors few well-separated groups, is not an adequate criterion for that choice on territorial data with gradual transitions between profiles. In an application, K should therefore be selected by a criterion validated on calibrated data, such as the information criterion of X-means, block stability or the analysis of a range of K values, rather than by the silhouette alone.
5.4. Tetouan-Calibrated Territory
The calibration check confirms that the generated territories reproduce the observed city values: the coverage rates, the road length and the population exactly, and the facility counts on average (Appendix C, Table A2). Table 15, Figure 9 and the maps of Figure 10 report Protocol A, with the hyperparameters tuned on the lattice and used unchanged.
Table 15.
Tetouan-calibrated territory, Protocol A (number of clusters known).
Figure 9.
Tetouan-calibrated territory, Protocol A (30 replications per regime; hyperparameters tuned on the lattice). (a) Distribution of the ARI under moderate noise; (b) distribution of the ARI under high noise; boxes show the interquartile range and points the replications; (c) median and interquartile range of the chance-corrected spatial coherence (circles: moderate noise; squares: high noise). Colors as in Figure 7.
Figure 10.
Reference profiles and partitions of one calibrated territory (seed 300, moderate noise; clusters matched to profiles by the Hungarian algorithm). The 640 irregular units are drawn inside the digitized outline of Tetouan. At the spatial weight tuned on the lattice, SR-DEC absorbs much of the thin corridors into neighboring profiles and expands the outer deficit belt into the peri-urban ring.
The ranking observed on the lattice is reversed. The classical methods are the most accurate: K-means reaches a median ARI of 0.794 under moderate noise and 0.624 under high noise, Ward clustering 0.796 and 0.557, and the ClustGeo-type method 0.785 and 0.569. All four deep models are significantly behind K-means (; Table 16), and the spatial deep models are the least accurate of them: the median paired difference with K-means is and for SR-IDEC, and and for SR-DEC. At the same time, SR-DEC has the highest chance-corrected coherence after the contiguity-constrained Ward method (0.663 and 0.552): the spatial weight tuned on the lattice over-smooths this territory. The maps show the mechanism. The corridors are only a few units wide; at that weight, they are largely absorbed into neighboring profiles, and the outer deficit belt expands into the peri-urban ring (Figure 10). Table 17 confirms it profile by profile. Under moderate noise, K-means recovers every profile with a median Jaccard index of at least 0.68. The spatial deep models lose on every profile, most on the corridors (0.30 for SR-DEC against 0.68 for K-means) and on the peri-urban ring and the deficit belt, which they partly merge (0.48 and 0.52 against 0.94 and 0.88); the institutional poles are the profile they recover best (0.75).
Table 16.
Paired comparisons on the Tetouan-calibrated territory (Protocol A, ARI).
Table 17.
Recovery of each profile of the a priori typology on the Tetouan-calibrated territory (Protocol A, lattice-tuned hyperparameters): median Jaccard index between the profile and its matched cluster over 30 replications, and median number of units of the profile.
A diagnostic analysis separates two possible causes of this reversal. The deep models and the ClustGeo-type method were re-tuned on five calibrated tuning seeds per regime (340–344), disjoint from the evaluation seeds, with the same criterion and with spatial weights extended downward to . The selected spatial weights are much smaller than on the lattice ( for both spatial models, that is, for SR-IDEC and for SR-DEC, against 1.25 and two on the lattice), so that the re-tuned SR-IDEC is practically IDEC. Re-tuning raises the median ARI of SR-DEC by (moderate noise) and (high noise) and that of SR-IDEC by and , but all deep models remain far behind K-means (re-tuned SR-DEC: and , ), and on these data the Laplacian variant is the most accurate deep model (re-tuned SR-IDEC against Lap-IDEC: and ). The bottleneck is the learned representation itself: K-means applied to the pre-trained representation is about 0.20 below K-means applied to the indicators ( and ). After their type-specific transformations, the calibrated indicators are close to linearly separable; compressing them into five latent dimensions discards information that no clustering objective recovers, and the advantage of representation learning observed on the strongly nonlinear lattice does not materialize. The re-tuned values serve this diagnosis only; the comparisons of Table 15 use the pre-specified values.
Under Protocol B, the silhouette selects two clusters in almost every replication for every model that relies on it, so that their ARI falls to about 0.2–0.3 (Appendix E, Table A6 and Table A7); X-means, whose information criterion selects and in median, is again the most accurate (0.690 and 0.547). The failure of the silhouette as a criterion for the number of clusters is thus confirmed on the calibrated territory.
5.5. Robustness to the Data-Generating Design
Figure 11 reports the 24 conditions of the robustness grid (values in Appendix E, Table A4). No method dominates. SR-DEC has the highest mean ARI in 12 conditions, K-means in six, SR-IDEC in three, the ClustGeo-type method in two and the contiguity-constrained Ward method in one; SR-DEC exceeds K-means in 15 of the 24 conditions, not significantly more than half (sign test, p = 0.307). Two results of the lattice benchmark are, however, stable across the grid: SR-IDEC exceeds IDEC and Lap-IDEC in 23 of the 24 conditions, and Lap-IDEC exceeds IDEC in 23.
Figure 11.
Robustness grid: mean ARI over ten replications for each of the 24 conditions (Protocol A). Each row changes one factor of the base design (, Gaussian noise, six profiles, smooth random fields, strong nonlinearity, three latent factors, separation 2.2). The best model of each row is framed.
Where the spatial deep models gain or lose follows a clear pattern. They gain where the noise is high or heavy-tailed and where profiles form large spatial patches: at , SR-DEC reaches 0.485 against 0.460 for K-means; under Student- noise, 0.766 against 0.715; with three profiles, 0.888 against 0.826; and on coarse fields, 0.781 against 0.736. They lose where the spatial structure is fine-grained or absent: on fine fields (0.679 against 0.731), on irregular polygons (0.640 for SR-DEC and 0.701 for SR-IDEC, against 0.701), and above all in the aspatial design, where SR-DEC falls to 0.074 and SR-IDEC to 0.466, against 0.727 for K-means. When space carries no information, a fixed spatial weight imposes a structure that does not exist. Conversely, when profiles are contiguous convex regions, the hard constraint is the right model (Ward-spatial, 0.947) and the ClustGeo-type method comes second (0.891). The advantage of the spatial term is therefore conditional on the spatial organization of the profiles relative to the graph, and its weight must be chosen for the data at hand (Section 5.8).
5.6. Ablation: What Each Component Contributes, and Why
The ablation is a factorial design: the reconstruction term (present or absent) is crossed with the spatial term (present or absent), and K-means applied to the pre-trained representation (AE + K-means) serves as the reference without self-training. All variants share the pre-trained backbone and the selected weights, at four noise levels with 30 replications each (Table 18, Figure 12). Three diagnostics describe the learned representation: the Fisher ratio of the true profiles (between-profile over within-profile dispersion), and the shares of the variance of the true latent factors () and of the measurement noise () that a linear map can recover from it.
Table 18.
Ablation as a factorial design: median ARI and mechanism diagnostics of the latent representation at four noise levels (30 replications each). F: Fisher ratio of the true profiles in the latent space; , : share of the variance of the true latent factors and of the measurement noise that is linearly recoverable from the latent representation.
Figure 12.
Ablation as a function of the noise level (30 replications per level, medians). (a) ARI; (b) share of the measurement-noise variance that is linearly recoverable from the learned representation; (c) Fisher ratio of the true profiles in the learned representation.
The spatial term is the component that matters. Adding it raises the median ARI by to with the reconstruction term and by to without it, significantly at every noise level, and the gain grows with the noise. It acts on the geometry of the representation: at the Fisher ratio rises from 2.84 for IDEC to 7.80 for SR-IDEC. Self-training is beneficial but modest: IDEC exceeds AE + K-means by to , significantly at every level, so that on these data the self-enhanced target improves the partition it starts from instead of amplifying its errors.
The reconstruction term explains the remaining difference. At the selected weights, removing it changes the median ARI by to in the presence of the spatial term, a difference that is significant only at the highest noise level, and by less than 0.01 without it. The diagnostics show why it costs accuracy when it does: the reconstruction loss requires the representation to preserve all the variance of the indicators, measurement noise included. At , the share of noise variance recoverable from the representation is 0.12 with reconstruction against 0.03 without it, and the pre-trained autoencoder alone retains 0.21; the Fisher ratio is correspondingly lower with reconstruction (3.81 against 4.23). The cost is small here because the tuning has already neutralized most of it: the selected clustering weight, , is at the top of the grid, and with a smaller , which gives the reconstruction term more weight, the ARI of SR-IDEC falls steeply (from 0.647 to 0.449 over the values tested; Section 5.8).
5.7. Contraction and Collapse of the Laplacian Penalty
Figure 13 confronts Proposition 4 with the behavior of Lap-IDEC along its spatial weight (, ten seeds, high-noise lattice). Contraction begins at the smallest weights, as part (a) predicts: the median latent dispersion falls from 2.323 at to 1.915 at the tuned weight , 0.700 at and 0.338 at . Accuracy holds up to (median ARI 0.583) and then breaks down: 0.267 at , and zero at and , where seven of the 10 runs have an ARI below 0.05 and five of them assign all units to a single cluster. The ratio computed at the start of the joint stage has median 0.59 (range 0.42–1.62), so that the threshold of part (b) lies between 6.7 and 25.9. The partition therefore degenerates below that threshold. Recording at every refresh explains why the criterion of part (b) is conservative: as the penalty smooths the representation, its Laplacian energy falls faster than the dispersion of the clusters, and rises during training (from 0.59 to a median of 15.6 at ), so that the scale itself never reaches zero in these runs. What collapses is the partition: once the representation has contracted by a factor of about seven, the soft assignments are nearly uniform and the self-training target gathers the units into one or two clusters. Along the same path, SR-IDEC keeps its latent dispersion between 2.28 and 2.33 at every weight, and its ARI increases with up to the tuned value (Figure 13a,b). Panel (c) illustrates part (b): with the target held fixed, the scale that minimizes the Lap-IDEC objective along the reparameterization path decreases continuously with and reaches zero at . The failure mode is thus real, it is preceded by a contraction that the reconstruction loss does not reveal, and on these data it begins at , far below the threshold of the sufficient condition.
Figure 13.
Contraction and collapse (high-noise lattice, ten seeds, ). (a) Median latent dispersion and (b) median ARI as functions of the spatial weight for Lap-IDEC and SR-IDEC ( is plotted at ); the shaded band is the range of the initial threshold over the seeds and the dashed line its median. (c) Scale that minimizes the Lap-IDEC objective along the reparameterization path of Proposition 4 with the target held fixed (seed 400).
5.8. Hyperparameter Sensitivity and Label-Free Selection of the Spatial Weight
Figure 14 reports the one-at-a-time sensitivity analysis around the selected values (high-noise lattice, ten seeds). SR-IDEC is insensitive to the refresh period T (range of median ARI over the values tested: 0.023), the target power (0.012), the kernel parameter (0.020), the latent dimension (0.017) and the number of pre-training epochs (0.030). It is sensitive to the clustering weight (range 0.198), because a small leaves the reconstruction term dominant; to the spatial weight (0.082); to a learning rate that is too small; and to a network that is too narrow (range 0.122, the 32–16 network being the weakest). SR-DEC is sensitive to in both directions: its ARI peaks at –2 and falls at larger weights through over-smoothing (range 0.452). The insensitivity to and T shows that the results do not hinge on the sharpness or on the refresh rate of the self-enhanced target.
Figure 14.
One-at-a-time sensitivity of SR-IDEC (blue) and SR-DEC (orange) around the selected hyperparameters (high-noise lattice, ten seeds): median ARI and interquartile range. Architecture parameters were varied for SR-IDEC only.
Because an application offers no reference partition, the spatial weight must be selected from internal information. Table 19 compares four label-free rules on the same seeds. On the lattice, the stability rule and the rank-sum rule come within 0.001–0.020 of the oracle choice for both models; the silhouette rule is adequate for SR-IDEC but loses 0.126 for SR-DEC; and maximizing the chance-corrected coherence is harmful for SR-DEC (median ARI 0.277) because it always selects the largest weight: spatial smoothness is not evidence of a better typology. The other designs qualify this picture (Table 19). The stability rule fails on the calibrated territory, where over-smoothed partitions are the most stable: for SR-DEC it selects under high noise and obtains 0.298, against 0.431 for the oracle. Stability, like coherence, rewards smoothness for its own sake. The silhouette and the rank-sum rule are the most robust: across the five designs and both models they stay within 0.05 of the oracle, except the silhouette for SR-DEC on the lattice. Most importantly, they protect against the failure documented in Section 5.5. In the aspatial design, all three internal rules select for SR-DEC (median ARI 0.688, against 0.063 with the lattice-tuned weight), and small weights for SR-IDEC. On the calibrated territory, they select weights close to zero, with which the spatial models perform like their non-spatial counterparts (SR-IDEC: 0.621 with the rank-sum rule against 0.621 at ) but remain far below K-means (Section 5.4). In an application, the spatial weight should therefore be selected by the rank sum of the silhouette and the block stability, after excluding degenerate single-cluster solutions, and never by maximizing spatial coherence or stability alone.
Table 19.
Label-free selection of the spatial weight : median ARI obtained with the weight chosen by each rule, on the high-noise lattice, the calibrated territory and two unfavorable conditions of the robustness grid (ten seeds each). Median selected weight in parentheses.
5.9. Convergence
Figure 15 shows the training traces of the four deep models under high noise on the lattice. Within every refresh period of the target, the total loss decreased in 100% of the periods, all runs and models together; the jumps at the refreshes are expected, because the target changes. The share of labels changing at each refresh decreases steadily for all models. Under moderate noise, 93% of the SR-IDEC runs and 73% of the SR-DEC runs met the convergence criterion within the 300-epoch budget (median 172 and 225 epochs); under high noise, the proportions were 40% and 10%, against 100% for IDEC and 90% for Lap-IDEC. A run that does not meet the criterion within the budget is not divergent: at the last refresh, the median share of labels still changing is 0.33% for SR-DEC, that is, about two of 600 units oscillating at profile boundaries. To check that the budget does not bias the comparison, all high-noise runs of SR-IDEC and SR-DEC were repeated with a budget of 900 epochs. Every run then converged (median 308 and 458 epochs). The partitions of SR-IDEC were unchanged (median ARI between the 300- and 900-epoch partitions: 1.000), whereas those of SR-DEC changed for 4.4% of the units in median, with a median ARI of 0.679 against 0.669 at 300 epochs. The reported results are therefore, if anything, slightly conservative for SR-DEC. The traces also show the contraction predicted by Proposition 4(a): at its tuned weight, Lap-IDEC ends with a latent dispersion of 82% of its initial value, against 96% for SR-IDEC and 97% for IDEC.
Figure 15.
Training traces of the deep models (lattice, high noise; medians over 30 runs). (a) Total loss relative to its initial value; the saw-tooth pattern reflects the refreshes of the target every 15 epochs. (b) Latent dispersion relative to its initial value. (c) Share of labels changed between consecutive refreshes (symmetric logarithmic scale); the dashed line is the convergence tolerance.
5.10. Computational Scaling
Figure 16 reports wall time and peak memory for n between 225 and 3600 units (three replications) and single runs at larger sizes. Over the small range, the time of SR-IDEC, pre-training included, grows with an exponent of 1.07 and its traced peak memory with an exponent of 0.91; Ward clustering and the ClustGeo-type method have memory exponents of 1.99 and 1.95, the signature of their dense dissimilarity matrices. At larger sizes, full-batch SR-IDEC took 0.7 min at , 2.4 min at and 8.7 min at on one CPU core (of which 4.4 min of pre-training and 4.3 min of joint training), with a peak resident memory of 1.18 GB at . Unconstrained Ward clustering already required 2.95 GB of additional memory at ; at , its condensed distance matrix alone would occupy 40 . Full-batch training is therefore feasible at the scale of a large city on ordinary hardware, but, as discussed in Section 3.8, its memory constant rather than its exponent would become binding at the scale of a national grid.
Figure 16.
Computational scaling on one CPU core. (a) Wall time and (b) peak memory as functions of the number of units (log–log). Lines: medians of three replications for , with memory traced by the Python allocator; diamonds: single full-batch runs at larger n, with the increment of resident memory. Colors identify the models as in the legend of panel (b) (blue diamonds: SR-IDEC; red diamonds: unconstrained Ward clustering).
6. Discussion
The discussion is organized around four questions: what the diagnosis establishes about Tetouan, when spatially regularized deep clustering is worth using, why the reconstruction term hurts on these data, and what cross-sectional evidence can and cannot show. Implications for planning close the section.
6.1. What the Diagnosis Establishes About Tetouan
The diagnosis supports the reading of Tetouan as a multifunctional regional pole, consistent with research that treats attraction as a combination of accessibility, specialized functions and observed flows rather than as a purely demographic attribute [6,9], and with the rapid urban change documented around Tangier and Tetouan [2,4]. It qualifies that reading in three ways. First, the endowment advantage is selective: the basic-network sub-index of 1.138 rests for 76% on networked water and sanitation, and household facilities are near-universal at both scales, so that infrastructure does not contribute uniformly to polarization. Second, the attractiveness of the city is not matched by its capacity: once the physician ratio enters the index, falls below parity for any weight of health capacity above 0.37. The city attracts users for health care through the presence and concentration of facilities (an HHI of 2304 for private beds) while its physician density is 20% below the national level, a combination that transfers regional demand onto a thin local capacity. Third, the revealed attraction measured at the three surveyed entrances is corridor-structured and seasonal, but these counts are a lower bound without a reference value; they show that flows exist and how they are distributed among the surveyed entrances, not that inbound mobility is high in any comparative sense.
These findings answer RQ1 at the city scale. They do not locate attractiveness or deprivation inside the city, which is the question that the unit-level typology must answer once census-district indicators exist.
6.2. When Is Spatially Regularized Deep Clustering Worth Using?
The evaluation gives a conditional answer to the question of why a new model is needed, and the conditions are specific. Against its direct predecessors, the scale-invariant penalty is consistently beneficial: SR-IDEC exceeds IDEC and Lap-IDEC on the lattice in both regimes and in 23 of the 24 conditions of the robustness grid, the exception being the aspatial design, where any spatial term misleads. This is the problem the model was introduced to solve, a failure of graph-regularized deep clustering, and on that problem it delivers both a guarantee (Section 3.6) and an empirical improvement. Against classical methods, the deep spatial models are competitive only when three conditions hold together: indicators that are nonlinear functions of the underlying profiles, high or heavy-tailed noise, and profiles that occupy spatial patches that are large relative to the units. Under these conditions they match K-means, exceed BIRCH and Ward clustering, and produce more coherent maps. When the profiles are close to linearly separable after transformation, when they are thin relative to the units, or when space carries no information, classical methods are as accurate or more accurate, and a spatial weight tuned on other data can do harm; the calibrated territory and the aspatial condition show both effects.
For the unit-level typology of Tetouan, this implies that a deep spatial model should not be the default. It should be adopted only if it outperforms K-means, Ward and ClustGeo-type clustering on a generator calibrated to the observed unit-level indicators, with its spatial weight selected on that generator, or at least by the rank sum of silhouette and stability (Section 5.8), and the number of clusters chosen by a criterion validated in the same way. The calibrated territory of this study is a first instance of such a generator; once unit-level data exist, its parameters can be estimated from them rather than assumed.
6.3. Why the Reconstruction Term Hurts on These Data
IDEC added the reconstruction term to DEC to preserve the local structure of the data [18]. On territorial indicators measured with noise, preserving the structure of the data also preserves the noise: the ablation shows that the representation retains a larger share of the measurement noise when the reconstruction term is present, that the profiles are correspondingly less separated in it, and that the cost grows with the noise. The spatial term pulls in the opposite direction, because averaging over neighbors suppresses noise that is independent between units. When the reconstruction term carries a substantial weight, the two terms compete, which is why a configuration with a smaller clustering weight pays a visible price for reconstruction (Figure 14). Tuning resolves the conflict by down-weighting reconstruction, and its limit is SR-DEC. The general lesson is that each component of a composite objective is a hypothesis about the data: the reconstruction term is useful when the input is clean and its fine structure is informative, and counterproductive when it mostly carries measurement noise.
6.4. Co-Variation Is Not Causation
The evidence of Section 4 is observational, cross-sectional and drawn from a single city. It shows that networked services, concentrated higher-order functions and inbound flows co-occur in Tetouan; it cannot show that the services cause the flows, that educational expansion causes population mobility, or that services structure the territory rather than co-varying with it. Population size, income and the historical role of the city plausibly drive both the location of services and the intensity of flows, and a single cross-section cannot separate these influences from a causal effect of the services themselves. The same caution applies to the clustering results: a typology describes how indicators co-occur across units and is not a causal model either. Three designs could address the causal question: panels of districts observed before and after the opening or closure of a facility, which would identify the effect of supply on local use and inflows; origin–destination and trip-purpose surveys, which would attribute inbound trips to functions; and comparisons across intermediate cities with different endowments, which would separate the effect of services from that of city size.
6.5. Implications for Planning and for the Unit-Level Analysis
At the municipal scale, the concentration of health, administration and commerce in central areas calls for capacity management where these functions overlap; congestion at central nodes should be treated as an outcome of that concentration and not only as a transport problem. At the inter-municipal scale, Tetouan’s catchment extends into neighboring municipalities, while the city depends on them for land, environmental resources, agricultural supply and tourism. A network-based approach that coordinates health, education, transport and land-use planning across municipal boundaries could reduce unnecessary trips and improve the distribution of higher-order services, consistent with the emphasis of the OECD on balanced territorial development and stronger urban governance [1]. At the regional scale, the objective is not to weaken the centrality of Tetouan but to make it more resilient, by adding capacity where the diagnosis shows a deficit (the medical workforce) and by developing complementary services in secondary centers.
The unit-level typology would make these implications spatially precise. Rather than ranking neighborhoods from best to worst, it distinguishes types of need: a peripheral area with adequate water and electricity but poor access to health care calls for a different intervention than a dense central zone with excellent accessibility and high congestion. Cluster memberships can also serve as inputs to downstream predictive models, as spectral clusters did for the prediction of test scores in education [76]; in territorial planning, they could stratify the forecasting of service demand. Two operational rules follow from the evaluation: each cluster should be reported with a measure of its own stability, because a partition contains well and weakly identified groups at the same time; and the number of clusters should be chosen with a criterion validated on calibrated data rather than with the silhouette alone (Section 5.3).
7. Limitations and Research Agenda
Each limitation is stated with its consequence for the conclusions.
- A partial index. Only two dimensions of the attractiveness index have a reference value. The index therefore summarizes networked endowment and health capacity; education, administration and revealed attraction enter the diagnosis descriptively. Its value depends on the weight given to health capacity, which is why it is reported as a function of that weight.
- Presence and capacity, not quality. No available source measures the quality of services (outcomes, waiting times, satisfaction). Capacity is measured for health only, through ratios whose reference years are not fully homogeneous. No conclusion about quality is drawn.
- Temporal heterogeneity. The sources span 2016–2025. Comparisons are made within sources and periods, and per-capita ratios use a population at most two years apart from their numerators, but the synthesis assembles indicators of different years and assumes that the underlying structure changed little over the period.
- Traffic sampling. The counts cover two one-hour windows on four days in each of two months at three entrances that do not form a complete cordon. They support no conclusion on annual patterns, on the share of the total inbound flow, on the origin of trips or on their purposes, and the seasonal difference cannot be attributed to tourism.
- Cross-sectional evidence. The diagnosis describes co-occurrence in one city at one time and cannot establish causal relations between services, flows and territorial structure (Section 6.4).
- No unit-level data. The clustering framework is evaluated, not applied. The calibrated territory reproduces the city-level aggregates of Tetouan, but its within-city distribution encodes hypotheses (the a priori typology and its parameters), so its results describe the behavior of the methods under a realistic data structure, not the structure of Tetouan.
- Conditional rankings. The rankings of the methods depend on the data-generating designs. The robustness grid and the calibrated territory widen the range of conditions, but the designs remain choices of the authors, and other geometries or indicator sets could change the order of methods whose differences are small.
- Selection of the number of clusters. The silhouette underestimates the number of clusters on these data, and no single criterion was validated for all methods. Protocol B shows the consequences of that choice rather than solving it.
- Full-batch training. Memory grows linearly but with a large constant; beyond about – units, mini-batch training on spatial blocks would be needed. All timings come from one implementation on one CPU core.
The research agenda follows from these limitations. It consists in geocoding facilities and harmonizing indicators at the level of census districts; computing network-based accessibility measures with floating catchments; adding capacity and quality indicators (staff, places, waiting times, outcomes); repeating the traffic counts as a complete cordon with origin–destination and trip-purpose information; observing districts over time to support causal designs; and then applying the pre-specified protocol of Section 3.9, both protocols included, to the observed unit-level data, reporting all parameters, seeds and transformations.
8. Conclusions
This article set out to define and measure the territorial attractiveness of Tetouan and to prepare, with a validated method, the unit-level typology that would locate this attractiveness within the city. The first objective is met at the city scale. Defined as the capacity to draw and retain users through services relative to a reference territory, attractiveness can be measured for Tetouan in two dimensions: the basic-network endowment of the city exceeds the regional level by a factor of 1.138, mostly because of networked water and sanitation, whereas its physician density is 20% below the national level, so that the composite index exceeds parity only if health capacity receives a weight below 0.37. Tetouan appears as a selectively endowed and functionally concentrated pole, with sixteen institutions of supra-municipal jurisdiction, a highly concentrated private hospital sector and a corridor-structured, seasonal inbound flow, whose attraction exceeds its service capacity per inhabitant. These are statements of co-occurrence. The cross-sectional evidence does not show that the services cause the flows or that they structure the territory rather than co-varying with it. On the second objective, the scale-invariant Rayleigh-quotient penalty has the properties that the Laplacian penalty lacks. It cannot be reduced by shrinking the latent representation, it is bounded by the spectrum of the spatial graph, and it is well defined everywhere. The Laplacian penalty, by contrast, contracts the representation for every positive weight, and in our experiments the partition degenerates into one or two clusters at weights well below the ratio at which the collapsed scale becomes attracting. The evaluation shows when the model is worth using and when it is not. SR-IDEC consistently outperforms its direct predecessors, IDEC and the Laplacian-regularized IDEC. On noisy lattices with spatially smooth profiles, it matches K-means and exceeds BIRCH and Ward clustering, with more coherent maps. On a territory calibrated on Tetouan, however, classical methods are more accurate: the transformed indicators are close to linearly separable, corridors are only a few units wide, and a spatial weight tuned on other data over-smooths them. For the unit-level typology of Tetouan, the evidence therefore recommends starting from K-means, Ward or ClustGeo-type clustering of transformed indicators, choosing the number of clusters with a validated criterion rather than the silhouette, and adopting a spatial deep model only if it outperforms these methods on a generator calibrated to the observed unit-level data. The pre-specified protocol of this article makes that test routine. The next step is to build harmonized indicators for census districts, capacity and quality measures, complete traffic cordons and longitudinal observations. With them, the protocol can turn the city-level diagnosis into a reproducible unit-level typology whose claims are proportionate to the evidence.
Author Contributions
Conceptualization, I.E.M. and B.E.; methodology, I.E.M. and A.L.H.; software, A.L.H. and I.E.M.; validation, Y.A. and M.L.S.; formal analysis, I.E.M. and A.L.H.; investigation, I.E.M. and N.S.; data curation, N.S.; writing—original draft preparation, I.E.M.; writing—review and editing, A.L.H., Y.A., M.L.S., N.S. and B.E.; visualization, I.E.M. and A.L.H.; supervision, B.E. All authors have read and agreed to the published version of the manuscript.
Funding
This research received no external funding.
Data Availability Statement
The city-level results of Section 4 derive exclusively from the census, institutional, sectoral and field sources listed in Table 2; no territorial indicator has been simulated, imputed or extrapolated. The clustering results of Section 5 come from controlled designs. They are labeled as such throughout. They quantify the behavior of the algorithms on the generators specified in Section 3.9.3 and Appendix C, and they are not measurements of Tetouan. Every seed range is stated in the text: 101–105 for tuning, 0–29 for the lattice benchmark, 200–209 for the robustness grid, 300–329 for the calibrated territory (340–344 for its diagnostic re-tuning), 400–409 for the sensitivity analysis and 1000–1002 for the scaling measurements. With these seeds, every reported number can be regenerated exactly. The code, the generators, the digitized outline and the raw result files are available from the corresponding author on reasonable request.
Conflicts of Interest
The authors declare no conflicts of interest.
Abbreviations
The following abbreviations are used in this manuscript: ARI, adjusted Rand index; BCa, bias-corrected and accelerated; BIC, Bayesian information criterion; DEC, deep embedded clustering; HHI, Herfindahl–Hirschman index; IDEC, improved deep embedded clustering; Lap-IDEC, Laplacian-regularized IDEC; NMI, normalized mutual information; SR-IDEC, spatially regularized IDEC; SR-DEC, spatially regularized DEC; TAI, territorial attractiveness index.
Appendix A. Proofs of the Propositions
Notation is that of Section 3.6: W is symmetric and nonnegative with zero diagonal, , , , , and . Two facts are used repeatedly: , because the rows of sum to one, and .
Proof of Proposition 1.
(a) and . (b) and because . (c) The Frobenius norm is invariant under right multiplication by an orthogonal matrix. (d) The gradients are and , hence . Since and , we obtain , which is Euler’s identity for a function homogeneous of degree zero. Moreover, and , so the columns of the gradient sum to zero. Finally, . □
Proof of Proposition 2.
is symmetric positive semidefinite and , so is an eigenvector and its orthogonal complement is invariant. A vector satisfies if and only if ; for a connected graph the stochastic matrix is irreducible and, by the Perron–Frobenius theorem, its eigenvalue one is simple with eigenvector . Hence, and is positive definite on , so . Let , whose columns lie in . Because , , a weighted average of the Rayleigh quotients of the nonzero columns, each of which lies in ; the lower bound is attained when every nonzero column belongs to the eigenspace of . For the expectation, let the rows of Z be independent with mean and covariance , and . Then , and , so that and . Row i of R has a one on the diagonal and elsewhere, so , which reduces to for binary weights. □
Proof of Proposition 3.
For the denominator never vanishes and is a ratio of polynomials, hence . Since and the columns of lie in , , so . The denominator equals if and only if , that is, , which means that all rows of Z are equal; then and . For , . □
Proof of Proposition 4.
(a) and, directly, because L is positive semidefinite. A gradient step of size on therefore moves Z along by . (b) The last encoder layer is affine without activation, so multiplying its weights and bias by c maps to ; dividing the weights of the first decoder layer by c leaves its pre-activations, hence and , unchanged. is unchanged by Proposition 1(a). With and the centroids also multiplied by c, the kernel is and with . Since and , . As , and , whence with S as in Equation (9), and . If , is positive on an interval , so is a strict local minimizer of f on and the gradient flow in c started in that interval converges to zero; if , near zero and the collapsed state repels. S is positive whenever the target weights the nearer centroids more heavily than the uniform distribution does, which holds in every run reported here. □
Appendix B. Numerical Verification
The analytical gradients of the joint objective with both penalties were compared with central finite differences on a small network (maximum relative error with the Rayleigh penalty and with the Laplacian penalty, for the network weights; below for the centroids). The propositions were checked numerically: the Euler identity evaluates to ; along the reparameterization path of Proposition 4, the reconstruction error is unchanged to machine precision, scales exactly as and changes by less than ; the small-c derivative of matches to four significant digits at ; at a collapsed configuration ; and the effect of stays below the bound of Proposition 3 at every scale tested. For random latent matrices without spatial structure on the lattice, ranges from 1.20 to 1.34, around the value predicted by Proposition 2.
Appendix C. Specification of the Tetouan-Calibrated Territory
The municipal outline of Figure 1 was digitized at the approximate scale given by the scale bar of the map (35 pixels per kilometer), downsampled by a factor of two and partitioned into 640 units by assigning every pixel to the nearest of 640 seeds. Seeds are drawn with probability proportional to , where r is the normalized distance to a stylized center, so that units are small near the center and large in the periphery. Table A1 lists the profile parameters and Table A2 the calibration check.
Table A1.
Profile parameters of the calibrated territory. Logit intercepts are shifted by a common constant per indicator so that the population-weighted city mean equals the observed value; facility rates are relative per-capita rates rescaled so that the expected totals equal the observed counts.
Table A2.
Calibration check: observed city values and the corresponding aggregates of the 60 generated territories (mean and range).
Appendix D. Tuning Results
Table A3 reports, for each tuned model, the three best configurations and the worst one, with their mean ARI over the ten tuning datasets. The worst Lap-IDEC configuration is a collapsed solution, which illustrates Proposition 4.
Table A3.
Tuning results on seeds 101–105 (mean ARI over ten datasets): three best configurations and the worst one per model.
Appendix E. Additional Results
Table A4.
Robustness grid: mean ARI over ten replications per condition (Protocol A). Each condition changes one factor of the base design; the best value per row is in bold.
Table A5.
Paired comparisons on the lattice benchmark under Protocol B (ARI).
Table A6.
Tetouan-calibrated territory, Protocol B (number of clusters estimated).
Table A7.
Paired comparisons on the Tetouan-calibrated territory (Protocol B, ARI).
References
- OECD. National Urban Policy Review of Morocco; Technical Report; Organisation for Economic Co-operation and Development: Paris, France, 2025. [Google Scholar]
- Moreno-Navarro, J.G.; Targuisti El Khalifi, K.; Ventura Fernández, J.; Hilal, I.; López Magán, E. Rural Exodus and Land Use Change in Northern Morocco: 2000–2020. Arab. J. Geosci. 2022, 15, 1138. [Google Scholar] [CrossRef] [Scilit]
- Haut-Commissariat au Plan (HCP), Morocco. General Population and Housing Census 2024: Thematic Results; Official Census; Primary Statistical Source; Haut-Commissariat au Plan (HCP): Rabat, Morocco, 2024. [Google Scholar]
- Hadek, A.; Wahbi, M.; Sebbah, B.; Maatouk, M.; Boulaassal, H.; El Kharki, O.; Yazid Alaoui, O. Mapping Land Use and Assessing Coastal Urbanization Impacts: A Case Study in Tangier, Northern Morocco. Environ. Res. Eng. Manag. 2024, 80, 60–74. [Google Scholar] [CrossRef] [Scilit]
- Servillo, L.; Atkinson, R.; Russo, A.P. Territorial Attractiveness in EU Urban and Spatial Policy: A Critical Review and Future Research Agenda. Eur. Urban Reg. Stud. 2012, 19, 349–365. [Google Scholar] [CrossRef] [Scilit]
- Geurs, K.T.; van Wee, B. Accessibility Evaluation of Land-Use and Transport Strategies: Review and Research Directions. J. Transp. Geogr. 2004, 12, 127–140. [Google Scholar] [CrossRef] [Scilit]
- Chen, X.; Jia, P. A Comparative Analysis of Accessibility Measures by the Two-Step Floating Catchment Area (2SFCA) Method. Int. J. Geogr. Inf. Sci. 2019, 33, 1739–1758. [Google Scholar] [CrossRef] [Scilit]
- Weiss, D.J.; Nelson, A.; Vargas-Ruiz, C.A.; Gligorić, K.; Bavadekar, S.; Gabrilovich, E.; Bertozzi-Villa, A.; Rozier, J.; Gibson, H.S.; Shekel, T.; et al. Global Maps of Travel Time to Healthcare Facilities. Nat. Med. 2020, 26, 1835–1838. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Alhazzani, M.; Alhasoun, F.; Alawwad, Z.; González, M.C. Urban Attractors: Discovering Patterns in Regions of Attraction in Cities. PLoS ONE 2021, 16, e0250204. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Gao, S.; Janowicz, K.; Couclelis, H. Extracting Urban Functional Regions from Points of Interest and Human Activities on Location-Based Social Networks. Trans. GIS 2017, 21, 446–467. [Google Scholar] [CrossRef] [Scilit]
- Greco, S.; Ishizaka, A.; Tasiou, M.; Torrisi, G. On the Methodological Framework of Composite Indices: A Review of the Issues of Weighting, Aggregation, and Robustness. Soc. Indic. Res. 2019, 141, 61–94. [Google Scholar] [CrossRef] [Scilit]
- Maliari, M.; Azyat, A.; Achhab, N.B.; Raissouni, N.; Chahboun, A. Spatial Accessibility of Urban Parks in Tangier City, Morocco. Int. Arch. Photogramm. Remote Sens. Spat. Inf. Sci. 2021, XLVI-4/W5-2021, 369–372. [Google Scholar] [CrossRef] [Scilit]
- Bouzaidi, T.D.; Ragbi, A. An Analysis of the Trend Towards Universal Health Coverage and Access to Healthcare in Morocco. Health Econ. Rev. 2024, 14, 5. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Assunção, R.M.; Neves, M.C.; Câmara, G.; da Costa Freitas, C. Efficient Regionalization Techniques for Socio-Economic Geographical Units Using Minimum Spanning Trees. Int. J. Geogr. Inf. Sci. 2006, 20, 797–811. [Google Scholar] [CrossRef] [Scilit]
- Duque, J.C.; Anselin, L.; Rey, S.J. The Max-p-Regions Problem. J. Reg. Sci. 2012, 52, 397–419. [Google Scholar] [CrossRef] [Scilit]
- Aydin, O.; Janikas, M.V.; Assunção, R.M.; Lee, T.H. A Quantitative Comparison of Regionalization Methods. Int. J. Geogr. Inf. Sci. 2021, 35, 2287–2315. [Google Scholar] [CrossRef] [Scilit]
- Xie, J.; Girshick, R.; Farhadi, A. Unsupervised Deep Embedding for Clustering Analysis. In Proceedings of the 33rd International Conference on Machine Learning (ICML), New York, NY, USA, 19–24 June 2016; Volume 48, pp. 478–487. [Google Scholar]
- Guo, X.; Gao, L.; Liu, X.; Yin, J. Improved Deep Embedded Clustering with Local Structure Preservation. In Proceedings of the Twenty-Sixth International Joint Conference on Artificial Intelligence (IJCAI), Melbourne, Australia, 19–25 August 2017; pp. 1753–1759. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Zhou, S.; Xu, H.; Zheng, Z.; Chen, J.; Li, Z.; Bu, J.; Wu, J.; Wang, X.; Zhu, W.; Ester, M. A Comprehensive Survey on Deep Clustering: Taxonomy, Challenges, and Future Directions. ACM Comput. Surv. 2024, 57, 69. [Google Scholar] [CrossRef] [Scilit]
- Jing, L.; Vincent, P.; LeCun, Y.; Tian, Y. Understanding Dimensional Collapse in Contrastive Self-Supervised Learning. In Proceedings of the 10th International Conference on Learning Representations (ICLR), Virtual Event, 25–29 April 2022. [Google Scholar]
- Bardes, A.; Ponce, J.; LeCun, Y. VICReg: Variance-Invariance-Covariance Regularization for Self-Supervised Learning. In Proceedings of the 10th International Conference on Learning Representations (ICLR), Virtual Event, 25–29 April 2022. [Google Scholar]
- Van Mechelen, I.; Boulesteix, A.L.; Dangl, R.; Dean, N.; Hennig, C.; Leisch, F.; Steinley, D.; Warrens, M.J. A White Paper on Good Research Practices in Benchmarking: The Case of Cluster Analysis. WIREs Data Min. Knowl. Discov. 2023, 13, e1511. [Google Scholar] [CrossRef] [Scilit]
- Moreno, C.; Allam, Z.; Chabaud, D.; Gall, C.; Pratlong, F. Introducing the “15-Minute City”: Sustainability, Resilience and Place Identity in Future Post-Pandemic Cities. Smart Cities 2021, 4, 93–111. [Google Scholar] [CrossRef] [Scilit]
- Yue, Y.; Zhuang, Y.; Yeh, A.G.O.; Xie, J.Y.; Ma, C.L.; Li, Q.Q. Measurements of POI-Based Mixed Use and Their Relationships with Neighbourhood Vibrancy. Int. J. Geogr. Inf. Sci. 2017, 31, 658–675. [Google Scholar] [CrossRef] [Scilit]
- Openshaw, S. A Geographical Solution to Scale and Aggregation Problems in Region-Building, Partitioning and Spatial Modelling. Trans. Inst. Br. Geogr. 1977, 2, 459–472. [Google Scholar] [CrossRef] [Scilit]
- Guo, D. Regionalization with Dynamically Constrained Agglomerative Clustering and Partitioning (REDCAP). Int. J. Geogr. Inf. Sci. 2008, 22, 801–823. [Google Scholar] [CrossRef] [Scilit]
- Chavent, M.; Kuentz-Simonet, V.; Labenne, A.; Saracco, J. ClustGeo: An R Package for Hierarchical Clustering with Spatial Constraints. Comput. Stat. 2018, 33, 1799–1822. [Google Scholar] [CrossRef] [Scilit]
- Kang, Y.; Wu, K.; Gao, S.; Ng, I.; Rao, J.; Ye, S.; Zhang, F.; Fei, T. STICC: A Multivariate Spatial Clustering Method for Repeated Geographic Pattern Discovery with Consideration of Spatial Contiguity. Int. J. Geogr. Inf. Sci. 2022, 36, 1518–1549. [Google Scholar] [CrossRef] [Scilit]
- Wolf, L.J.; Knaap, E.; Rey, S. Geosilhouettes: Geographical Measures of Cluster Fit. Environ. Plan. B Urban Anal. City Sci. 2021, 48, 521–539. [Google Scholar] [CrossRef] [Scilit]
- Hinton, G.E.; Salakhutdinov, R.R. Reducing the Dimensionality of Data with Neural Networks. Science 2006, 313, 504–507. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Yang, B.; Fu, X.; Sidiropoulos, N.D.; Hong, M. Towards K-means-friendly Spaces: Simultaneous Deep Learning and Clustering. In Proceedings of the 34th International Conference on Machine Learning (ICML), Sydney, NSW, Australia, 6–11 August 2017; Volume 70, pp. 3861–3870. [Google Scholar]
- Caron, M.; Bojanowski, P.; Joulin, A.; Douze, M. Deep Clustering for Unsupervised Learning of Visual Features. In Proceedings of the Computer Vision—ECCV 2018, Munich, Germany, 8–14 September 2018; pp. 132–149. [Google Scholar] [CrossRef] [Scilit]
- Ren, Y.; Pu, J.; Yang, Z.; Xu, J.; Li, G.; Pu, X.; Yu, P.S.; He, L. Deep Clustering: A Comprehensive Survey. IEEE Trans. Neural Netw. Learn. Syst. 2025, 36, 5858–5878. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Kipf, T.N.; Welling, M. Semi-Supervised Classification with Graph Convolutional Networks. In Proceedings of the 5th International Conference on Learning Representations (ICLR), Toulon, France, 24–26 April 2017. [Google Scholar]
- Wang, C.; Pan, S.; Hu, R.; Long, G.; Jiang, J.; Zhang, C. Attributed Graph Clustering: A Deep Attentional Embedding Approach. In Proceedings of the Twenty-Eighth International Joint Conference on Artificial Intelligence (IJCAI), Macao, China, 10–16 August 2019; pp. 3670–3676. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Bo, D.; Wang, X.; Shi, C.; Zhu, M.; Cui, P.; Pan, S. Structural Deep Clustering Network. In Proceedings of the Web Conference 2020, Taipei, Taiwan, 20–24 April 2020; pp. 1400–1410. [Google Scholar] [CrossRef] [Scilit]
- Hu, J.; Li, X.; Coleman, K.; Schroeder, A.; Ma, N.; Irwin, D.J.; Lee, E.B.; Shinohara, R.T.; Li, M. SpaGCN: Integrating Gene Expression, Spatial Location and Histology to Identify Spatial Domains and Spatially Variable Genes by Graph Convolutional Network. Nat. Methods 2021, 18, 1342–1351. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Dong, K.; Zhang, S. Deciphering Spatial Domains from Spatially Resolved Transcriptomics with an Adaptive Graph Attention Auto-Encoder. Nat. Commun. 2022, 13, 1739. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Janowicz, K.; Gao, S.; McKenzie, G.; Hu, Y.; Bhaduri, B. GeoAI: Spatially Explicit Artificial Intelligence Techniques for Geographic Knowledge Discovery and Beyond. Int. J. Geogr. Inf. Sci. 2020, 34, 625–636. [Google Scholar] [CrossRef] [Scilit]
- Belkin, M.; Niyogi, P. Laplacian Eigenmaps for Dimensionality Reduction and Data Representation. Neural Comput. 2003, 15, 1373–1396. [Google Scholar] [CrossRef] [Scilit]
- Arazo, E.; Ortego, D.; Albert, P.; O’Connor, N.E.; McGuinness, K. Pseudo-Labeling and Confirmation Bias in Deep Semi-Supervised Learning. In Proceedings of the 2020 International Joint Conference on Neural Networks (IJCNN), Glasgow, UK, 19–24 July 2020; pp. 1–8. [Google Scholar] [CrossRef] [Scilit]
- Chiang, W.L.; Liu, X.; Si, S.; Li, Y.; Bengio, S.; Hsieh, C.J. Cluster-GCN: An Efficient Algorithm for Training Deep and Large Graph Convolutional Networks. In Proceedings of the 25th ACM SIGKDD International Conference on Knowledge Discovery and Data Mining, Anchorage, AK, USA, 4–8 August 2019; pp. 257–266. [Google Scholar] [CrossRef] [Scilit]
- Laakel Hemdanou, A.; Achtoun, Y.; Mouali, S.; Lamarti Sefian, M.; Šešum Čavić, V.; Radenović, S. Cover Tree-Optimized Spectral Clustering: Efficient Nearest Neighbor Search for Large-Scale Data Partitioning. Mach. Learn. Knowl. Extr. 2025, 7, 139. [Google Scholar] [CrossRef] [Scilit]
- Demšar, J. Statistical Comparisons of Classifiers over Multiple Data Sets. J. Mach. Learn. Res. 2006, 7, 1–30. [Google Scholar]
- Benavoli, A.; Corani, G.; Mangili, F. Should We Really Use Post-Hoc Tests Based on Mean-Ranks? J. Mach. Learn. Res. 2016, 17, 152–161. [Google Scholar]
- von Luxburg, U. Clustering Stability: An Overview. Found. Trends Mach. Learn. 2010, 2, 235–274. [Google Scholar] [CrossRef] [Scilit]
- Hennig, C. Cluster-Wise Assessment of Cluster Stability. Comput. Stat. Data Anal. 2007, 52, 258–271. [Google Scholar] [CrossRef] [Scilit]
- Regional Directorate of National Education and Vocational Training in Tetouan. Educational Institution Statistics for Tetouan, 2016–2022; Primary Administrative Statistical Source; Regional Directorate of National Education and Vocational Training in Tetouan: Tetouan, Morocco, 2023.
- Regional Delegation for Health and Social Protection in Tetouan. Private Medical and Paramedical Facilities in Tetouan: 2023 Data; Primary Administrative Data Source; Regional Delegation for Health and Social Protection in Tetouan: Tetouan, Morocco, 2025.
- Département des Affaires Économiques et Sociales de la Préfecture de Tétouan. Urban Mobility and Infrastructure Data: Administrative Records and Interview; Primary Administrative Data Source; Interview Dated 5 July 2024; Department of Economic and Social Affairs of the Prefecture of Tetouan: Tetouan, Morocco, 2024.
- Municipality of Tetouan. Collective Monograph of Tetouan; Primary Administrative Source; Road-Network Structure; Municipality of Tetouan: Tetouan, Morocco, 2022; p. 45.
- MacQueen, J.B. Some Methods for Classification and Analysis of Multivariate Observations. In Proceedings of the Fifth Berkeley Symposium on Mathematical Statistics and Probability, Berkeley, CA, USA, 21 June–18 July 1965 and 27 December 1965–7 January 1966; Volume 1, pp. 281–297. [Google Scholar]
- Arthur, D.; Vassilvitskii, S. k-means++: The Advantages of Careful Seeding. In Proceedings of the Eighteenth Annual ACM-SIAM Symposium on Discrete Algorithms, New Orleans, LA, USA, 7–9 January 2007; pp. 1027–1035. [Google Scholar]
- Laakel Hemdanou, A.; Achtoun, Y.; Lamarti Sefian, M.; Tahiri, I.; El Afia, A. Random Normed k-Means: A Paradigm-Shift in Clustering within Probabilistic Metric Spaces. J. Comput. Math. Data Sci. 2026, 19, 100132. [Google Scholar] [CrossRef] [Scilit]
- Zhang, T.; Ramakrishnan, R.; Livny, M. BIRCH: An Efficient Data Clustering Method for Very Large Databases. In Proceedings of the 1996 ACM SIGMOD International Conference on Management of Data, Montreal, QC, Canada, 4–6 June 1996; pp. 103–114. [Google Scholar] [CrossRef] [Scilit]
- Ward, J.H., Jr. Hierarchical Grouping to Optimize an Objective Function. J. Am. Stat. Assoc. 1963, 58, 236–244. [Google Scholar] [CrossRef]
- Müllner, D. fastcluster: Fast Hierarchical, Agglomerative Clustering Routines for R and Python. J. Stat. Softw. 2013, 53, 1–18. [Google Scholar] [CrossRef] [Scilit]
- Pelleg, D.; Moore, A.W. X-means: Extending K-means with Efficient Estimation of the Number of Clusters. In Proceedings of the Seventeenth International Conference on Machine Learning (ICML), Stanford, CA, USA, 29 June–2 July 2000; pp. 727–734. [Google Scholar]
- Campello, R.J.G.B.; Moulavi, D.; Zimek, A.; Sander, J. Hierarchical Density Estimates for Data Clustering, Visualization, and Outlier Detection. ACM Trans. Knowl. Discov. Data 2015, 10, 5. [Google Scholar] [CrossRef] [Scilit]
- McInnes, L.; Healy, J. Accelerated Hierarchical Density Based Clustering. In Proceedings of the IEEE International Conference on Data Mining Workshops (ICDMW), New Orleans, LA, USA, 18–21 November 2017; pp. 33–42. [Google Scholar] [CrossRef] [Scilit]
- Hubert, L.; Arabie, P. Comparing Partitions. J. Classif. 1985, 2, 193–218. [Google Scholar] [CrossRef] [Scilit]
- Vinh, N.X.; Epps, J.; Bailey, J. Information Theoretic Measures for Clusterings Comparison: Variants, Properties, Normalization and Correction for Chance. J. Mach. Learn. Res. 2010, 11, 2837–2854. [Google Scholar]
- Rousseeuw, P.J. Silhouettes: A Graphical Aid to the Interpretation and Validation of Cluster Analysis. J. Comput. Appl. Math. 1987, 20, 53–65. [Google Scholar] [CrossRef] [Scilit]
- Caliński, T.; Harabasz, J. A Dendrite Method for Cluster Analysis. Commun. Stat. 1974, 3, 1–27. [Google Scholar] [CrossRef] [Scilit]
- Davies, D.L.; Bouldin, D.W. A Cluster Separation Measure. IEEE Trans. Pattern Anal. Mach. Intell. 1979, PAMI-1, 224–227. [Google Scholar] [CrossRef] [Scilit]
- Friedman, M. The Use of Ranks to Avoid the Assumption of Normality Implicit in the Analysis of Variance. J. Am. Stat. Assoc. 1937, 32, 675–701. [Google Scholar] [CrossRef] [Scilit]
- Wilcoxon, F. Individual Comparisons by Ranking Methods. Biom. Bull. 1945, 1, 80–83. [Google Scholar] [CrossRef] [Scilit]
- Holm, S. A Simple Sequentially Rejective Multiple Test Procedure. Scand. J. Stat. 1979, 6, 65–70. [Google Scholar]
- Efron, B.; Tibshirani, R.J. An Introduction to the Bootstrap; Chapman and Hall: New York, NY, USA, 1993. [Google Scholar]
- Cliff, N. Dominance Statistics: Ordinal Analyses to Answer Ordinal Questions. Psychol. Bull. 1993, 114, 494–509. [Google Scholar] [CrossRef] [Scilit]
- Lakens, D. Equivalence Tests: A Practical Primer for t Tests, Correlations, and Meta-Analyses. Soc. Psychol. Personal. Sci. 2017, 8, 355–362. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Harris, C.R.; Millman, K.J.; van der Walt, S.J.; Gommers, R.; Virtanen, P.; Cournapeau, D.; Wieser, E.; Taylor, J.; Berg, S.; Smith, N.J.; et al. Array Programming with NumPy. Nature 2020, 585, 357–362. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Virtanen, P.; Gommers, R.; Oliphant, T.E.; Haberland, M.; Reddy, T.; Cournapeau, D.; Burovski, E.; Peterson, P.; Weckesser, W.; Bright, J.; et al. SciPy 1.0: Fundamental Algorithms for Scientific Computing in Python. Nat. Methods 2020, 17, 261–272, Correction in Nat. Methods 2020, 17, 352. https://doi.org/10.1038/s41592-019-0686-2. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Pedregosa, F.; Varoquaux, G.; Gramfort, A.; Michel, V.; Thirion, B.; Grisel, O.; Blondel, M.; Prettenhofer, P.; Weiss, R.; Dubourg, V.; et al. Scikit-learn: Machine Learning in Python. J. Mach. Learn. Res. 2011, 12, 2825–2830. [Google Scholar]
- Kingma, D.P.; Ba, J. Adam: A Method for Stochastic Optimization. In Proceedings of the 3rd International Conference on Learning Representations (ICLR), San Diego, CA, USA, 7–9 May 2015. [Google Scholar]
- Laakel Hemdanou, A.; Achtoun, Y.; Tahiri, I.; Lamarti Sefian, M. Clustering Students with Spectral Algorithm Enhanced by KDtree to Improve Test Score Predictions. Educ. Inf. Technol. 2025, 30, 27111–27145. [Google Scholar] [CrossRef] [Scilit]
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2026 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license.















