Skip to content
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

Set up Travis #2

Merged
merged 4 commits into from
Sep 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
language: julia

coveralls: true

os:
- linux

julia:
- 1.1
- 1.2
- nightly

matrix:
allow_failures:
- julia: nightly
fast_finish: true

after_success:
- julia -e 'Pkg.add("Coverage"); using Coverage; Codecov.submit(process_folder())'

notifications:
email: false
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Parameters = "d96e819e-fc66-5662-9728-84c9c7592b0a"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"

[extra]
[extras]
Distances = "b4f34e82-e78d-54a5-968a-f98e89d6e8f7"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

Expand Down
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,16 @@

A Julia package for density ratio estimation

Supported methods
- Infinite moment matching based on maximum mean discrepancy (MMD)
[![Build Status](https://travis-ci.com/xukai92/DensityRatioEstimation.jl.svg?branch=master)](https://travis-ci.com/xukai92/DensityRatioEstimation.jl) [![Coverage Status](https://coveralls.io/repos/github/xukai92/DensityRatioEstimation.jl/badge.svg)](https://coveralls.io/github/xukai92/DensityRatioEstimation.jl)

To get started, see the [introduction](https://htmlpreview.github.io/?https://github.com/xukai92/DensityRatioEstimation.jl/blob/master/docs/intro.html).

## Supported methods

Infinite moment matching based on maximum mean discrepancy (MMD)
- Numerical solution with optional positivity and normalisation constraints
- Analytical solution with no constraint

## References

Sugiyama M, Suzuki T, Kanamori T. Density ratio estimation in machine learning. Cambridge University Press, 2012.
4 changes: 2 additions & 2 deletions src/moment_matching.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function estimate_ratio(mmd::AbstractMMD, x_de, x_nu; σs=nothing)
end

@with_kw struct MMDNumerical <: AbstractMMD
positive::Bool=true
positivity::Bool=true
normalisation::Bool=true
end

Expand All @@ -57,7 +57,7 @@ function _estimate_ratio(mmd::MMDNumerical, Kdede, Kdenu)
model = Model(with_optimizer(IpoptOptimizer; print_level=0))
@variable(model, r[1:n_de])
@objective(model, Min, 1 / n_de ^ 2 * sum(r[i] * Kdede[i,j] * r[j] for i = 1:n_de, j=1:n_de) - 2 / (n_de * n_nu) * sum(r[i] * Kdenu[i,j] for i = 1:n_de, j=1:n_nu))
if mmd.positive
if mmd.positivity
@constraint(model, r .>= 0)
end
if mmd.normalisation
Expand Down