Example usage
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 25/100
- Issue type
- Documentation
- Clarity
- Needs clarification
- Activity status
- Stale
- Tech stack
- julia
- Domain
- documentation
Research direction
Start by reviewing the Julia example in the issue body, including the elastic_net_logistic_regression, train, and generate_predictions functions. Clarify where this example should be documented and what changes are wanted; done means the agreed usage example is added or revised in that location.
Written by the indexing model from the issue text.
Description
`
using DelimitedFiles
using MLJLinearModels
#############################################
'''
wrapper for the logistic regression function with elastic
net penalty provided by MLJLinearModels
'''
#############################################
function elastic_net_logistic_regression(Z::Matrix{Float64},
y::Vector{Float64},
λ::Float64 = 1.0,
α::Float64 = 0.0)
model = LogisticRegression(λ, α, penalty=:en)
return MLJLinearModels.fit(model, Z, y)
end
#############################################
'''
as MLJLinearModels require the labels to be +1, -1 instead
of 0, +1, the following code will read the data and the
labels (0, +1). Then it shall convert the labels to +1, -1
'''
#############################################
M = readdlm("train_data.txt", Float64)
n, m = size(M)
X = Matrix(M[1:n,1:m-1])
y = M[1:end,m:end][:]
z = copy(y) # z shall be the vector of labels
for i = 1:n
if y[i] == 0.0
z[i] = -1.0
end
end
#############################################
'''
compute the parameter vector on the training data
'''
#############################################
function train(X, y)
m, n = size(X)
β_bar = elastic_net_logistic_regression(X, y, 0.0, 0.0)[1:n] # ignore the intercept
return β_bar
end
#############################################
'''
make predictions after training
'''
#############################################
function generate_predictions(X, β)
n, m = size(X)
pred_y = zeros(n)
for i = 1:n
p = sigmoid(X[i,:], β)
if isinf(p)
println("error. sigmoid returned Inf")
end
if p >= 0.5
pred_y[i] = 1.0
else
pred_y[i] = -1.0
end
end
return pred_y
end
`
- Dominant language
- Julia
- Stars
- 86
- Forks
- 16
- PR merge metrics
- No merged PRs in 30d
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from JuliaAI/MLJLinearModels.jl
-
Difficulty 3/5 1-2 days Newbie friendliness 78/100
JuliaAI/MLJLinearModels.jl#187 · 1 reaction ·
-
Difficulty 4/5 3-5 days Newbie friendliness 58/100
JuliaAI/MLJLinearModels.jl#180 ·
-
help wanted
Difficulty 5/5 Over a week Newbie friendliness 25/100
JuliaAI/MLJLinearModels.jl#163 · 4 comments ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 45/100
JuliaAI/MLJLinearModels.jl#160 · 1 comment ·
-
Difficulty 3/5 1-2 days Newbie friendliness 42/100
JuliaAI/MLJLinearModels.jl#159 · 3 comments ·
All issues in JuliaAI/MLJLinearModels.jl
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
Sienna-Platform/PowerSimulations.jl#1737 ·
Maintainers usually reply within 4 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
FluxML/Optimisers.jl#254 ·
-
Minor: floodplain warning percentage, scalar output error message and a never-true identity checkOpenbug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
JuliaAI/MLJTransforms.jl#101 ·
Maintainers usually reply within 1 day
-
@contents blocks fail to render on Julia 1.14Possibly taken @sbfnk claimed this 1 day ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
LuxDL/DocumenterVitepress.jl#410 ·