Skip to content

Commit

Permalink
Merge branch 'develop' into all-contributors/add-Dl-Vv
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaelDkhn committed Oct 25, 2023
2 parents 0f1779b + 8b1157d commit 34dfd87
Show file tree
Hide file tree
Showing 132 changed files with 9,524 additions and 540 deletions.
27 changes: 27 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,33 @@
"contributions": [
"code"
]
},
{
"login": "chachaleo",
"name": "Charlotte",
"avatar_url": "https://avatars.githubusercontent.com/u/49371958?v=4",
"profile": "https://github.com/chachaleo",
"contributions": [
"code"
]
},
{
"login": "0xfulanito",
"name": "0xfulanito",
"avatar_url": "https://avatars.githubusercontent.com/u/145947367?v=4",
"profile": "https://github.com/0xfulanito",
"contributions": [
"code"
]
},
{
"login": "0x73e",
"name": "0x73e",
"avatar_url": "https://avatars.githubusercontent.com/u/132935850?v=4",
"profile": "https://github.com/0x73e",
"contributions": [
"code"
]
}
],
"contributorsPerLine": 7,
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

# Orion: An Open-source Framework for Validity and ZK ML ✨
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
[![All Contributors](https://img.shields.io/badge/all_contributors-16-orange.svg?style=flat-square)](#contributors-)
[![All Contributors](https://img.shields.io/badge/all_contributors-19-orange.svg?style=flat-square)](#contributors-)
<!-- ALL-CONTRIBUTORS-BADGE:END -->

Orion is an open-source, community-driven framework dedicated to Provable Machine Learning. It provides essential components and a new ONNX runtime for building verifiable Machine Learning models using [STARKs](https://starkware.co/stark/).
Expand Down Expand Up @@ -89,6 +89,9 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
<tr>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/vikkydataseo"><img src="https://avatars.githubusercontent.com/u/65757691?v=4?s=100" width="100px;" alt="vikkydataseo"/><br /><sub><b>vikkydataseo</b></sub></a><br /><a href="https://github.com/gizatechxyz/orion/commits?author=vikkydataseo" title="Documentation">📖</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://www.brilliantblocks.io/"><img src="https://avatars.githubusercontent.com/u/83556514?v=4?s=100" width="100px;" alt="Daniel"/><br /><sub><b>Daniel</b></sub></a><br /><a href="https://github.com/gizatechxyz/orion/commits?author=Dl-Vv" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/chachaleo"><img src="https://avatars.githubusercontent.com/u/49371958?v=4?s=100" width="100px;" alt="Charlotte"/><br /><sub><b>Charlotte</b></sub></a><br /><a href="https://github.com/gizatechxyz/orion/commits?author=chachaleo" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/0xfulanito"><img src="https://avatars.githubusercontent.com/u/145947367?v=4?s=100" width="100px;" alt="0xfulanito"/><br /><sub><b>0xfulanito</b></sub></a><br /><a href="https://github.com/gizatechxyz/orion/commits?author=0xfulanito" title="Code">💻</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/0x73e"><img src="https://avatars.githubusercontent.com/u/132935850?v=4?s=100" width="100px;" alt="0x73e"/><br /><sub><b>0x73e</b></sub></a><br /><a href="https://github.com/gizatechxyz/orion/commits?author=0x73e" title="Code">💻</a></td>
</tr>
</tbody>
</table>
Expand Down
16 changes: 16 additions & 0 deletions docgen/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,22 @@ fn main() {
let trait_name: &str = "TreeRegressorTrait";
doc_trait(trait_path, doc_path, label);
doc_functions(trait_path, doc_path, trait_name, label);

// TREE ClASSIFIER DOC
let trait_path = "src/operators/ml/tree_classifier/core.cairo";
let doc_path = "docs/framework/operators/machine-learning/tree-classifier";
let label = "tree";
let trait_name: &str = "TreeClassifierTrait";
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
10 changes: 9 additions & 1 deletion docs/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
* [tensor.less](framework/operators/tensor/tensor.less.md)
* [tensor.less\_equal](framework/operators/tensor/tensor.less\_equal.md)
* [tensor.abs](framework/operators/tensor/tensor.abs.md)
* [tensor.neg](framework/operators/tensor/tensor.neg.md)
* [tensor.ceil](framework/operators/tensor/tensor.ceil.md)
* [tensor.cumsum](framework/operators/tensor/tensor.cumsum.md)
* [tensor.sin](framework/operators/tensor/tensor.sin.md)
Expand Down Expand Up @@ -86,6 +87,7 @@
* [tensor.unsqueeze](framework/operators/tensor/tensor.unsqueeze.md)
* [tensor.sign](framework/operators/tensor/tensor.sign.md)
* [tensor.clip](framework/operators/tensor/tensor.clip.md)
* [tensor.identity](framework/operators/tensor/tensor.identity.md)
* [Neural Network](framework/operators/neural-network/README.md)
* [nn.relu](framework/operators/neural-network/nn.relu.md)
* [nn.leaky\_relu](framework/operators/neural-network/nn.leaky\_relu.md)
Expand All @@ -95,10 +97,16 @@
* [nn.softsign](framework/operators/neural-network/nn.softsign.md)
* [nn.softplus](framework/operators/neural-network/nn.softplus.md)
* [nn.linear](framework/operators/neural-network/nn.linear.md)
* [nn.hard\_sigmoid](framework/operators/neural-network/nn.hard\_sigmoid.md)
* [nn.thresholded\_relu](framework/operators/neural-network/nn.thresholded_relu.md)
* [Machine Learning](framework/operators/machine-learning/README.md)
* [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)
* [Tree Classifier](framework/operators/machine-learning/tree-classifier/README.md)
* [tree.predict](framework/operators/machine-learning/tree-classifier/tree.predict.md)
* [tree.predict_proba](framework/operators/machine-learning/tree-classifier/tree.predict_proba.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
6 changes: 5 additions & 1 deletion docs/framework/compatibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ You can see below the list of current supported ONNX Operators:
| [Less](operators/tensor/tensor.less.md) | :white\_check\_mark: |
| [LessOrEqual](operators/tensor/tensor.less\_equal.md) | :white\_check\_mark: |
| [Abs](operators/tensor/tensor.abs.md) | :white\_check\_mark: |
| [Neg](operators/tensor/tensor.neg.md) | :white\_check\_mark: |
| [Ceil](operators/tensor/tensor.ceil.md) | :white\_check\_mark: |
| [Exp](operators/tensor/tensor.exp.md) | :white\_check\_mark: |
| [Ln](operators/tensor/tensor.log.md) | :white\_check\_mark: |
Expand All @@ -33,12 +34,14 @@ You can see below the list of current supported ONNX Operators:
| [Flatten](operators/tensor/tensor.flatten.md) | :white\_check\_mark: |
| [Relu](operators/neural-network/nn.relu.md) | :white\_check\_mark: |
| [LeakyRelu](operators/neural-network/nn.leaky\_relu.md) | :white\_check\_mark: |
|[ThresholdedRelu](operators/neural-network/nn.thresholded\_relu.md)| :white\_check\_mark: |
| [Sigmoid](operators/neural-network/nn.sigmoid.md) | :white\_check\_mark: |
| [Softmax](operators/neural-network/nn.softmax.md) | :white\_check\_mark: |
| [LogSoftmax](operators/neural-network/nn.logsoftmax.md) | :white\_check\_mark: |
| [Softsign](operators/neural-network/nn.softsign.md) | :white\_check\_mark: |
| [Softplus](operators/neural-network/nn.softplus.md) | :white\_check\_mark: |
| [Linear](operators/neural-network/nn.linear.md) | :white\_check\_mark: |
| [HardSigmoid](operators/neural-network/nn.hard\_sigmoid.md) | :white\_check\_mark: |
| [Sinh](operators/tensor/tensor.sinh.md) | :white\_check\_mark: |
| [Asinh](operators/tensor/tensor.asinh.md) | :white\_check\_mark: |
| [Cosh](operators/tensor/tensor.cosh.md) | :white\_check\_mark: |
Expand All @@ -57,5 +60,6 @@ You can see below the list of current supported ONNX Operators:
| [Unsqueeze](operators/tensor/tensor.unsqueeze.md) | :white\_check\_mark: |
| [Sign](operators/tensor/tensor.sign.md) | :white\_check\_mark: |
| [Clip](operators/tensor/tensor.clip.md) | :white\_check\_mark: |
| [Identity](operators/tensor/tensor.identity.md) | :white\_check\_mark: |

Current Operators support: **50/156 (32%)**
Current Operators support: **51/156 (33%)**
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Tree Classifier

`TreeClassifierTrait` provides a trait definition for decision tree classifier. This trait offers functionalities to build a decision tree and predict target values based on input features.

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

### Data types

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

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

***

| function | description |
| --- | --- |
| [`tree.predict`](tree.predict.md) | Given a set of features, predicts the target value using the constructed decision tree. |
| [`tree.predict_proba`](tree.predict\_proba.md) | Predicts class probabilities based on feature data. |

Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# TreeClassifierTrait::predict

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

Predicts the target value for a set of features using the provided decision tree.

## Args

* `self`: A reference to the decision tree used for making the prediction.
* `features`: A span representing the features for which the prediction is to be made.

## Returns

The predicted target value.

## Type Constraints

Constrain input and output types to fixed point.

## Examples

```rust
use orion::operators::ml::{FP16x16TreeClassifier, TreeClassifierTrait, TreeClassifier};
use orion::numbers::{FP16x16, FixedTrait};

fn tree_classifier_example(tree: TreeClassifier<FP16x16>) {

tree.predict(
array![FixedTrait::new_unscaled(1, false), FixedTrait::new_unscaled(2, false),].span()
);

}
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# TreeClassifierTrait::predict_proba

```rust
fn predict_proba(ref self: TreeClassifier<T>, features: Span<T>) -> Span<T>;
```

Given a set of features, this method traverses the decision tree
represented by `self` and returns the class distribution (probabilities)
found in the leaf node that matches the provided features. The traversal
stops once a leaf node is reached in the decision tree.

## Args

* `self`: A reference to the decision tree used for making the prediction.
* `features`: A span representing the features for which the prediction is to be made.

## Returns

Returns a `Span<T>` representing the class distribution at the leaf node.

## Type Constraints

Constrain input and output types to fixed points.

## Examples

```rust
use orion::operators::ml::{FP16x16TreeClassifier, TreeClassifierTrait, TreeClassifier};
use orion::numbers::{FP16x16, FixedTrait};

fn tree_classifier_example(tree: TreeClassifier<FP16x16>) {

tree.predict_proba(
array![FixedTrait::new_unscaled(1, false), FixedTrait::new_unscaled(2, false),].span()
);

}
```
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,5 @@ Orion supports currently only fixed point data types for `TreeRegressorTrait`.

| function | description |
| --- | --- |
| [`tree.fit`](tree.fit.md) | Constructs a decision tree regressor based on the provided data and target values. |
| [`tree.predict`](tree.predict.md) | Given a set of features, predicts the target value using the constructed decision tree. |

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# TreeRegressorTrait::predict

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

Predicts the target value for a set of features using the provided decision tree.
Expand All @@ -17,37 +17,19 @@ The predicted target value.

## Type Constraints

Constrain input and output types to fixed point tensors.
Constrain input and output types to fixed point.

## Examples

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

fn tree_regressor_example() {
fn tree_regressor_example(tree: TreeRegressor<FP16x16>) {

let data = array![
array![FixedTrait::new_unscaled(1, false), FixedTrait::new_unscaled(2, false)].span(),
array![FixedTrait::new_unscaled(3, false), FixedTrait::new_unscaled(4, false)].span(),
array![FixedTrait::new_unscaled(5, false), FixedTrait::new_unscaled(6, false)].span(),
array![FixedTrait::new_unscaled(7, false), FixedTrait::new_unscaled(8, false)].span(),
]
.span();

let target = array![
FixedTrait::new_unscaled(2, false),
FixedTrait::new_unscaled(4, false),
FixedTrait::new_unscaled(6, false),
FixedTrait::new_unscaled(8, false)
]
.span();

let mut tree = TreeRegressorTrait::fit(data, target, 3);

let prediction_1 = tree
.predict(
tree.predict(
array![FixedTrait::new_unscaled(1, false), FixedTrait::new_unscaled(2, false),].span()
);

}
```
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. |

Loading

0 comments on commit 34dfd87

Please sign in to comment.