1 Introduction

1.1 Context and motivation

Artificial intelligence (AI) and machine learning can help cultural institutions interpret attendance data, understand changes in visitor demand, and identify groups of museums with similar audiences. This report explores historical French museum attendance data, using descriptive visualization, a simple regression forecast, and unsupervised clustering.

1.2 Research problems

How can machine learning predict future museum attendance from historical visitor numbers and identify trends that may help museums plan their activities?

How can unsupervised machine learning, such as K-Means, identify different museum visitor profiles based on school visits, individual attendance, group visits, and paid versus free admissions?

The implemented models are deliberately introductory. The first uses year as a predictor; region and admission categories are documented as possible extensions. The second uses four visitor ratios; age-based indicators are available but are not included in the initial clusters.

2 Dataset and variables

The source file is ENTREES_ET_CATEGORIES_DE_PUBLIC.csv. The raw dataset contains 12292 records and 20 columns. The observed years run from 2014 to 2024. Each row describes a museum in a given year; the number of reporting museums may vary over time.

variables <- data.frame(
  Variable = c("annee", "region", "nom_du_musee", "total", "payant", "gratuit", "individuel", "scolaires", "groupes_hors_scolaires", "moins_18_ans_hors_scolaires", "_18_25_ans"),
  Meaning = c("Observation year", "Geographic region", "Museum name", "Total admissions", "Paid admissions", "Free admissions", "Individual visits", "School visitors", "Visitors in non-school groups", "Under-18 visitors outside school groups", "Visitors aged 18–25"),
  Type = c(rep("Categorical", 0), "Numeric", "Categorical", "Categorical", rep("Numeric", 8)),
  check.names = FALSE
)
knitr::kable(variables, caption = "Variables relevant to the research questions")
Variables relevant to the research questions
Variable Meaning Type
annee Observation year Numeric
region Geographic region Categorical
nom_du_musee Museum name Categorical
total Total admissions Numeric
payant Paid admissions Numeric
gratuit Free admissions Numeric
individuel Individual visits Numeric
scolaires School visitors Numeric
groupes_hors_scolaires Visitors in non-school groups Numeric
moins_18_ans_hors_scolaires Under-18 visitors outside school groups Numeric
_18_25_ans Visitors aged 18–25 Numeric
knitr::kable(head(dat[c("nom_du_musee", "region", "annee", "total", "payant", "gratuit")], 8), caption = "Sample museum records")
Sample museum records
nom_du_musee region annee total payant gratuit
musée de Brou Auvergne-Rhône-Alpes 2014 94648 53088 41560
musée de Brou Auvergne-Rhône-Alpes 2015 112860 76918 35942
musée de Brou Auvergne-Rhône-Alpes 2016 98951 74138 24813
musée de Brou Auvergne-Rhône-Alpes 2017 97132 73396 23736
musée de Brou Auvergne-Rhône-Alpes 2018 98216 62284 35932
musée de Brou Auvergne-Rhône-Alpes 2019 98110 61957 36153
musée de Brou Auvergne-Rhône-Alpes 2020 44630 28135 16495
musée de Brou Auvergne-Rhône-Alpes 2021 69814 43734 26080

3 Attendance prediction

3.1 Historical museum attendance

# Keep valid year and attendance values, then aggregate admissions by year.
# The number of museum records is also retained to monitor reporting coverage.
annual <- dat %>%
  filter(!is.na(annee), !is.na(total), total >= 0) %>%
  group_by(annee) %>%
  summarise(visitors = sum(total), records = n(), .groups = "drop") %>%
  arrange(annee)

# Plot the total recorded attendance for each year.
ggplot(annual, aes(annee, visitors)) +
  geom_line(color = "#2463a8", linewidth = 1.15) +
  geom_point(color = "#c44b3c", size = 2.7) +
  scale_x_continuous(breaks = annual$annee) +
  scale_y_continuous(labels = fmt) +
  labs(title = "Annual museum attendance", subtitle = "Recorded admissions, 2014–2024", x = "Year", y = "Total recorded admissions")

The annual totals make it possible to observe how museum attendance changed over the period. A sharp decline around 2020 would be consistent with the disruption caused by the COVID-19 pandemic and the temporary closure of cultural institutions. A recovery in the following years would suggest that visitors gradually returned to museums. However, the totals also depend on how many museums reported data each year, so an increase or decrease should not automatically be attributed to visitor behavior alone. Comparing the number of museum-year records with the attendance totals helps identify whether changes in reporting coverage may also explain part of the trend.

knitr::kable(annual, col.names = c("Year", "Total recorded admissions", "Museum-year records"), caption = "Annual attendance and reporting coverage")
Annual attendance and reporting coverage
Year Total recorded admissions Museum-year records
2014 64606704 1170
2015 61543364 1133
2016 58971364 1118
2017 61268603 1107
2018 65964548 1151
2019 65933388 1155
2020 23819133 1100
2021 31029788 1156
2022 62397742 1103
2023 68977529 1057
2024 71192245 1039

3.2 Distribution of museum attendance (histogram)

This histogram shows how museum-year attendance values are distributed across the dataset. It complements the annual trend by showing whether most museum-year records have relatively low attendance or whether a small number of records have very high attendance.

# Keep valid positive attendance values for the distribution analysis.
attendance_distribution <- dat %>%
  filter(!is.na(total), total > 0)

# A histogram displays the frequency of museum-year records across attendance ranges.
# The logarithmic x-axis makes both smaller and very large attendance values visible.
ggplot(attendance_distribution, aes(x = total)) +
  geom_histogram(bins = 40, fill = "#25967c", color = "white", alpha = 0.9) +
  scale_x_log10(labels = fmt) +
  scale_y_continuous(labels = fmt) +
  labs(
    title = "Distribution of museum-year attendance",
    subtitle = "Frequency of records by total admissions (logarithmic x-axis)",
    x = "Total admissions per museum-year (log scale)",
    y = "Number of museum-year records"
  )

The histogram helps identify the typical range of attendance and the presence of highly attended museums. If most records are concentrated on the left and only a few extend far to the right, the distribution is right-skewed: many museum-year records have modest attendance, while a smaller number have very high attendance. The logarithmic x-axis is used because museum attendance varies greatly between institutions.

3.3 Attendance forecast using linear regression

Linear regression is used to estimate the general relationship between the year and total museum attendance. The model learns a straight-line trend from the historical annual totals, then extends that trend to estimate attendance for 2025, 2026, and 2027. This provides a simple baseline that is easy to understand and compare with more advanced forecasting methods.

The model uses year as its only predictor. It does not directly account for regional differences, museum-specific characteristics, ticket prices, holidays, or exceptional events. The predictions should therefore be considered exploratory estimates rather than guaranteed attendance figures.

# Fit a linear trend using the annual attendance totals.
model <- lm(visitors ~ annee, data = annual)

# Create future years and predict their attendance using the fitted model.
# pmax(0, ...) prevents the model from returning negative attendance values.
future <- data.frame(annee = 2025:2027)
future$prediction <- pmax(0, as.numeric(predict(model, newdata = future)))

# Connect the last observed year to the forecast years for a continuous display.
forecast_path <- rbind(
  data.frame(annee = tail(annual$annee, 1), visitors = tail(annual$visitors, 1)),
  data.frame(annee = future$annee, visitors = future$prediction)
)

ggplot() +
  geom_line(data = annual, aes(annee, visitors), color = "#2463a8", linewidth = 1.15) +
  geom_point(data = annual, aes(annee, visitors), color = "#2463a8", size = 2.2) +
  geom_line(data = forecast_path, aes(annee, visitors), color = "#c44b3c", linewidth = 1.15, linetype = "dashed") +
  geom_point(data = future, aes(annee, prediction), color = "#c44b3c", size = 2.8) +
  geom_vline(xintercept = 2024.5, linetype = "dotted", color = "grey50") +
  scale_x_continuous(breaks = seq(min(annual$annee), 2027, by = 1)) +
  scale_y_continuous(labels = fmt) +
  labs(title = "Exploratory attendance forecast", subtitle = "Historical observations (blue); regression extrapolation (red)", x = "Year", y = "Admissions")

# Display the predicted attendance values and the model's R-squared statistic.
knitr::kable(data.frame(Year = future$annee, Predicted_admissions = round(future$prediction)),
             caption = "Exploratory predictions for 2025–2027")
Exploratory predictions for 2025–2027
Year Predicted_admissions
2025 56172425
2026 55902611
2027 55632797
cat("Regression R-squared:", round(summary(model)$r.squared, 3))
## Regression R-squared: 0.003

The dashed red line represents the model’s estimated future attendance, while the blue line shows the observed historical values. If the red line continues upward, the model projects an increase in attendance based on the overall historical trend; if it slopes downward, it projects a decrease. The distance between the historical points and the fitted trend indicates how closely a straight line describes the past data. A higher R-squared means that year explains a larger proportion of the variation in the annual totals within this dataset, but it does not prove that the future predictions will be accurate. The model cannot anticipate unexpected events such as museum closures, major exhibitions, changes in tourism, or changes in the number of museums reporting data.

4 Visitor segmentation

4.1 Prepare visitor ratios and train K-Means

For each museum-year record, the model computes paid, school, individual, and non-school group admissions as proportions of total attendance. Rows with missing or inconsistent ratios are excluded. K-Means uses standardized variables to prevent higher-variance features dominating the distances.

# Remove records that cannot be used to calculate visitor-category proportions.
visitors <- dat %>%
  filter(!is.na(total), total > 0,
         !is.na(payant), !is.na(scolaires),
         !is.na(individuel), !is.na(groupes_hors_scolaires)) %>%
  mutate(paid_ratio = payant / total,
         school_ratio = scolaires / total,
         individual_ratio = individuel / total,
         group_ratio = groupes_hors_scolaires / total) %>%
  filter(if_all(c(paid_ratio, school_ratio, individual_ratio, group_ratio),
                ~ is.finite(.x) & .x >= 0 & .x <= 1))

# Keep the four visitor composition variables used by K-Means.
features <- visitors %>%
  select(paid_ratio, school_ratio, individual_ratio, group_ratio)

# Remove any feature with no variation, since it cannot help separate records.
features <- features[, vapply(features, sd, numeric(1)) > 0, drop = FALSE]
if (nrow(features) < 3 || ncol(features) < 2) stop("Not enough usable data for clustering")

# Standardize variables so that each feature contributes on a comparable scale.
scaled <- scale(features)

# Fix the random seed so the clustering can be reproduced.
# nstart = 25 runs K-Means from several initial configurations.
set.seed(123)
km <- kmeans(scaled, centers = 3, nstart = 25)
visitors$cluster <- factor(km$cluster)
cat("Records in analysis:", nrow(visitors), "\n")
## Records in analysis: 9035

4.2 K-Means visitor profiles visualized with PCA

# PCA reduces the standardized visitor indicators to two dimensions for plotting.
# The cluster labels come from K-Means; PCA is used here only for visualization.
pca <- prcomp(scaled, center = FALSE, scale. = FALSE)
variance <- 100 * pca$sdev^2 / sum(pca$sdev^2)
pca_data <- data.frame(PC1 = pca$x[, 1], PC2 = pca$x[, 2], Cluster = visitors$cluster)

# Each point is one museum-year record; color shows its assigned cluster.
ggplot(pca_data, aes(PC1, PC2, color = Cluster)) +
  geom_point(alpha = .45, size = 1.4) +
  scale_color_manual(values = c("#2463a8", "#c44b3c", "#25967c")) +
  labs(title = "Visitor composition clusters", subtitle = "K-Means (K = 3), visualized with PCA", x = paste0("PC1 (", round(variance[1], 1), "% variance)"), y = paste0("PC2 (", round(variance[2], 1), "% variance)"))

Each point represents one museum observed in a particular year. Points with the same color belong to the same K-Means cluster and have similar proportions of paid, school, individual, and non-school group visits. If the colored groups are clearly separated, the visitor profiles differ noticeably. If colors overlap, some records have similar profiles even though K-Means assigned them to different clusters. The axes are principal components, not original visitor categories; the percentages indicate how much of the variation in the standardized data is represented by each axis. This plot is a simplified view of the clusters, so some differences may exist in dimensions not shown here.

4.3 Comparison of visitor profiles across clusters

# Calculate the average percentage of each visitor category within every cluster.
# These averages help describe the typical profile represented by each group.
cluster_summary <- visitors %>%
  group_by(cluster) %>%
  summarise(Records = n(),
            Paid = mean(paid_ratio) * 100,
            School = mean(school_ratio) * 100,
            Individual = mean(individual_ratio) * 100,
            Groups = mean(group_ratio) * 100,
            .groups = "drop")

cluster_long <- cluster_summary %>%
  pivot_longer(cols = c(Paid, School, Individual, Groups),
               names_to = "Visitor_type", values_to = "Percentage")

ggplot(cluster_long, aes(cluster, Percentage, fill = Visitor_type)) +
  geom_col(position = "dodge", width = .72) +
  scale_fill_manual(values = c(Paid = "#2463a8", School = "#c44b3c", Individual = "#25967c", Groups = "#e2a02c")) +
  labs(title = "Visitor characteristics by cluster", subtitle = "Average ratios by museum-year profile", x = "Cluster", y = "Mean percentage (%)", fill = "Visitor category")

knitr::kable(cluster_summary, digits = 2, caption = "Mean visitor characteristics by cluster (%)")
Mean visitor characteristics by cluster (%)
cluster Records Paid School Individual Groups
1 3698 68.68 8.23 83.87 7.58
2 2290 40.53 30.53 45.34 12.49
3 3047 17.21 11.38 83.91 4.39

The bars compare the average composition of the three visitor clusters. A cluster with a higher paid percentage contains museum-year records where paid admissions make up a larger share of total attendance. A higher school percentage indicates a stronger presence of school visits, while higher individual or non-school group percentages show which type of visit is more common in that cluster. These differences can help museums identify audience profiles and adapt communication or visitor services. Cluster numbers are assigned by the algorithm and do not represent a ranking from best to worst. Because visitor categories may overlap in the source data, the percentages should be interpreted as descriptive indicators rather than mutually exclusive shares that must add up to 100%.

5 Discussion and limitations

The analysis demonstrates two complementary applications of machine learning. Regression provides a simple, interpretable forecast baseline; clustering reveals variations in the composition of museum visits. However, the forecast is not independently validated, the K-Means cluster count is chosen for illustration, and missing values limit the segmentation sample. Museum-year observations can include repeated museums across years. Age variables are available but omitted from the clustering features because coverage is less complete.

Future work could compare predictive models using a held-out time period, include region-level data and lagged admissions, test alternative numbers of clusters using silhouette analysis, and assess the stability of visitor segments over time.

6 Conclusion

This report explored French museum attendance through five visualizations: annual attendance, an exploratory regression forecast, a histogram of attendance distribution, a PCA plot of K-Means clusters, and a comparison of cluster characteristics. The project illustrates how AI techniques can support descriptive and exploratory analysis of cultural data, while also highlighting the importance of careful data preparation, validation, and interpretation.

7 Sources and data attribution

The attendance data used in this project are provided in the file ENTREES_ET_CATEGORIES_DE_PUBLIC.csv (2014–2024), supplied for this analysis.

The official data publisher for French museum attendance is the Ministère de la Culture. Dataset: Fréquentation des Musées de France. Open data page: https://www.data.gouv.fr/datasets/frequentation-des-musees-de-france-1

The dataset is published under the Licence Ouverte / Open Licence. Please include the original CSV file alongside this report when submitting the project. The CSV used by this report must be the same file from which the variables in this analysis (annee, total, payant, gratuit, individuel, scolaires, and groupes_hors_scolaires) were obtained; do not substitute a different resource without checking its column structure.

Citation: Ministère de la Culture. Fréquentation des Musées de France. data.gouv.fr. Licence Ouverte / Open Licence. https://www.data.gouv.fr/datasets/frequentation-des-musees-de-france-1