Technology
December 10, 2025
Analysis of parliamentary spending patterns through clustering
Author: Dalciana Bressan Waller — Advisor: Eder Costa Cassettari
Summary prepared by the ResumeAI tool, an artificial intelligence solution developed by Instituto Pecege focused on synthesis and writing.
The objective of this research was to investigate the spending patterns of Brazilian federal deputies with the Quota for the Exercise of Parliamentary Activity (CEAP), using unsupervised clustering techniques to identify groupings. The study explored a public database to verify the existence of similar spending behaviors among parliamentarians, segmenting them into groups with distinct consumption profiles. The analysis aims to provide a tool that contributes to the oversight and transparency in the use of public resources, identifying general trends and atypical behaviors that may warrant investigation.
The relevance of this work lies in the growing demand for governmental transparency. The opening of public data allows citizens to exercise social control over their representatives (Silva et al., 2014), strengthening civic participation and management efficiency. According to a report by the Federal Court of Accounts (Tribunal de Contas da União), transparency is a central tool in combating corruption, as the publicity of administrative acts deters illicit practices by exposing managers to public scrutiny (TCU, 2018).
The Brazilian parliament has been evolving in the regulation and disclosure of the use of public funds. Lemos and Joseph (2010) highlight that measures have been implemented to provide greater publicity and rigor in monitoring these expenditures. Among the financial aids, the Quota for the Exercise of Parliamentary Activity (CEAP), established in 2009, is one of the main funding mechanisms, covering expenses such as air travel, office maintenance, food, accommodation, transportation, and dissemination of parliamentary activity.
Transparency in the use of CEAP was formalized by Ordinance 228/2014, which mandated the publication of invoices. The monthly quota value ranges between R$ 36,000 and R$ 51,400 per deputy, depending on the state of origin to reflect cost differences, mainly related to travel. A characteristic of the regulation is that the unused balance in some categories can be accumulated throughout the fiscal year, influencing spending patterns, while other categories have strict, non-accumulable monthly limits.
The research applies data analysis techniques to explore the CEAP spending base, seeking consumption patterns that allow grouping parliamentarians into clusters. The use of unsupervised machine learning algorithms, such as hierarchical clustering and K-means, offers an objective approach to discovering latent structures in the data. The study also verifies whether current quota rules can facilitate abuses or questionable necessity spending, promoting awareness about the use of public resources.
The analysis material consists of public databases on CEAP expenses, from the open data portal of the Chamber of Deputies. The CSV files from 2023, 2024, and 2025, from the 57th legislature, were used. The consolidated dataset covered the period from February 1, 2023, to April 30, 2025, totaling 604,374 expense records. The cutoff date was chosen to ensure data completeness, considering the 90-day deadline for submitting receipts. The central variables extracted were parliamentarian’s name, party, state (UF), expense description, and net amount.
Data preparation involved rigorous treatment. Monetary fields were converted to numeric format. To reduce granularity, the auxiliary variable macrocategories grouped detailed descriptions into broader categories, such as “office maintenance”, “fuels and lubricants”, and “parliamentary activity disclosure”. External categorical variables were incorporated to enrich the parliamentarians’ profile, such as re-election (catreeleicao) and tenure (catcargotitusup). The time variable numAnoMes_compet was created for temporal analyses. Monetary updating was not applied to simplify comparative analysis in the short term.
The methodology was based on unsupervised clustering, suitable for grouping observations by intrinsic similarities without a predefined response variable (Fávero and Belfiore, 2017). The first technique was hierarchical clustering, which builds a hierarchy of clusters represented by a dendrogram. Different distance metrics (Euclidean, Manhattan, Chebyshev) and linkage methods (single, complete, average) were tested. Euclidean distance measures the direct linear distance, while Manhattan calculates the sum of absolute differences, both derived from the Minkowski dissimilarity measure.
The second and main technique was the K-means algorithm, a non-hierarchical method that partitions the data into a pre-defined number K of clusters, minimizing the sum of intra-cluster squared distances (WCSS). The choice of the ideal number of clusters (K) was guided by the “elbow method” and the silhouette method, which measures the cohesion and separation of clusters. Processing and modeling were performed in Python, using the Jupyter Notebook environment and the Pandas, Scikit-learn, Matplotlib, and Seaborn libraries.
The initial exploratory analysis revealed no temporal anomalies, with the exception of January 2023, the last month of the previous term. 623 names of deputies with expenses were identified, a number higher than the 513 elected due to the performance of substitutes. Geographically, deputies from São Paulo, Minas Gerais, and Rio de Janeiro had the highest total expenditure volumes, as expected due to having the largest delegations. However, the analysis of average expenditure per parliamentarian showed that deputies from states in the North region presented the highest averages, possibly due to higher costs with air travel.
The distribution of expenditure by category was one of the most significant findings. The “disclosure of parliamentary activity” item accounted for almost 40% of the total amount spent on the CEAP. The temporal analysis of this category revealed strong seasonality, with expenditure intensifying in the second half of each year. This pattern is relevant because, unlike other categories, parliamentary disclosure does not have a monthly spending limit. The absence of a ceiling, combined with the non-accumulation of balance between fiscal years, may encourage the concentration of expenses at the end of the year, raising questions about their real necessity. This concern has already been pointed out by the TCU (2019), which recommended a review of the rules for this item, suggesting the establishment of criteria and maximum values.
The clustering was performed in three stages. In the first, 21 expense category variables were used for all 623 parliamentarians, with low collinearity among them. Hierarchical clustering resulted in illegible dendrograms, a common limitation in large datasets, as Noble points out. The attempt with K-means was also unsuccessful: the elbow and silhouette methods did not indicate a clear number of clusters. Analysis of variance (ANOVA) showed that most variables were significant, but the overlap of groups in 3D plots demonstrated the difficulty in separating them based on such a broad set of variables.
In the second stage, the approach was refined, focusing on the six categories with the highest financial representativeness: disclosure of parliamentary activity, air travel, vehicle rental, office maintenance, fuel, and accommodation. With this reduced set, the results were more promising. The elbow method and silhouette analysis suggested an optimal number between 3 and 5 clusters. Opting for 5 clusters, ANOVA confirmed the relevance of all six variables, with “disclosure of parliamentary activity” being the most discriminant (highest F statistic). The 3D visualization showed a clearer separation, although with some overlap. It was possible to identify one cluster (Cluster 4) with high spending on disclosure and air travel, and another (Cluster 3) with more contained expenses, composed mainly of substitute and first-term deputies.
The third stage adopted a new perspective, using as variables the average monthly spending values in the same six categories, weighted by the number of months in office to normalize the data. Again, the elbow method indicated 3 to 5 clusters. The application of K-means with 5 clusters revealed an interesting result: the formation of a cluster (Cluster 4) with only three parliamentarians. The analysis of the centroids showed that these individuals presented a significantly higher average monthly spending pattern than the others, characterizing them as outliers. According to Fávero and Belfiore (2017), the sensitivity of K-means to outliers can lead to the formation of individual clusters, and the identification of these atypical points is a valuable result, as it points to behaviors that deviate from the norm and may justify an audit.
The general analysis of the clustering results indicates that, although spending patterns are largely homogeneous, the application of segmentation techniques allows for the identification of distinct consumption profiles. The initial difficulty in forming clusters with many variables suggests that lower expenditures follow a similar pattern among parliamentarians. However, by focusing on the categories with the greatest financial impact, especially “disclosure of parliamentary activity”, it was possible to group the deputies more coherently. The identification of a small group with average expenses much higher than the average in the third stage reinforces the potential of the methodology as a monitoring tool to highlight cases that require greater scrutiny.
The study demonstrated that the application of unsupervised machine learning to public parliamentary spending data is a viable approach to promote transparency. The analysis revealed that “disclosure of parliamentary activity” is the main differentiating factor in spending patterns and, due to its flexible regulation, represents an area of potential vulnerability. The study’s limitations include the relatively small number of observations (deputies), which can be overcome in future work by including data from previous legislatures. Suggestions for future research include applying more robust algorithms to outliers such as K-means++, analyzing anomalies in the granular database, and investigating supplier CNPJs.
The analysis demonstrates the usefulness of clustering techniques for public spending oversight, offering a path to enhance transparency and social control. The ability to segment and identify patterns and outliers in large volumes of government data represents an advance for auditing and accountability. It is concluded that the objective was achieved: it was demonstrated that, although general spending patterns are homogeneous, segmented analysis through clustering allows for the identification of specific consumption profiles and outliers that can support control and transparency actions.
References:
Chamber of Deputies Press Office. Guide for journalists on Parliamentary Quotas. Available at <https://www2. camara. leg. br/comunicacao/assessoria-de-imprensa/guia-para-jornalistas/cota-parlamentar>. Accessed on May 31, 2025.
Chamber of Deputies. Press Office. Guide for journalists about the Chamber of Deputies. Available at <https://www2. camara. leg. br/comunicacao/assessoria-de-imprensa/guia-para-jornalistas/camara-dos-deputados>. Accessed on June 16, 2025.
Chamber of Deputies. Press Office on recess. Available at <https://www2. camara. leg. br/comunicacao/assessoria-de-imprensa/guia-para-jornalistas/recesso-dos-deputados>. Accessed on July 19, 2025.
Chamber of Deputies. Quota for the Exercise of Parliamentary Activity (Ceap). Available at <https://www2. camara. leg. br/a-camara/documentos-e-pesquisa/arquivo/sites-tematicos/57a-legislatura/no-exercicio-do-mandato/cota-para-o-exercicio-da-atividade-parlamentar-ceap>. Accessed on September 2, 2025.
Chamber of Deputies. Open data. Session Expenses by Quota for Exercise of Parliamentary Activity. Available at <https://dadosabertos. camara. leg. br/swagger/api. html? tab=staticfile>. First accessed on May 10, 2025 and second accessed on September 2, 2025.
Chamber of Deputies. Parliamentary expenses. Available at <https://www. camara. leg. br/transparencia/gastos-parlamentares/>. Accessed on May 2, 2025.
Chamber of Deputies. Frequently asked questions about deputies and their mandates. Available at <https://www2. camara. leg. br/transparencia/acesso-a-informacao/copyofperguntas-frequentes/deputados>. Accessed on September 2, 2025.
Chamber of Deputies. Ordinance No. 228, of 06/18/2014. Available at <https://www2. camara. leg. br/legin/int/portar/2014/portaria-228-18-junho-2014-779144-publicacaooriginal-144692-cd-dg. html>. Accessed on June 16, 2025.
Chamber of Deputies. Results of elected deputies (holders) for the 57th legislature. Available at <https://www. camara. leg. br/internet/agencia/infograficos-html5/tabelasEleicoes/deputados-eleitos-estado/index. html>. Accessed on July 20, 2025.
Chamber of Deputies. Results of reelected deputies for the 57th legislature. Available at <https://www. camara. leg. br/noticias/912220-reeleicao-na-camara-alcanca-57-veja-quais-deputados-foram-reeleitos/>. Accessed on July 5, 2025.
Chamber of Deputies. Meaning of the columns in the parliamentary expenses database. <https://dadosabertos. camara. leg. br/howtouse/2023-12-26-dados-ceap. html>. Accessed on May 2, 2025.
Fávero, L. P.; Belfiore, P. Manual of data analysis: statistics and multivariate modeling with Excel, SPSS, and Stata. Rio de Janeiro: Elsevier, 2017. Accessed on June 7, 2025.
Lemos, L.; Joseph, R. 2010. Parliamentarians’ Expenses Recent Reforms: a briefing on Australia, Canada, United Kingdom and Brazil. Global Economic Governance Programme- GEG Working Paper 2010/57. Available at <https://www. geg. ox. ac. uk/sites/default/files/Lemos%20JosephGEG%20WP%20201057. pdf>. Accessed on June 15, 2025.
Noble, J. How hierarchical clustering works. Available at <https://www. ibm. com/br-pt/think/topics/hierarchical-clustering> Accessed on August 17, 2025.
Silva, C. F.; Santos, E. M. F.; Chaves, M. C.; Vaz, W; Balaniuk;. R. Open data: a strategy for increasing transparency and modernizing public management. Revista do TCU, Brasília, n. 131, p. 22–29, 2014. Available at: <https://revista. tcu. gov. br/ojs/index. php/RTCU/article/view/59> Accessed on June 14, 2025.
Court of Accounts of the Union. 2018. Systemic report on Public Transparency. Available at: <https://portal. tcu. gov. br/data/files/16/63/C5/6F/46A1F6107AD96FE6F18818A8/Fisc_Transparencia. pdf>. Accessed on June 15, 2025.
Court of Accounts of the Union. 2019. Decision 3048/2019 – Plenary. Available at <https://pesquisa. apps. tcu. gov. br//acordao-completo/Ac%25C3%25B3rd%25C3%25A3o%25203048%252F2019%2520/%2520/DTRELEVANCIA%2520desc%252C%2520NUMACORDAOINT%2520desc/0/%2520>. Accessed on June 30, 2025.
Executive summary from the Final Project of the Specialization in Data Science and Analytics from the MBA USP/Esalq
Learn more about the course; click here: