Build sim from data for use in reinforcement learning and bonsai platform for machine teaching.
Перейти к файлу
Ali Zaidi 7d18e348dd update: use standard multioutputs loaders; update tests 2021-01-17 21:00:40 -08:00
.github Updating numpy requirements 2020-12-04 13:04:34 -08:00
conf update: use standard multioutputs loaders; update tests 2021-01-17 21:00:40 -08:00
config Discovered release version does not run hidden code, it's removed. So fixed release version so it at least works. Moved csv data to csv_data folder. 2020-11-05 22:35:35 -08:00
csv_data add: initial hydra integration for multiple configs 2021-01-15 00:16:44 -08:00
env_data Fixed data cleaning/checker tools with recent overhaul 2020-10-27 23:54:08 -07:00
img Adding jupyter notebook for presales qualification of data driven sim creation. It is using the nbgrader package to grade its feasibility with the Validate button. The release version is intended for usage for the 'students'. Major change with datadrivenmodel is the addition of selecting the lag for iterations between state transitions from the config 2020-11-04 01:29:34 -08:00
release/presales_evaluation changing verbage from sample to test in GMM 2020-12-08 10:55:26 -08:00
source/presales_evaluation changing verbage from sample to test in GMM 2020-12-08 10:55:26 -08:00
tests update: use standard multioutputs loaders; update tests 2021-01-17 21:00:40 -08:00
.dockerignore update: ddm refactor1 2020-12-15 21:45:32 +00:00
.gitignore update: use standard multioutputs loaders; update tests 2021-01-17 21:00:40 -08:00
CODE_OF_CONDUCT.md Initial CODE_OF_CONDUCT.md commit 2020-09-08 15:20:22 -07:00
Dockerfile update: ddm refactor1 2020-12-15 21:45:32 +00:00
LICENSE.txt Adding disclaimer and updating environment.yml to not need sdk2 2020-09-16 17:03:22 -07:00
README.md 😰 update: final docs and passing off for users to test 2021-01-15 14:05:35 -08:00
SECURITY.md Initial SECURITY.md commit 2020-09-08 15:20:27 -07:00
base.py update: use standard multioutputs loaders; update tests 2021-01-17 21:00:40 -08:00
datamodeler.py Trying to integrate gboost class into tool 2021-01-04 09:16:23 -08:00
datamodeler2.py :bugs: fix: fix saving when using single filename with gboost predictors 2021-01-15 12:31:29 -08:00
environment.yml UPDATE: 📚 initial readme plus improved tests for sklearn and add max_rows arg 2021-01-15 11:48:54 -08:00
gboost_models.py update: use standard multioutputs loaders; update tests 2021-01-17 21:00:40 -08:00
keras_models.py tests and timelag -> iteration_order to prevent argument clashing 2020-12-17 18:48:51 -08:00
loaders.py refactor: loaders class now only deals with features and labels directly 2021-01-14 16:58:32 -08:00
model_loader.py ADD: configuration files for data conf with two examples 2021-01-15 10:11:21 -08:00
pltmodels.py refactor: basetrainer class for all models, initial hyperparam tuning pipelines 2020-11-09 04:22:17 +00:00
predictor.py MERGE: origin/main with alizaidi/refactor 2020-11-11 00:31:01 +00:00
requirements.txt merge: orgin/main 2020-12-16 08:49:34 +00:00
sim_predictor.py UPDATE: if no augm columns then gracefully skip 2021-01-15 15:02:14 -08:00
skmodels.py update: use standard multioutputs loaders; update tests 2021-01-17 21:00:40 -08:00
torch_models.py refactor: loaders class now only deals with features and labels directly 2021-01-14 16:58:32 -08:00
train_bonsai_main.py Minimal working for Journey using gboost and sim_predictor.py 2021-01-03 18:02:36 -08:00

README.md

Training Data-Driven or Surrogate Simulators

This repository provides a template for training data-driven simulators that can then be leveraged for training brains (reinforcement learning agents) with Project Bonsai.

⚠️ Disclaimer: This is not an official Microsoft product. This application is considered an experimental addition to Microsoft's Project Bonsai toolbox. Its primary goal is to reduce barriers of entry to use Project Bonsai's core Machine Teaching. Pull requests for fixes and small enhancements are welcome, but we expect this to be replaced by out-of-the-box features of Project Bonsai shortly.

Dependencies

This repository leverages Anaconda for Python virtual environments and all dependencies. Please install Anaconda or miniconda first and then run the following:

conda env update -f environment.yml
conda activate ddm

This will create and activate a new conda virtual environment named ddm based on the configuration in the environment.yml file.

Tests

To get an understanding of the package, you may want to look at the tests in tests, and the configuration files in conf.

Usage

The scripts in this package expect that you have a dataset of CSVs or numpy arrays. If you are using a CSV, you should ensure your CSV has a header with unique column names describing your inputs to the model and the outputs of the model. In addition, your CSV should have a column for the episode index and another column for the iteration index.

Generating Logs from an Existing Simulator

For an example on how to generate logged datasets from a simulator using the Python SDK, take a look at the examples in the samples repository, in particular, you can use the flag --test-local True --log-iteration True to generate a CSV data that matches the schema used in this repository.

Training Your Models

The scripts in this package leverage the configuration files saved in the conf folder to load CSV files, train and save models, and interface them to the Bonsai service. The library comes with a default configuration set in conf/config.yaml.

python datamodeler2.py

You can change any configuration parameter by specifying the configuration file you would like to change and its new path, i.e.,

python datamodeler2.py data=cartpole_st_at

which will use the configuration file in conf/data/cartpole_st_at.yaml.

You can also override the parameters of the configuration file by specifying their name:

python datamodeler2.py data.path=csv_data/cartpole_at_st.csv data.iteration_order=1
python datamodeler2.py data.path=csv_data/cartpole_at_st.csv model=xgboost 

The script automatically saves your model to the path specified by model.saver.filename. An outputs directory is also saved with your configuration file and logs.

Building Your Simulators

The schema for your simulator resides in conf/simulator. After defining your states, actions, and configs, you can run the simulator as follows:

python sim_predictor sim=$YOUR_SIM_CONFIG.yaml

If you would like to test your simulator before connecting to the platform, you can use a random policy:

python sim_predictor.py simulator.policy=random

Build Simulator Package

az acr build --image <IMAGE_NAME>:<IMAGE_VERSION> --file Dockerfile --registry <ACR_REGISTRY> .

Data Evaluation

Use the release version of the jupyter notebook to assist you with qualifying your data for creation of a simulator using supervised learning. The notebook is split up into three parts. The notebook uses the nbgrader package, where the user should click the Validate button to determine if all tests have been passed. You will be responsible for loading the data, running cells to see if you successfully pass tests, and manipulating the data in Python if the notebook finds things like NaNs and outliers. It will ask for desired operating limits of the model you wish to create and compare that against what is available in your provided datasets. Asssuming you pass the tests for data relevance, your data will be exported to a single csv named approved_data.csv which is ready to be ingested by the datadrivenmodel tool.

  • Data Relevance
  • Sparsity
  • Data Distribution Confidence
jupyter notebook release/presales_evaluation/presales_evaluation.ipynb

Once you have successfuly qualified your data using the Validate button, it is recommended to export it as a PDF to share the results without requiring access to the data.

Contribute Code

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.

When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repositories using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

Telemetry

The software may collect information about you and your use of the software and send it to Microsoft. Microsoft may use this information to provide services and improve our products and services. You may turn off the telemetry as described in the repository. There are also some features in the software that may enable you and Microsoft to collect data from users of your applications. If you use these features, you must comply with applicable law, including providing appropriate notices to users of your applications together with a copy of Microsoft's privacy statement. Our privacy statement is located at https://go.microsoft.com/fwlink/?LinkID=824704. You can learn more about data collection and use in the help documentation and our privacy statement. Your use of the software operates as your consent to these practices.

Trademarks

This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft's Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party's policies.