Skip to content

Commit

Permalink
generate doc
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaelDkhn committed Oct 16, 2023
1 parent bcc412d commit 55402b2
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 0 deletions.
8 changes: 8 additions & 0 deletions docgen/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ fn main() {
let trait_name: &str = "TreeRegressorTrait";
doc_trait(trait_path, doc_path, label);
doc_functions(trait_path, doc_path, trait_name, label);

// XGBOOST REGRESSOR DOC
let trait_path = "src/operators/ml/xgboost_regressor/core.cairo";
let doc_path = "docs/framework/operators/machine-learning/xgboost-regressor";
let label = "xgboost";
let trait_name: &str = "XGBoostRegressorTrait";
doc_trait(trait_path, doc_path, label);
doc_functions(trait_path, doc_path, trait_name, label);
}

fn doc_trait(trait_path: &str, doc_path: &str, label: &str) {
Expand Down
2 changes: 2 additions & 0 deletions docs/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@
* [Tree Regressor](framework/operators/machine-learning/tree-regressor/README.md)
* [tree.fit](framework/operators/machine-learning/tree-regressor/tree.fit.md)
* [tree.predict](framework/operators/machine-learning/tree-regressor/tree.predict.md)
* [XGBoost Regressor](framework/operators/machine-learning/xgboost-regressor/README.md)
* [xgboost.predict](framework/operators/machine-learning/xgboost-regressor/xgboost.predict.md)

## 🏛 Hub

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Tree Regressor

`XGBoostRegressorTrait` provides a trait definition for xgboost regression. This trait offers functionalities to predict target values based on input features.

```rust
use orion::operators::ml::XGBoostRegressorTrait;
```

### Data types

Orion supports currently only fixed point data types for `XGBoostRegressorTrait`.

| Data type | dtype |
| -------------------- | ------------------------------------------------------------- |
| Fixed point (signed) | `TreeRegressorTrait<FP8x23 \| FP16x16 \| FP64x64 \| FP32x32>` |

***

| function | description |
| --- | --- |
| [`xgboost.predict`](xgboost.predict.md) | Predicts the target value for a set of features using the provided ensemble of decision trees. |

Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# XGBoostRegressorTrait::predict

```rust
fn predict(ref self: Span<TreeNode<T>>, ref features: Span<T>, ref weights: Span<T>) -> T;
```

Predicts the target value for a set of features using the provided ensemble of decision trees
and combining their results using given weights.

## Args

* `self`: A reference to a span representing a ensemble of decision trees.
* `features`: A reference to a span representing the features for which the prediction is to be made.
* `weights`: A reference to a span representing the weights applied to the predictions from each tree.

## Returns

The predicted target value.

## Type Constraints

Constrain input and output types to fixed point.

## Examples

```rust
use orion::operators::ml::{FP16x16XGBoostRegressor, TreeRegressorTrait, TreeRegressor};
use orion::numbers::{FP16x16, FixedTrait};

fn xgboost_regressor_example(trees: Span<TreeRegressor<FP16x16>>) {

let mut features = array![
FixedTrait::new_unscaled(1, false),
FixedTrait::new_unscaled(2, false),
].span();

let mut weights = array![
FixedTrait::new_unscaled(0.5, false),
FixedTrait::new_unscaled(0.5, false)
].span();

FP16x16XGBoostRegressor::predict(ref trees, ref features, ref weights);
}
```

0 comments on commit 55402b2

Please sign in to comment.