-
Notifications
You must be signed in to change notification settings - Fork 156
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
Implement MLJ interface for linear models #35
Comments
In response to an offer of help from @tlienart. Some details: How about you put your implementation of the MLJ "model interface" for I expect you will generally be generally be predicting probabilities and We will go with @fkiraly recommendations, which are not reflected in the adding_new_models.md document just yet; In particular:
Do keep in mind that in the case of nominal target data, the target Note that you will need a separate model for each kind of target data
and limit the allowed options for the "family" and "link" options No need for R style "formula". Your model already gets separate input |
Oops. Closed by accident. :-) |
Ok, I'll start this and probably open a NO-MERGE PR for guidance while I get familiar with the interface and more comfortable with the goal |
Is there an example on how to use linear models using MLJ.jl? Can anyone please show me a simple example of fitting using GLM
x = rand(100)
y = rand(100)
data = DataFrame(x=x, y=y)
lm(@formulat(y~x), data) |
Hello @xiaodaigh , there's an ongoing PR to interface with GLM models which should be merged next week I would think. |
For now you can use OLS (ordinary least squares regressor) or RidgeRegressor. For example: julia> using MLJ
julia> X = (x1=rand(100), x2=rand(100)); # input must be a Tables.jl compatible table
julia> y = rand(100)
julia> @load OLSRegressor # load code from external packages
julia> model = OLSRegressor() # instantiate model
OLSRegressor(fit_intercept = true,) @ 4…70
julia> mach = machine(model, X, y) # bind model to train/evaluation data
Machine{OLSRegressor} @ 1…97
julia> fit!(mach, rows=1:95) # fit on selected rows
[ Info: Training Machine{OLSRegressor} @ 1…97.
Machine{OLSRegressor} @ 1…97
julia> predict(mach, rows=96:100) # get (probabilistic) predictions on some other rows
5-element Array{Distributions.Normal{Float64},1}:
Distributions.Normal{Float64}(μ=0.5573871503802207, σ=0.2789162731813959)
Distributions.Normal{Float64}(μ=0.5910371492542903, σ=0.2789162731813959)
Distributions.Normal{Float64}(μ=0.4871839625605999, σ=0.2789162731813959)
Distributions.Normal{Float64}(μ=0.6031116815100634, σ=0.2789162731813959)
Distributions.Normal{Float64}(μ=0.5461718402936951, σ=0.2789162731813959)
julia> predict_mean(mach, rows=1:5) # get point predictions
5-element Array{Float64,1}:
0.5573871503802207
0.5910371492542903
0.4871839625605999
0.6031116815100634
0.5461718402936951
julia> predict_mean(mach, (x1=rand(4), x2=rand(4))) get point predictions on new input data
4-element Array{Float64,1}:
0.5483367654825207
0.5948051723537034
0.4847273704563324
0.5892571004039957 |
Would someone like to implement the new MLJ interface for linear models for which julia code already exists, including:
GLM.jl for many of these
Lasso.jl
which needs upgrading from 0.6.MultivarateStats
GLM
Lasso.jl
Multivariate stats
Relevant:
The text was updated successfully, but these errors were encountered: