Comments (5)
I'm curious about how to go about this. In the following it seems that +
precedes :
in the order of operations for Expr
objects (which of course is incorrect for the model notation).
julia> f = Formula(:(y ~ x1 + x1:x2))
Formula([y],[:(+(x1,x1),x2)])
julia> f.rhs[1].args
2-element Any Array:
+(x1,x1)
x2
Doesn't this make it harder to use the :
notation without changing Expr
objects?
from dataframes.jl.
Maybe we'll have to change operators. :: looks like it might work. So would & and %. Here's a list of operators ordered by precedence from julia-parser.scm:
(define ops-by-prec
'#((= := += -= *= /= //= .//= .*= ./= |\\=| |.\\=| ^= .^= %= |\|=| &= $= => <<= >>= >>>= ~ |.+=| |.-=|)
(?)
(|\|\||)
(&&)
; note: there are some strange-looking things in here because
; the way the lexer works, every prefix of an operator must also
; be an operator.
(<- -- -->)
(> < >= <= == === != |.>| |.<| |.>=| |.<=| |.==| |.!=| |.=| |.!| |<:| |>:|)
(: |..|)
(+ - |.+| |.-| |\|| $)
(<< >> >>>)
(* / |./| % & |.*| |\\| |.\\|)
(// .//)
(^ |.^|)
(|::|)
(|.|)))
from dataframes.jl.
(Tom, think you hit the close button by mistake! A bit of a GitHub UI quirk...)
I concur. I think we should go with & instead of :. y ~ 1 + x + x&y
. There are also those redundant formula features I never use, like subtracting a predictor: y ~ 1 + x * y - y
and whatnot. I don't really care if we support those or not. I'd prefer we stick with 0+
to remove the interaction term too, and not support - 1
, which I find harder to read.
from dataframes.jl.
There is something to be said for supporting R's syntax: it's been around long enough for people to be familiar with it, and the Python people are starting to use it as well. Would this be possible if we instead parsed strings? As soon as I said that, though, it doesn't seem worth it.
On the other hand, the number of operations we're talking about is pretty minimal, so people will just need to look up Julia's way of doing it. One direction I think would be cool: extend this notation to also include namespaces of features a la Vowpal Wabbit's sparse format. For example, if you have a sparse, bag-of-words representation for a text document, all of these features could be under the words
namespace. If you also have a categorical variable for day of week, all y ~ words * day
would create interaction terms between all the word features and the day feature.
from dataframes.jl.
Yeah, I don't think a single-character change is a big deal here, and using Julia's parser seems a big enough win that I think we should stick with it.
As for namespaces (cool -- I need to actually try VW out sometime!), we'd need a way to define them separate from the formula. Would we want to include something like "colname groups" in the DataFrame? So, you'd somehow define "dims" to be a colname group for "height", "width", and "depth", then you could use "dims" instead of a list of those three column names? That could be useful for other things too. df["dims"] becomes a shorthand for df[["height", "width", "depth"]], and df["predictors"] and df["response"] seem natural things to define, too. So you could then call lm(:(response ~ predictors + covariants), df)
or something. That's fairly awesome. I'm going to spin off an issue!
from dataframes.jl.
Related Issues (20)
- Feature request: Pairs in stack HOT 2
- Grouped DataFrame with array elements fails to combine HOT 4
- error when combining a grouped empty dataframe using `first` HOT 6
- Short circuit && on subset? HOT 1
- Integer strings as colnames/selectors are error prone HOT 2
- Suggestion - Matrix Syntax for hcat (as well as vcat) HOT 4
- Document custom generation of column names in manual HOT 9
- `join` should not introduce `Missing` types to schema HOT 1
- Consider removing Tables.allocatecolumn in vcat
- DataFrame(t::Table) converts PooledVector columns HOT 2
- Sampling GroupedDataFrames (rand) HOT 5
- Julia 1.12.0-DEV: testing DataFrames throws a 'method dispatch ambiguities' error HOT 2
- Add options to `join` missing error? HOT 1
- Column types seem to change after inner-join between two DataFrames HOT 1
- using propertynames on GroupedDataFrame HOT 6
- Very slow to convert DBInterface (DuckDB) result HOT 1
- Add arbitrary matching function for joins HOT 3
- Add Tidier.jl to docs/src/man/querying_frameworks.md HOT 1
- join size warnings
- Type piracy of `reduce(vcat)` HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dataframes.jl.