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

feat: cascade feature #110

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -172,3 +172,13 @@ cython_debug/
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
.idea/

# Ignore macOS .DS_Store files
.DS_Store
examples/.DS_Store
examples/cascade/.DS_Store

# Ignore specific output folder
examples/cascade/output/

# Ignore libem-specific .DS_Store file
libem/.DS_Store
28 changes: 28 additions & 0 deletions examples/cascade/bench.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import numpy as np
from benchmark.run import args
import json
from libem.prepare.datasets import abt_buy, beer, itunes_amazon
from libem.cascade.function import online
from util import sensitivity_analysis, generate_stats, confidence_cost_plot, confidence_f1_plot, plot_result, save_results, compare_results

def bench():
results_data = online(args(), dataset=abt_buy, num_pairs=None, threshold=0.9)
compare_results(results_data)
cascade_stats, prematch_single, match_single = generate_stats(results_data)
save_results(cascade_stats, prematch_single, match_single)
plot_result(cascade_stats, prematch_single, match_single)


def sensitivity_analysis():
# Perform sensitivity analysis
thresholds = np.arange(0.1, 1.0, 0.1)
f1_scores, costs = sensitivity_analysis(args(), abt_buy, thresholds, num_pairs=100)
F1_SCORE = f1_scores
COSTS = costs
confidence_cost_plot(thresholds, COSTS)
confidence_f1_plot(thresholds, F1_SCORE)



if __name__ == '__main__':
bench()
11 changes: 11 additions & 0 deletions examples/cascade/online.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from libem.prepare.datasets import abt_buy
from benchmark.run import args
import numpy as np
from libem.cascade.function import online

def main():
online(args(), abt_buy, num_pairs=100, threshold=0.9)


if __name__ == '__main__':
main()
Loading