GithubHelp home page GithubHelp logo

eugene-yang / tarexp Goto Github PK

View Code? Open in Web Editor NEW
16.0 16.0 0.0 4.07 MB

An opensource TAR framework for experiments and applications

Home Page: https://eugene.zone/tarexp

License: Apache License 2.0

Python 100.00%
active-learning high-recall-retrieval technology-assisted-review

tarexp's People

Contributors

eugene-yang avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar

tarexp's Issues

Example not working?

This looks like a really great package. I'm trying to get the example running, but having some trouble. I adapted the code from here:
https://www.eugene.zone/tarexp/example/
yielding

import ir_measures
import pandas as pd
from sklearn import datasets
from sklearn.linear_model import LogisticRegression

import tarexp as tar
from tarexp import component as tarc

rcv1     = datasets.fetch_rcv1()
X        = rcv1['data']
y        = rcv1['target'].todense().astype(bool)
y_names  = rcv1['target_names']
rel_info = pd.DataFrame(y, columns=y_names)


# --
# tarexp

ds      = tar.SparseVectorDataset.from_sparse(X)
setting = tarc.combine(
    tarc.SklearnRanker(LogisticRegression, solver='liblinear'),
    tarc.PerfectLabeler(),
    tarc.RelevanceSampler(),
    tarc.FixedRoundStoppingRule(max_round=20)
)()

workflow = tar.OnePhaseTARWorkflow(
    ds.setLabels(rel_info['GPRO'].values),
    setting,
    seed_doc=[1023],
    batch_size=200,
    random_seed=123
)


recording_metrics = [
    ir_measures.RPrec
]
for ledger in workflow:
    print("Round {}: found {} positives in total".format(ledger.n_rounds, ledger.n_pos_annotated))
    print("metric:", workflow.getMetrics(recording_metrics))

(Note I had to change set_label to setLabels, I think.)

When I run that, I get the following error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/bjohnson/opt/anaconda3/lib/python3.9/site-packages/tarexp/workflow.py", line 102, in __next__
    self.step()
  File "/Users/bjohnson/opt/anaconda3/lib/python3.9/site-packages/tarexp/workflow.py", line 250, in step
    self.component.trainRanker(*self.dataset.getTrainingData(self.ledger))
  File "/Users/bjohnson/opt/anaconda3/lib/python3.9/site-packages/tarexp/component/ranker.py", line 49, in trainRanker
    assert np.unique(y).size == 2
AssertionError

... which I think is an error from trying to train a classifier on a (sample of the) dataset that only has a single class. Thoughts on how to proceed? Do you have another example that works out-of-the-box?

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.