Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

R + Weights & Biases Integration Example

This project demonstrates how to train a model in R and log metrics to Weights & Biases using a Python bridge.

Structure

  • src/R/models/LinearModelTrainer.R: R6 class for model training.
  • src/R/utils/WandbLogger.R: R6 class that handles communication with Python.
  • src/python/wandb_adapter.py: Python script that interfaces with the W&B SDK.
  • main.R: Main entry point.

Prerequisites

1. R Dependencies

Run the install script:

Rscript install.R

2. Python Dependencies

You need wandb installed.

pip install -r requirements.txt

3. Environment Setup

  1. Copy .Renviron.example to .Renviron:
    cp .Renviron.example .Renviron
  2. Edit .Renviron and add your W&B API Key:
    WANDB_API_KEY=your_actual_api_key
    
    Or ensure you are logged in via CLI:
    wandb login

Usage

Run the main R script:

Rscript main.R

Or source main.R in your RStudio session and run main().

How it works

  1. R trains the model and calculates metrics.
  2. WandbLogger in R writes these metrics to a temporary JSON file.
  3. R calls src/python/wandb_adapter.py via system2().
  4. The Python script reads the JSON, logs to W&B, and exits.

About

Convert R model training into a W&B Python SDK friendly logger.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages