Git Product home page Git Product logo

proxy-a-distance's Introduction

Proxy A-Distance

This is an implementation of an algorithm discussed in Ganin et. al (2015), Glorot et. al (2011), and Ben-David et. al (2007). It has been adapted for use with machine translation datasets, and released to the public under the MIT license.

This algorithm computes the Proxy A-Distance (PAD) between two domain distributions. PAD is a measure of similarity between datasets from different domains (e.g. newspapers and talk shows). Intuitively, similar domains => bigger error => smaller PAD. Dissimilar domains => smaller error => bigger PAD. The MAE error metric for binary classification between domains will bound PAD in the range [0, 2].

The algorithm is as follows:

  1. Mix the two datasets. Apply label that indicate each example's origin.
  2. Train a classifier on these merged data.
  3. Measure the classifier's error e on a held-out test set.
  4. Set PAD = 2 (1 โˆ’ 2e)

We use a linear bag-of-words SVM for the underlying classifier.

Requirements

  • numpy: pip install numpy
  • sklearn: pip install sklearn

Usage

python main.py [corpusfile 1] [corpusfile 2] [vocab file]
  • corpusfile 1 is a text file with one sentence per line.
  • corpusfile 2 is another text file with one sentence per line.
  • vocab is a text file with one token per line. These tokens represent a shared vocabulary for the above corpusfiles.

Example

python main.py test_data/europarl.en test_data/europarl.fr test_data/opensubtitles.en test_data/opensubtitles.fr test_data/vocab

proxy-a-distance's People

Contributors

rpryzant avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

proxy-a-distance's Issues

Question

Hi,
thank you for this piece of code.

I do have a question: the value of the metric is always negative, isn't it?
If PAD=-3 the distributions are more similar than the situation where PAD=-1. Am I correct?

Thank you in advance,
Ylenia

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.