-
Notifications
You must be signed in to change notification settings - Fork 28.1k
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
[SPARK-11965] [ML] [Doc] Update user guide for RFormula feature interactions #10222
Closed
Closed
Changes from 2 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
b08e063
Update user guide for RFormula feature interactions
yanboliang a98f0af
update doc
yanboliang 3b9e886
address comments
yanboliang feac366
copy user guide doc to Scala API doc
yanboliang 346cd21
cut too long line
yanboliang fccdc90
fix typos
yanboliang bc6ed66
fix typos
yanboliang 7def89a
Fix list issue of Scala API doc
yanboliang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2036,7 +2036,25 @@ System.out.println(output.select("userFeatures", "features").first()); | |
|
||
## RFormula | ||
|
||
`RFormula` selects columns specified by an [R model formula](https://stat.ethz.ch/R-manual/R-devel/library/stats/html/formula.html). It produces a vector column of features and a double column of labels. Like when formulas are used in R for linear regression, string input columns will be one-hot encoded, and numeric columns will be cast to doubles. If not already present in the DataFrame, the output label column will be created from the specified response variable in the formula. | ||
`RFormula` selects columns specified by an [R model formula](https://stat.ethz.ch/R-manual/R-devel/library/stats/html/formula.html). | ||
Currently we support a limited subset of the R operators, including '~', '.', ':', '+', and '-'. | ||
The basic operators are: | ||
|
||
* `~` separate target and terms | ||
* `+` concat terms, “+ 0” means removing intercept | ||
* `-` remove a term, “- 1” means removing intercept | ||
* `:` interaction (multiplication for numeric values, or binarized categorical values) | ||
* `.` all columns except target | ||
|
||
Suppose `a` and `b` are double columns, we use the following simple examples to illustrate the effect of `RFormula`: | ||
|
||
* `y ~ a + b` means model `y = w0 + w1 * a + w2 * b` where `w0` is the intercept and `w1, w2` are coefficients | ||
* `y ~ a + b + a:b - 1` means model `y = w1 * a + w2 * b + w3 * a * b` where `w1, w2, w3` are coefficients, which is the same as `y ~ (a + b)^2 + 0` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
`RFormula` produces a vector column of features and a double or string column of label. | ||
Like when formulas are used in R for linear regression, string input columns will be one-hot encoded, and numeric columns will be cast to doubles. | ||
If the label column is of type string, it will be first transformed to double with `StringIndexer`. | ||
If the label is not in the DataFrame, the output label column will be created from the specified response variable in the formula. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
**Examples** | ||
|
||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
=
->~
because the model family is not yet determined