# How to Reproduce the Results of the Numerical Experiments in Section D.1.

## Preparation

### Python Environment
You may need to create a virtual environment and install the following packages using pip:

```
python -m venv ./env_dre_expr
source ./env_dre_expr/bin/activate
pip install --upgrade pip
pip install numpy
pip install pandas
pip install matplotlib
pip install -U scikit-learn
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
pip install lightning
pip install tensorboard
```

### R Environment
The ```densratio``` library in R is used for KLIEP and uLSIF.  
To conduct the experiments related to Section 6.2, install this library by running the following command in an R console:

```
> install.packages("densratio")
```

---

## Running the Experiments

### Reproducing the Results in Section D.1.

#### 1. Generate Datasets
First, generate the datasets used in the experiments. The datasets will be saved in the ```data/DRE``` directory:

```
source env_dre_expr/bin/activate
python generate_data_for_experiment_Section_D_1.py
```

#### 2. Run Scripts
* **For $\alpha$-Div**:  
  To reproduce all the results of $\alpha$-Div, run the following script:

  ```
  source env_dre_expr/bin/activate
  python run_experiment_Section_D_1_alphaDiv.py
  ```

* **For D3RE**:  
  To reproduce all the results of D3RE, run the following script:

  ```
  source env_dre_expr/bin/activate
  python run_experiment_Section_D_1_nnBD_LSI.py
  ```


* **For KLIEP and uLSIF**:  
   To reproduce all the results for KLIEP and uLSIF, execute the R scripts ```run_exp_Section_D_1_KLIEP.R``` and ```run_exp_Section_D_1_uLSIF.R``` in the R console as follows:

   * **KLIEP**:
      ```
      > setwd("<path to the directory where generate_data_for_experiment_Section_D_1.py was executed>")
      > source("run_exp_Section_D_1_KLIEP.R")
      ```

   * **uLSIF**:
      ```
      > setwd("<path to the directory where generate_data_for_experiment_Section_D_1.py was executed>")
      > source("run_exp_Section_D_1_uLSIF.R")
      ```
