Skip to content

Commit

Permalink
bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
cbbcbail committed Jul 19, 2024
1 parent 8b0d47d commit 3d35903
Show file tree
Hide file tree
Showing 16 changed files with 108 additions and 63 deletions.
Binary file modified data/Fig1-designProcess/blend1Subset.pickle
Binary file not shown.
Binary file modified data/Fig1-designProcess/blend2Subset.pickle
Binary file not shown.
Binary file modified data/Fig1-designProcess/blend3Subset.pickle
Binary file not shown.
Binary file modified data/Fig1-designProcess/distinct1Subset.pickle
Binary file not shown.
Binary file modified data/Fig1-designProcess/distinct2Subset.pickle
Binary file not shown.
Binary file modified data/Fig1-designProcess/distinct3Subset.pickle
Binary file not shown.
Binary file modified data/Fig1-designProcess/distinctSubset.pickle
Binary file not shown.
Binary file modified data/Fig1-designProcess/fullData.pickle
Binary file not shown.
Binary file modified data/Fig1-designProcess/hullSubset.pickle
Binary file not shown.
Binary file modified data/Fig1-designProcess/outliersSubset.pickle
Binary file not shown.
42 changes: 42 additions & 0 deletions data/solverLog.csv
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,45 @@ Uni-criterion: clusterCenters,greedySwap,1000,2,10,0.13956262497231364,0.3799413
"Uni-criterion: preserveMetric, hull",greedyMinSubset,500,2,12,0.2948356249835342,0.0
"Uni-criterion: sum, outlierness",greedySwap,500,2,40,0.07649645791389048,-74.23043000890738
"Uni-criterion: distinctness, distances",greedySwap,500,2,60,0.5947001250460744,-92.08564918686247
"Uni-criterion: preserveMetric, hull",greedyMinSubset,500,2,9,0.20904829213395715,0.0
"Uni-criterion: sum, outlierness",greedySwap,500,2,40,0.08821466704830527,-79.95507869120974
"Uni-criterion: distinctness, distances",greedySwap,500,2,60,0.6470217080786824,-94.69010039466121
"Uni-criterion: preserveMetric, hull",greedyMinSubset,500,2,10,0.221585167106241,0.0
"Uni-criterion: sum, outlierness",greedySwap,500,2,40,0.08099545910954475,-76.8424909434427
"Uni-criterion: distinctness, distances",greedySwap,500,2,60,0.6626855423673987,-87.75324874515424
"Uni-criterion: preserveMetric, hull",greedyMinSubset,200,2,9,0.07839837530627847,0.0
"Uni-criterion: sum, outlierness",greedySwap,200,2,40,0.03452433319762349,-76.73330214179785
"Uni-criterion: distinctness, distances",greedySwap,200,2,60,0.15389200020581484,-72.30676106510778
"Multi-criterion: 100*(earthMoversDistance) + 1*(distinctness, distances)",greedySwap,200,2,80,8.683466792106628,-37.832634391613226
"Multi-criterion: 50*(earthMoversDistance) + 1*(distinctness, distances)",greedySwap,200,2,80,8.944492833223194,-55.336713455218515
"Multi-criterion: 1*(earthMoversDistance) + 1*(distinctness, distances)",greedySwap,200,2,80,10.16267108405009,-77.45551739898436
"Uni-criterion: preserveMetric, hull",greedyMinSubset,200,2,9,0.07779270829632878,0.0
"Uni-criterion: sum, outlierness",greedySwap,200,2,40,0.029774457681924105,-70.13661593006383
"Uni-criterion: distinctness, distances",greedySwap,200,2,60,0.1661411253735423,-76.52681602089089
"Multi-criterion: 100*(earthMoversDistance) + 1*(distinctness, distances)",greedySwap,200,2,80,8.791529291309416,-35.549221713913795
"Multi-criterion: 50*(earthMoversDistance) + 1*(distinctness, distances)",greedySwap,200,2,80,9.541060833260417,-56.63750965002805
"Multi-criterion: 1*(earthMoversDistance) + 1*(distinctness, distances)",greedySwap,200,2,80,10.46921870810911,-83.31100611009497
"Uni-criterion: distinctness, distances",greedyMixed,200,2,12,0.0214225840754807,-37.26355923400367
"Uni-criterion: distinctness, distances",greedyMixed,200,2,36,0.0722177498973906,-57.328890897044175
"Uni-criterion: distinctness, distances",greedyMixed,200,2,28,0.05338112497702241,-58.87100686028796
"Uni-criterion: distinctness, distances",greedyMixed,200,2,17,0.03293449990451336,-44.09659907116473
"Uni-criterion: distinctness, distances",greedyMixed,200,2,55,0.11244387505576015,-61.49184399076313
"Uni-criterion: distinctness, distances",greedyMixed,200,2,101,0.24100016662850976,-86.10404158691499
"Uni-criterion: distinctness, distances",greedyMixed,200,2,15,0.031042208895087242,-37.86319298068655
"Uni-criterion: distinctness, distances",greedyMixed,200,2,50,0.10623954189941287,-61.01378931117458
"Uni-criterion: distinctness, distances",greedyMixed,200,2,103,0.24973824992775917,-83.00438182523874
"Uni-criterion: distinctness, distances",greedyMixed,200,2,20,0.0373823749832809,-45.76776906728566
"Uni-criterion: distinctness, distances",greedyMixed,200,2,11,0.017222166061401367,-44.268067171984875
"Uni-criterion: distinctness, distances",greedyMixed,200,2,92,0.2180039999075234,-82.50779303999899
"Uni-criterion: distinctness, distances",greedyMixed,200,2,23,0.04364325013011694,-44.964197525236315
"Uni-criterion: distinctness, distances",greedyMixed,200,2,52,0.10621762461960316,-61.43036396431012
"Uni-criterion: distinctness, distances",greedyMixed,200,2,85,0.2009903327561915,-79.26661008322394
"Uni-criterion: preserveMetric, hull",greedyMinSubset,200,2,9,0.06682970793917775,0.0
"Uni-criterion: sum, outlierness",greedySwap,200,2,40,0.03168637491762638,-87.25866709672482
"Uni-criterion: distinctness, distances",greedySwap,200,2,60,0.17151008266955614,-83.69038566035452
"Multi-criterion: 100*(earthMoversDistance) + 1*(distinctness, distances)",greedySwap,200,2,80,9.204857917036861,-27.184808100622732
"Multi-criterion: 10*(earthMoversDistance) + 1*(distinctness, distances)",greedySwap,200,2,80,10.099580999929458,-78.56242065843928
"Multi-criterion: 1*(earthMoversDistance) + 1*(distinctness, distances)",greedySwap,200,2,80,10.901172333396971,-87.1982622784361
"Uni-criterion: distinctness, distances",greedyMixed,200,2,21,0.04174462519586086,-47.546951611341385
"Uni-criterion: distinctness, distances",greedyMixed,200,2,13,0.021749832667410374,-51.19458441796628
"Uni-criterion: distinctness, distances",greedyMixed,200,2,108,0.24733683420345187,-88.67659171843289
Binary file modified figures/Fig1-designProcess/blend.pdf
Binary file not shown.
Binary file modified figures/Fig1-designProcess/express.pdf
Binary file not shown.
Binary file modified figures/Fig1-designProcess/tune.pdf
Binary file not shown.
5 changes: 2 additions & 3 deletions flexibleSubsetSelection/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def errorMarkers(ax, x, vals1, color1, marker1, vals2=None, color2=None,

# --- Plots --------------------------------------------------------------------

def initialize(color, font="Times New Roman", family="sans-serif", size=42):
def initialize(color, font="Times New Roman", size=42):
"""
Initialize matplotlib settings global parameters for text and background
Expand All @@ -171,8 +171,7 @@ def initialize(color, font="Times New Roman", family="sans-serif", size=42):
if not isinstance(color, Color):
raise ValueError("color must be an instance of Color object")

plt.rcParams["font.sans-serif"] = font
plt.rcParams["font.family"] = family
plt.rcParams["font.family"] = font
plt.rcParams["pdf.fonttype"] = size
plt.rcParams["ps.fonttype"] = size
plt.rcParams["axes.facecolor"] = color.palette["grey"]
Expand Down
124 changes: 64 additions & 60 deletions jupyter/Fig1-designProcess.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"# Initialize notebook settings\n",
"sns.set_theme() # set seaborn theme\n",
"matplotlib_inline.backend_inline.set_matplotlib_formats('svg') # vector plots\n",
"%matplotlib inline \n",
"# %matplotlib inline \n",
"%load_ext autoreload\n",
"%autoreload 2"
]
Expand All @@ -58,7 +58,7 @@
"seed = 123456789 # random generation seed for replicability\n",
"\n",
"# Create a random blobs dataset to use as our example dataset\n",
"dataset = fss.Dataset(randTypes=\"blobs\", size=(500, 2), seed=seed)\n",
"dataset = fss.Dataset(randTypes=\"blobs\", size=(200, 2), seed=seed)\n",
"dataset.save(f\"{directory}/fullData\")"
]
},
Expand Down Expand Up @@ -104,8 +104,12 @@
"\n",
"Applying this objective allows us to select a subset of 40 points with the highest local outlier effect.\n",
"\n",
"$$\\max_{S \\in \\mathbb{S}} \\space \\text{LOF}(S)$$\n",
"$$\\text{s.t.} \\space \\|S\\| = 40$$"
"$$\n",
"\\max_{S \\in \\mathbb{S}} \\ \\text{LOF}(S)\n",
"$$\n",
"$$\n",
"\\text{s.t.} \\ \\|S\\| = 40\n",
"$$"
]
},
{
Expand Down Expand Up @@ -173,23 +177,23 @@
"source": [
"# Initialize color and plot settings\n",
"color = fss.plot.Color()\n",
"fss.plot.initialize(color)\n",
"fss.plot.initialize(color, font=\"DejaVu Sans\")\n",
"\n",
"# Plot the three different resulting subsets as scatterplots\n",
"titleSize = 24\n",
"subtitleSize = 18\n",
"titles = [\"Hull\", \"Outliers\", \"Distinctness\"]\n",
"subsets = [subsetHull, subsetOutliers, subsetDistinct]\n",
"\n",
"fig, axs = plt.subplots(nrows=1, ncols=3, figsize=(6.25, 3))\n",
"fig, axs = plt.subplots(nrows=1, ncols=3, figsize=(8, 3.5))\n",
"fig.text(0.49, 1, '1. Express', ha='center', va='center', fontsize=titleSize)\n",
"\n",
"for i, ax in enumerate(fig.axes):\n",
" ax.grid(visible=False)\n",
" ax.set_xticks([])\n",
" ax.set_yticks([])\n",
" ax.set_title(titles[i], fontsize=subtitleSize)\n",
" ax.set_aspect(\"equal\")\n",
" # ax.set_aspect(\"equal\")\n",
"\n",
" fss.plot.scatter(ax = ax, \n",
" color = color, \n",
Expand Down Expand Up @@ -218,23 +222,23 @@
"metadata": {},
"outputs": [],
"source": [
"# subsetSize = 80 # The size of subsets being selected with blended objectives\n",
"subsetSize = 80 # The size of subsets being selected with blended objectives\n",
"\n",
"# # Use distribution and distinctness objectives\n",
"# objectives = [fss.objective.earthMoversDistance, fss.objective.distinctness]\n",
"# Use distribution and distinctness objectives\n",
"objectives = [fss.objective.earthMoversDistance, fss.objective.distinctness]\n",
"\n",
"# # Parameters of the distribution and distinctness objectives\n",
"# parameters = [{\"dataset\": dataset.dataArray}, \n",
"# {\"solveArray\": \"distances\", \"selectBy\": \"matrix\"}]\n",
"# Parameters of the distribution and distinctness objectives\n",
"parameters = [{\"dataset\": dataset.dataArray}, \n",
" {\"solveArray\": \"distances\", \"selectBy\": \"matrix\"}]\n",
"\n",
"# # Create the multicriterion loss function from the objectives and weight them\n",
"# solver.lossFunction = fss.MultiCriterion(objectives = objectives, \n",
"# parameters = parameters, \n",
"# weights=[100, 1])\n",
"# Create the multicriterion loss function from the objectives and weight them\n",
"solver.lossFunction = fss.MultiCriterion(objectives = objectives, \n",
" parameters = parameters, \n",
" weights=[100, 1])\n",
"\n",
"# # Solve for the blended distribution and distinctness subset\n",
"# subsetBlend1 = solver.solve(dataset, subsetSize=subsetSize, verbose=verbose)\n",
"# subsetBlend1.save(f\"{directory}/blend1Subset\")"
"# Solve for the blended distribution and distinctness subset\n",
"subsetBlend1 = solver.solve(dataset, subsetSize=subsetSize, verbose=verbose)\n",
"subsetBlend1.save(f\"{directory}/blend1Subset\")"
]
},
{
Expand All @@ -243,14 +247,14 @@
"metadata": {},
"outputs": [],
"source": [
"# # Update the weights to provide less emphasis on the distribution objective\n",
"# solver.lossFunction = fss.MultiCriterion(objectives = objectives, \n",
"# parameters = parameters, \n",
"# weights=[50, 1])\n",
"\n",
"# # Solve for the blended distribution and distinctness subset\n",
"# subsetBlend2 = solver.solve(dataset, subsetSize=subsetSize, verbose=verbose)\n",
"# subsetBlend2.save(f\"{directory}/blend2Subset\")"
"# Update the weights to provide less emphasis on the distribution objective\n",
"solver.lossFunction = fss.MultiCriterion(objectives = objectives, \n",
" parameters = parameters, \n",
" weights=[10, 1])\n",
"\n",
"# Solve for the blended distribution and distinctness subset\n",
"subsetBlend2 = solver.solve(dataset, subsetSize=subsetSize, verbose=verbose)\n",
"subsetBlend2.save(f\"{directory}/blend2Subset\")"
]
},
{
Expand All @@ -259,14 +263,14 @@
"metadata": {},
"outputs": [],
"source": [
"# # Update the weights to an even weight of the two objectives\n",
"# solver.lossFunction = fss.MultiCriterion(objectives = objectives, \n",
"# parameters = parameters, \n",
"# weights=[1, 1])\n",
"\n",
"# # Solve for the blended distribution and distinctness subset\n",
"# subsetBlend3 = solver.solve(dataset, subsetSize=subsetSize, verbose=verbose)\n",
"# subsetBlend3.save(f\"{directory}/blend3Subset\")"
"# Update the weights to an even weight of the two objectives\n",
"solver.lossFunction = fss.MultiCriterion(objectives = objectives, \n",
" parameters = parameters, \n",
" weights=[1, 1])\n",
"\n",
"# Solve for the blended distribution and distinctness subset\n",
"subsetBlend3 = solver.solve(dataset, subsetSize=subsetSize, verbose=verbose)\n",
"subsetBlend3.save(f\"{directory}/blend3Subset\")"
]
},
{
Expand All @@ -284,28 +288,28 @@
"metadata": {},
"outputs": [],
"source": [
"# # Plot the three subsets with different blends of the two objectives\n",
"# titles = [\"More Distribution,\\nLess Distinct\", \"\", \n",
"# \"Less Distribution,\\nMore Distinct\"]\n",
"# subsets = [subsetBlend1, subsetBlend2, subsetBlend3]\n",
"\n",
"# fig, axs = plt.subplots(nrows=1, ncols=3, figsize=(6.25, 3))\n",
"# fig.text(0.49, 1, '2. Blend', ha='center', va='center', fontsize=titleSize)\n",
"\n",
"# for i, ax in enumerate(fig.axes):\n",
"# ax.grid(visible=False)\n",
"# ax.set_xticks([])\n",
"# ax.set_yticks([])\n",
"# ax.set_title(titles[i], fontsize=subtitleSize)\n",
"# ax.set_aspect(\"equal\")\n",
"\n",
"# fss.plot.scatter(ax = ax, \n",
"# color = color, \n",
"# dataset = dataset, \n",
"# subset = subsets[i], \n",
"# alpha = 0.6)\n",
"\n",
"# plt.savefig(f\"../figures/{directory}/blend.pdf\", bbox_inches=\"tight\")"
"# Plot the three subsets with different blends of the two objectives\n",
"titles = [\"More Distribution,\\nLess Distinct\", \"\", \n",
" \"Less Distribution,\\nMore Distinct\"]\n",
"subsets = [subsetBlend1, subsetBlend2, subsetBlend3]\n",
"\n",
"fig, axs = plt.subplots(nrows=1, ncols=3, figsize=(8, 3.5))\n",
"fig.text(0.49, 1, '2. Blend', ha='center', va='center', fontsize=titleSize)\n",
"\n",
"for i, ax in enumerate(fig.axes):\n",
" ax.grid(visible=False)\n",
" ax.set_xticks([])\n",
" ax.set_yticks([])\n",
" ax.set_title(titles[i], fontsize=subtitleSize)\n",
" ax.set_aspect(\"equal\")\n",
"\n",
" fss.plot.scatter(ax = ax, \n",
" color = color, \n",
" dataset = dataset, \n",
" subset = subsets[i], \n",
" alpha = 0.6)\n",
"\n",
"plt.savefig(f\"../figures/{directory}/blend.pdf\", bbox_inches=\"tight\")"
]
},
{
Expand Down Expand Up @@ -345,7 +349,7 @@
"subsetDistinct2.save(f\"{directory}/distinct2Subset\")\n",
"\n",
"subsetDistinct3 = solver.solve(dataset = dataset, \n",
" weight = 0.1, \n",
" weight = 0.05, \n",
" initialSize = 3, \n",
" verbose = verbose)\n",
"subsetDistinct3.save(f\"{directory}/distinct3Subset\")"
Expand All @@ -370,7 +374,7 @@
"titles = [\"Fewer Points,\\nMore Distinct\", \"\", \"More Points,\\nLess Distinct\"]\n",
"subsets = [subsetDistinct1, subsetDistinct2, subsetDistinct3]\n",
"\n",
"fig, axs = plt.subplots(nrows=1, ncols=3, figsize=(6.25, 3))\n",
"fig, axs = plt.subplots(nrows=1, ncols=3, figsize=(8, 3.5))\n",
"fig.text(0.49, 1, '3. Tune', ha='center', va='center', fontsize=titleSize)\n",
"\n",
"for i, ax in enumerate(fig.axes):\n",
Expand Down

0 comments on commit 3d35903

Please sign in to comment.