Skip to content

Rust extension - XGBoost #286

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Aug 31, 2022
Merged

Rust extension - XGBoost #286

merged 11 commits into from
Aug 31, 2022

Conversation

levkk
Copy link
Contributor

@levkk levkk commented Aug 30, 2022

Adding Rust XGBoost POC:

  • train from a Postgres table
  • predict using passed-in features
  • load model trained in other languages (e.g. Python)

Latency per prediction varies between 0.9ms and 6ms.

///
/// ```
/// SELECT * FROM pgml_train('pgml.diabetes', ARRAY['age', 'sex'], 'target');
#[pg_extern]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#[pg_extern]
#[pg_extern]
#[search_path(pgml, public)]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pgml schema is not used in this one, at least not yet. I'm building this parallel to pgml in pgml_rust, so this can be used as an optimization for available algorithms.

let features = features.iter().map(|column| format!("CAST({} AS REAL)", column)).collect::<Vec<String>>();

let query = format!(
"SELECT {}, CAST({} AS REAL) FROM {} ORDER BY RANDOM()", features.clone().join(", "), label, table
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this how you're getting around select * from foo?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, everything coming in is guaranteed to be a REAL so we can get is as value::<f32>()

@levkk levkk changed the title Rust PoC Rust extension - XGBoost Aug 31, 2022
@levkk levkk merged commit 2c16cf2 into master Aug 31, 2022
@levkk levkk deleted the levkk-rust-poc branch August 31, 2022 01:33
SilasMarvin pushed a commit that referenced this pull request Oct 5, 2023
* Rust XGBoost POC

* README

* vendor

* cleanup

* remove submodule

* readme

* Vendor

* readme

* Cleaner

* version

* move files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants