Skip to content

Commit

Permalink
Update README with detailed instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
gdequeiroz committed Sep 11, 2020
1 parent e267a8d commit af4688c
Show file tree
Hide file tree
Showing 2 changed files with 147 additions and 4 deletions.
68 changes: 66 additions & 2 deletions aif360/aif360-r/README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,69 @@ library(aif360)
install_aif360()
```

## Installation methods

AIF360 is distributed as a Python package and so needs to be installed within a Python environment on your system. By default, the install_aif360() function attempts to install AIF360 within an isolated Python environment (“r-reticulate”).

You can check using `reticulate::conda_python()` and `reticulate::py_config()`

### Suggested steps

1) Install reticulate and check if you have miniconda installed. If you do, go to step 2.

```r
install.packages("reticulate")
reticulate::conda_list()
```
If you get an error: `Error: Unable to find conda binary. Is Anaconda installed?`, please install
miniconda

```r
reticulate::install_miniconda()
```
If everything worked, you should get the message:

`* Miniconda has been successfully installed at '/home/rstudio/.local/share/r-miniconda'.`

You can double check:

```
reticulate::conda_list()
```
You will get something like this:

```
name python
1 r-miniconda /home/rstudio/.local/share/r-miniconda/bin/python
2 r-reticulate /home/rstudio/.local/share/r-miniconda/envs/r-reticulate/bin/python
```


2) You can create a new conda env and then configure which version of Python to use:

```r
reticulate::conda_create(envname = "r-test")
reticulate::use_miniconda(condaenv = "r-test", required = TRUE)
```
Check that everything is working `reticulate::py_config()`.

3) If you haven't yet, please install the aif360 package `install.packages("aif360")` and then
install aif360 dependencies

```r
aif360::install_aif360(envname = "r-test")
```
Note that this step should take a few minutes and the R session will restart.

4) Finally, load the aif360 functions

```
library(aif360)
reticulate::use_miniconda(condaenv = "r-test", required = TRUE)
load_aif360_lib()
```


## Getting Started

``` r
Expand All @@ -56,8 +119,9 @@ load_aif360_lib()
``` r
# load a toy dataset
data <- data.frame("feature1" = c(0,0,1,1,1,1,0,1,1,0),
"feature2" = c(0,1,0,1,1,0,0,0,0,1),
+ "label" = c(1,0,0,1,0,0,1,0,1,1))
"feature2" = c(0,1,0,1,1,0,0,0,0,1),
"label" = c(1,0,0,1,0,0,1,0,1,1))

# format the dataset
formatted_dataset <- aif360::aif_dataset(data_path = data,
favor_label = 0,
Expand Down
83 changes: 81 additions & 2 deletions aif360/aif360-r/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,84 @@ library(aif360)
install_aif360()
```

## Installation methods

AIF360 is distributed as a Python package and so needs to be installed
within a Python environment on your system. By default, the
install\_aif360() function attempts to install AIF360 within an isolated
Python environment (“r-reticulate”).

You can check using `reticulate::conda_python()` and
`reticulate::py_config()`

### Suggested steps

1) Install reticulate and check if you have miniconda installed. If you
do, go to step 2.

<!-- end list -->

``` r
install.packages("reticulate")
reticulate::conda_list()
```

If you get an error: `Error: Unable to find conda binary. Is Anaconda
installed?`, please install miniconda

``` r
reticulate::install_miniconda()
```

If everything worked, you should get the message:

`* Miniconda has been successfully installed at
'/home/rstudio/.local/share/r-miniconda'.`

You can double check:

reticulate::conda_list()

You will get something like this:

```
name python
1 r-miniconda /home/rstudio/.local/share/r-miniconda/bin/python
2 r-reticulate /home/rstudio/.local/share/r-miniconda/envs/r-reticulate/bin/python
```

2) You can create a new conda env and then configure which version of
Python to use:

<!-- end list -->

``` r
reticulate::conda_create(envname = "r-test")
reticulate::use_miniconda(condaenv = "r-test", required = TRUE)
```

Check that everything is working `reticulate::py_config()`.

3) If you haven’t yet, please install the aif360 package
`install.packages("aif360")` and then install aif360 dependencies

<!-- end list -->

``` r
aif360::install_aif360(envname = "r-test")
```

Note that this step should take a few minutes and the R session will
restart.

4) Finally, load the aif360 functions

<!-- end list -->

library(aif360)
reticulate::use_miniconda(condaenv = "r-test", required = TRUE)
load_aif360_lib()

## Getting Started

``` r
Expand All @@ -47,8 +125,9 @@ load_aif360_lib()
``` r
# load a toy dataset
data <- data.frame("feature1" = c(0,0,1,1,1,1,0,1,1,0),
"feature2" = c(0,1,0,1,1,0,0,0,0,1),
+ "label" = c(1,0,0,1,0,0,1,0,1,1))
"feature2" = c(0,1,0,1,1,0,0,0,0,1),
"label" = c(1,0,0,1,0,0,1,0,1,1))

# format the dataset
formatted_dataset <- aif360::aif_dataset(data_path = data,
favor_label = 0,
Expand Down

0 comments on commit af4688c

Please sign in to comment.