- Notifications
You must be signed in to change notification settings - Fork328
fix and test preprocessing examples#1520
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes from1 commit
Commits
Show all changes
2 commits Select commitHold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
NextNext commit
fix and test preprocessing examples
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
commitfb773bb307720ccfc7f7f566a448efb0b7c673bf
There are no files selected for viewing
33 changes: 33 additions & 0 deletionspgml-extension/examples/preprocessing.sql
This file contains hidden or 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,33 @@ | ||
-- load the diamonds dataset, that contains text categorical variables | ||
SELECT pgml.load_dataset('jdxcosta/diamonds'); | ||
-- view the data | ||
SELECT * FROM pgml."jdxcosta/diamonds" LIMIT 10; | ||
-- drop the Unamed column, since it's not useful for training (you could create a view instead) | ||
ALTER TABLE pgml."jdxcosta/diamonds" DROP COLUMN "Unnamed: 0"; | ||
-- train a model using preprocessors to scale the numeric variables, and target encode the categoricals | ||
SELECT pgml.train( | ||
project_name => 'Diamond prices', | ||
task => 'regression', | ||
relation_name => 'pgml.jdxcosta/diamonds', | ||
y_column_name => 'price', | ||
algorithm => 'lightgbm', | ||
preprocess => '{ | ||
"carat": {"scale": "standard"}, | ||
"depth": {"scale": "standard"}, | ||
"table": {"scale": "standard"}, | ||
"cut": {"encode": "target", "scale": "standard"}, | ||
"color": {"encode": "target", "scale": "standard"}, | ||
"clarity": {"encode": "target", "scale": "standard"} | ||
}' | ||
); | ||
-- run some predictions, notice we're passing a heterogeneous row (tuple) as input, rather than a homogenous ARRAY[]. | ||
SELECT price, pgml.predict('Diamond prices', (carat, cut, color, clarity, depth, "table", x, y, z)) AS prediction | ||
FROM pgml."jdxcosta/diamonds" | ||
LIMIT 10; | ||
-- This is a difficult dataset for more algorithms, which makes it a good challenge for preprocessing, and additional | ||
-- feature engineering. What's next? |
7 changes: 4 additions & 3 deletionspgml-extension/src/bindings/transformers/mod.rs
This file contains hidden or 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
13 changes: 6 additions & 7 deletionspgml-extension/src/orm/model.rs
This file contains hidden or 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
2 changes: 1 addition & 1 deletionpgml-extension/src/orm/sampling.rs
This file contains hidden or 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 |
---|---|---|
@@ -55,7 +55,7 @@ impl Sampling { | ||
Sampling::stratified => { | ||
format!( | ||
" | ||
SELECT{col_string} | ||
FROM ( | ||
SELECT | ||
*, | ||
23 changes: 16 additions & 7 deletionspgml-extension/src/orm/snapshot.rs
This file contains hidden or 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
1 change: 1 addition & 0 deletionspgml-extension/tests/test.sql
This file contains hidden or 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
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.