-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Also update install process and instructions PiperOrigin-RevId: 616216549
- Loading branch information
1 parent
89dae4f
commit 2814d79
Showing
15 changed files
with
290 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
5.3.0 | ||
6.5.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
# Building and installing YDF | ||
|
||
## Install from PyPi | ||
|
||
To install YDF, run: | ||
|
||
``` | ||
pip install ydf --upgrade | ||
``` | ||
|
||
## Building | ||
|
||
### Pre-work | ||
|
||
Use `tools/update_version.sh` to update the version number (if needed) and | ||
remember to update `CHANGELOG.md`. | ||
|
||
### Linux | ||
|
||
#### Docker | ||
|
||
For building manylinux2014-compatible packages, you can use an appropriate | ||
Docker image. The pre-configured build script at | ||
`tools/build_linux_release_in_docker.sh` starts a container and builds the | ||
wheels end-to-end. You can find the wheels in the `dist/`subdirectory. | ||
|
||
#### Manual build | ||
|
||
Note that we may not be able to help with issues during manual builds. | ||
|
||
**Requirements** | ||
|
||
* Bazel - version as specified in `.bazelversion`, | ||
[Bazelisk](https://github.com/bazelbuild/bazelisk) recommended | ||
* GCC >= 9 or Clang >= 14 | ||
* rsync | ||
* Python headers (e.g. `python-dev` package on Ubuntu) | ||
* Python virtualenv | ||
|
||
**Steps** | ||
|
||
1. Compile and test the code with | ||
|
||
```shell | ||
# Create a virtual environment where Python dependencies will be installed. | ||
python -m venv myvenv | ||
RUN_TESTS=1 ./tools/test_pydf.sh | ||
deactivate | ||
``` | ||
|
||
Substitute for your compiler name / version | ||
|
||
1. Build the Pip package | ||
|
||
```shell | ||
PYTHON_BIN=python | ||
./tools/build_pydf.sh $PYTHON_BIN | ||
``` | ||
|
||
If you want to build with [Pyenv](https://github.com/pyenv/pyenv) for all supported Python versions, run | ||
|
||
```shell | ||
./tools/build_pydf.sh ALL_VERSIONS | ||
``` | ||
|
||
### MacOS | ||
|
||
**Requirements** | ||
|
||
* Bazel (version as specified in `.bazelversion`, | ||
[Bazelisk](https://github.com/bazelbuild/bazelisk) recommended) | ||
* XCode command line tools | ||
* [Pyenv](https://github.com/pyenv/pyenv) | ||
|
||
**Building for all supported Python versions** | ||
|
||
Simply run | ||
|
||
```shell | ||
./tools/build_macos_release.sh | ||
``` | ||
This will build a MacOS wheel for every supported Python version on the current | ||
architecture. See the contents of this script for details about the build. | ||
|
||
### MacOS cross-compilation | ||
|
||
We have not tested MacOS cross-compilation (Intel <-> ARM) for YDF yet, though | ||
it is on our roadmap. | ||
|
||
### AArch64 | ||
|
||
We have not tested AArch64 compilation for YDF yet. | ||
|
||
### Windows | ||
|
||
TODO, see `tools/build.bat`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
yggdrasil_decision_forests/port/python/examples/minimal.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# Copyright 2022 Google LLC. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
r"""Minimal usage example of YDF. | ||
This example trains, displays, evaluates and exports a Gradient Boosted Tree | ||
model. | ||
Usage example: | ||
pip install ydf pandas -U | ||
python minimal.py | ||
""" | ||
|
||
from absl import app | ||
import pandas as pd | ||
import ydf | ||
|
||
|
||
def main(argv): | ||
if len(argv) > 1: | ||
raise app.UsageError("Too many command-line arguments.") | ||
|
||
# Download the Adult dataset, load in a Pandas dataframe. | ||
train_path = "https://raw.githubusercontent.com/google/yggdrasil-decision-forests/main/yggdrasil_decision_forests/test_data/dataset/adult_train.csv" | ||
test_path = "https://raw.githubusercontent.com/google/yggdrasil-decision-forests/main/yggdrasil_decision_forests/test_data/dataset/adult_train.csv" | ||
train_df = pd.read_csv(train_path) | ||
test_df = pd.read_csv(test_path) | ||
|
||
# Display full logs | ||
ydf.verbose(2) | ||
|
||
# Trains the model. | ||
model = ydf.GradientBoostedTreesLearner(label="income").train(train_df) | ||
|
||
# Some information about the model. | ||
print(model.describe()) | ||
|
||
# Evaluates the model on the test dataset. | ||
evaluation = model.evaluate(test_df) | ||
print(evaluation) | ||
|
||
# Exports the model to disk. | ||
model.save("/tmp/ydf_model") | ||
|
||
# Reload the model from disk | ||
loaded_model = ydf.load_model("/tmp/ydf_model") | ||
|
||
# Make predictions with the model from disk. | ||
predictions = loaded_model.predict(test_df) | ||
print(predictions) | ||
|
||
|
||
if __name__ == "__main__": | ||
app.run(main) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
yggdrasil_decision_forests/port/python/tools/build_macos_release.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/bin/bash | ||
# Copyright 2022 Google LLC. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# https://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
|
||
set -vex | ||
|
||
declare -a python_versions=("3.8" "3.9" "3.10" "3.11") | ||
|
||
for pyver in "${python_versions[@]}" | ||
do | ||
pyenv install -s $pyver | ||
export PYENV_VERSION=$pyver | ||
rm -rf ${TMPDIR}venv | ||
python -m venv ${TMPDIR}venv | ||
source ${TMPDIR}venv/bin/activate | ||
pip install --upgrade pip | ||
|
||
echo "Building with $(python3 -V 2>&1)" | ||
|
||
bazel clean --expunge | ||
RUN_TESTS=0 CC="clang" ./tools/test_pydf.sh | ||
./tools/build_pydf.sh python | ||
deactivate | ||
done |
Oops, something went wrong.