---
title: "7. Selecting the best fit"
output:
  rmarkdown::html_vignette:
    keep_md: true
vignette: >
  %\VignetteIndexEntry{7. Selecting the best fit}
  %\VignetteEngine{knitr::rmarkdown}
  %\VignetteEncoding{UTF-8}
---

```{r, include = FALSE}
knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  message = FALSE,
  warning = FALSE
)
```

```{r setup}
library(quollr)
library(dplyr)
library(ggplot2)
library(patchwork)

set.seed(20240110)
```

This illustrates how to compare multiple NLDR layouts and select the most appropriate one. The evaluation is typically based on Residual Mean Squared Error (RMSE), allowing you to assess the quality of different binning configurations or modeling strategies.

## Step 1: Generate design for 2-D NLDR layouts

We begin by specifying a layout design for arranging the plots. The design defines the arrangement of 2-D NLDR layouts.

```{r}
design <- gen_design(n_right = 4, ncol_right = 2)
```

## Step 2: Visualising RMSE across configurations

To visually compare multiple 2-D NLDR layouts, we use the `plot_rmse_layouts()` function. This function plots RMSE values against different bin width configurations along with 2-D NLDR layouts, making it easier to identify the best-performing model visually.

```{r, fig.alt="RMSE Vs binw idths.", fig.height=10, fig.width=15, out.width="100%"}

plot_rmse_layouts(plots = scurve_plts, design = design)
```

