Code
import FileIO:load
import MLJ:fit!,match,predict,table,fitted_params
using GLMakie, CSV,DataFrames,MLJ,FileIO
=load("./data/snowy-cricket.jpg"); img
import FileIO:load
import MLJ:fit!,match,predict,table,fitted_params
using GLMakie, CSV,DataFrames,MLJ,FileIO
=load("./data/snowy-cricket.jpg"); img
=CSV.File("./data/CricketChirps.csv") |> DataFrame |> dropmissing;
df=MLJ.table(reshape(df[:,1],7,1))
X=Vector(df[:,2])
y
=range(extrema(df[:,1])...,50)
test_X=MLJ.table(reshape(test_X,50,1))
test_X=names(df) cols
2-element Vector{String}:
"Temperature"
"Chirps"
= @load LinearRegressor pkg=MLJLinearModels
LinearRegressor = fit!(machine(LinearRegressor(), X, y))
mach report(mach)
[ Info: For silent loading, specify `verbosity=0`.
┌ Warning: The number and/or types of data arguments do not match what the specified model
│ supports. Suppress this type check by specifying `scitype_check_level=0`.
│
│ Run `@doc MLJLinearModels.LinearRegressor` to learn more about your model's requirements.
│
│ Commonly, but non exclusively, supervised models are constructed using the syntax
│ `machine(model, X, y)` or `machine(model, X, y, w)` while most other models are
│ constructed with `machine(model, X)`. Here `X` are features, `y` a target, and `w`
│ sample or class weights.
│
│ In general, data in `machine(model, data...)` is expected to satisfy
│
│ scitype(data) <: MLJ.fit_data_scitype(model)
│
│ In the present case:
│
│ scitype(data) = Tuple{Table{AbstractVector{Continuous}}, AbstractVector{Count}}
│
│ fit_data_scitype(model) = Tuple{Table{<:AbstractVector{<:Continuous}}, AbstractVector{Continuous}}
└ @ MLJBase ~/.julia/packages/MLJBase/fEiP2/src/machines.jl:230
[ Info: Training machine(LinearRegressor(fit_intercept = true, …), …).
┌ Info: Solver: MLJLinearModels.Analytical
│ iterative: Bool false
└ max_inner: Int64 200
import MLJLinearModels ✔
=predict(mach,test_X).|>(d->round(d,digits=2))
yhatfunction plot_fitting_curve(df,yhat)
=df[:,1]
X=range(extrema(df[:,1])...,50)
test_X=names(df)
cols=Figure()
fig=Axis(fig[1:3,1:3];xlabel="$(cols[1])",ylabel="$(cols[2])",title="cricket-chirp")
ax= Axis(fig[2,4],title="snowy-tree-cricket")
ax2 scatter!(ax, X,y,markersize=16,color=(:red,0.8))
lines!(ax, test_X,yhat,color=:blue)
image!(ax2,img)
hidespines!(ax2)
hidedecorations!(ax2)
figend
plot_fitting_curve(df,yhat)