Introduction

The SAPP (Sector-adjusted Points Plot) package provides a visualization technique designed to illustrate feature importances and interactions in a two-dimensional space. This method helps users intuitively understand the influence of different features on the model’s predictions by adjusting the position of points according to their associated feature importances.

Installation

To install the development version of the SAPP package from GitHub, you can use the following code:

# install.packages("devtools")
devtools::install_github("FaresAmine/SAPP")

Key Features

1. Calculate Sector Centers

The calculate_sector_centers() function computes the x and y coordinates of sector centers based on the provided feature importances.

calculate_sector_centers(importances)

Arguments: importances: A numeric vector of feature importances.

Returns:

A matrix with the x and y coordinates of sector centers.

2. Adjust Points Based on Influence

The adjust_points() function adjusts the position of points according to the most influential feature for each point.

adjust_points(points, centers, importances, influence_feature)

Arguments:

points: A matrix with original x, y coordinates.

centers: A matrix with x, y coordinates of sector centers.

importances: A numeric vector of feature importances.

influence_feature: A vector indicating the most influential feature for each point.

Returns:

A matrix with new x, y coordinates after adjustment.

3. SAPP Visualization

The plot_SAPP() function creates a visual representation of feature influence using ggplot2.

plot_SA(data, importances, influence_feature)

Arguments:

data: A data frame containing the features and target variable.

importances: A named numeric vector of feature importances.

influence_feature: A numeric vector indicating the most influential feature for each point. Returns:

A ggplot2 object representing the SAPP visualization.

Example Usage

Below is an example demonstrating how to use the SAPP package with a sample dataset.

install.packages(SA)
# Example Data
set.seed(42)
data <- data.frame(
  sex = sample(1:2, 50, replace = TRUE),
  num_applications = sample(5:35, 50, replace = TRUE),
  work_experience = sample(0:5, 50, replace = TRUE),
  education_level = sample(1:5, 50, replace = TRUE),
  field_of_study = sample(1:4, 50, replace = TRUE),
  age = sample(22:30, 50, replace = TRUE)
)

# Example feature importances
importances <- c(sex = 0.1, num_applications = 0.2, work_experience = 0.3, education_level = 0.25, field_of_study = 0.15)

# Mock influential feature determination
influence_feature <- apply(data[, -ncol(data)], 1, function(x) which.max(x * importances))

# Plot the SAPP
plot_SA(data, importances, influence_feature)

Future Work

The SAPP package is actively being developed. Future versions may include additional customization options for the visualizations, support for more types of data, and more advanced interaction models.

Contributing

Contributions to the SAPP package are welcome! If you find a bug or have a feature request, please submit an issue or a pull request on GitHub.

License

The SAPP package is licensed under the MIT License.

Citation

If you use the SAPP package in your research or work, please cite it as follows:

---
title: "SAPP: Sector-adjusted Points Plot"
author: "Dr. Mohamed Amine FARES"
output: 
  html_document:
    toc: true
    toc_float: true
    theme: flatly
    highlight: tango
    code_folding: hide
---