https://github.com/thesps/maxbdt
https://github.com/thesps/maxbdt
fpga java maxeler
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/thesps/maxbdt
- Owner: thesps
- Created: 2017-05-02T10:49:57.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2017-06-15T13:40:39.000Z (about 9 years ago)
- Last Synced: 2025-03-23T14:36:21.673Z (over 1 year ago)
- Topics: fpga, java, maxeler
- Language: Python
- Size: 80.1 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# A Boosted Decision Tree for Maxeler Dataflow Engines
## Example Project
To get started with the example, first:
```
cd CPUCode
python example_train.py
```
This creates a dummy dataset, and trains a BDT to classify it using sklearn.
The BDT is written to `bdt.pkl` so we can use it again in python, and `bdtjson.txt` so we can generate a DFE implementation.
Now build the DFE project:
```
cd RunRules/
make build
```
Create the SLiC skin:
```
sliccompile -t python -m maxfiles/DFEBDT.max
mv DFEBDT.py _DFEBDT.so simutils/ ../../CPUCode
```
Compare the sklearn `GradientBoostingClassifier.decision_function` output to the DFE, over the whole dataset feature range (as in [the sklearn example](http://scikit-learn.org/stable/auto_examples/classification/plot_classifier_comparison.html)):
```
cd CPUCode
python example_test.py
```

## Custom Project
To make your own low latency BDT predictions, first of all train a BDT with sklearn, and write the JSON file:
```
import bdtToJSON
myBDT = GradientBoostingClassifier()
myBDT.fit(myTrainX, myTrainY)
with open('mybdtjson.txt', 'w') as f:
f.write(bdtToJSON.toJSON(myBDT))
```
Modify EngineCode/src/BDTManager.maxj to point to your JSON file.
You may also want to change the data type of the features and score in the same file.
## Dependencies
The `maxj` project requires [json-simple](https://github.com/fangyidong/json-simple) and [maxpower](https://github.com/maxeler/maxpower).
Running the example additionally requires python libraries `sklearn`, `numpy`, `matplotlib`, `json`.