Comments (5)
Here is more relevant paper that deals with any underlying regressor https://proceedings.mlr.press/v91/vovk18a.html
And toy Python package that implements it https://pypi.org/project/pysloth/
from conformalprediction.jl.
I had a look at the slides:
using MLJ, EvoTrees, ConformalPrediction, Plots, Random, MLJLinearModels, Tables;
########################################
n= 100_000; p=70; σ=100.10;
X = [ones(n) randn(MersenneTwister(49), n, p-1)]
θ = randn(MersenneTwister(49), p)
CEF = X*θ
Noise = σ*randn(MersenneTwister(49), n)
y = CEF + Noise
train, calibration, test = partition(eachindex(y), 0.4, 0.4)
########################################
LinearRegressor = @load LinearRegressor pkg=MLJLinearModels
model = LinearRegressor(fit_intercept = false)
mach = machine(model, Tables.table(X), y)
fit!(mach, rows=train)
pr_y = predict(mach, rows=test)
########################################
conf_mach = conformal_machine(mach)
calibrate!(conf_mach, selectrows(X, calibration), y[calibration])
pr = predict(conf_mach, X[test,:]; coverage=0.95)
pr_lower = [pr[j][1][2][] for j in 1:length(test)]
pr_upper = [pr[j][2][2][] for j in 1:length(test)]
mean(pr_lower .<= y[test] .<= pr_upper) # 0.94975
###########################################
# recover the predicted distribution
xt = [X[test[1],:] ;;]'
c_grid = .01:.001:0.99
LB = []; UB = [];
for j in eachindex(c_grid)
pr = predict(conf_mach, xt; coverage=c_grid[j] )
push!(LB, pr[1][1][2][])
push!(UB, pr[1][2][2][])
end
plot(legend=:topleft)
plot!(LB, (1.0 .- c_grid)/2.0, lab="LB, quantile")
plot!(UB, (c_grid[end]/2.0) .+ (c_grid)/2.0, lab="UB, quantile")
plot!([pr_y[1]], seriestype = :vline, lab="y prediction, median", color="red")
Gives the ECDF (centered at the median)
Shouldn't the "density" be the derivative of the ECDF?
from conformalprediction.jl.
Question: how do I plot the predicted distribution of y
at a given x
?
#AZ: recover the predicted distribution?
xt = [X[test[1],:] ;;]'
c_grid = .01:.01:0.99
LB = []; UB = [];
for j in eachindex(c_grid)
pr = predict(conf_mach, xt; coverage=c_grid[j] )
push!(LB, pr[1][1][2][])
push!(UB, pr[1][2][2][])
end
plot(legend=:topleft)
plot!(LB, 1.0 .- c_grid, lab="LB at %-ile")
plot!(UB, 1.0 .- c_grid, lab="UB at %-ile")
plot!([pr_y[1]], seriestype = :vline, lab="y prediction point estimate", color="red")
To be clear, I'm fairly confident that what I plotted above is not the predicted density of y
given x
.
My question is how to recover it...
from conformalprediction.jl.
Hi @azev77! Great to see you've already played around with the package. I understand what you have in mind and that would certainly be nice feature to add. It can apparently be done as demonstrated in this paper by @valeman and co-authors, but the package does not support this yet. For now all you can really produce is prediction intervals. Adding support for this in the future would be nice, but it looks too involved for me to do that any time soon. Here's a corresponding tutorial if you want to have a go at it yourself. Or perhaps I'm overthinking this and others know of a straight-forward way to do what you have in mind.
What you have plotted is the user-chosen error rate
from conformalprediction.jl.
Thanks @azev77 - just linking the related thread on discourse here for info.
from conformalprediction.jl.
Related Issues (20)
- Conformal Training examples HOT 2
- Support for thresholding predictive distributions as explained in Section 2.4 of the tutorial HOT 2
- Conformal Bayes through 'add-one-in' importance sampling
- .vscode folder HOT 1
- Add Aqua.jl
- Add parallelizer field to all models
- Add support for SAPS
- COnformal Bayes classification HOT 1
- Class-Conditional CP with many classes
- Treat data as artifacts
- JuliaCon pres
- Add format check to CI
- Add support for RAPS
- [Refactor] Separate module for TS
- Revisit sample correction
- Move plot methods to TaijaPlotting.jl
- Add TaijaPlotting to docs env HOT 1
- Add support for 1.6 HOT 1
- readme Quick Tour notebook: "Could not fetch rendered notebook or notebook source." HOT 5
- Conformal Training
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 conformalprediction.jl.