瀏覽代碼

Add max inertia metric and change obj fn to reflect actual score values

Kirk Trombley 3 年之前
父節點
當前提交
18f91bccf1
共有 2 個文件被更改,包括 14 次插入10 次删除
  1. 6 5
      nearest.html
  2. 8 5
      nearest.js

+ 6 - 5
nearest.html

@@ -35,17 +35,18 @@
                             <option>Mean Angle</option>
                             <option>Mean Distance</option>
                             <option>Hue Angle</option>
+                            <option>Max Inertia</option>
                             <option>Custom Metric</option>
                         </select>
                     </div>
                     <div class="panel dropdown">
-                        <label for="image-mean">Mean Argument:</label>
+                        <label for="image-mean">Cluster:</label>
                         <select type="checkbox" onchange="onMeanArgumentChanged()" id="image-summary">
                             <option selected>All Pixels</option>
-                            <option>Biggest Cluster (M)</option>
-                            <option>Smallest Cluster (m)</option>
-                            <option>Best Cluster (α)</option>
-                            <option>Worst Cluster (ω)</option>
+                            <option>Biggest (M)</option>
+                            <option>Smallest (m)</option>
+                            <option>Best (α)</option>
+                            <option>Worst (ω)</option>
                         </select>
                     </div>
 

+ 8 - 5
nearest.js

@@ -158,6 +158,8 @@ const metrics = [
   },
   // hue angle
   (stats, q) => angleDiff(selectedSummary(stats, q)[0].hue, q.hue),
+  // max inertia
+  (stats) => -stats.inertia,
   // custom
   (stats, q) => (state.includeX ? stats.inertia : 0) - state.closeCoeff * vectorDot(
     selectedSummary(stats, q)[0][state.normQY ? "unit" : "vector"],
@@ -215,9 +217,10 @@ const mathDefinitions = {
 
 const metricText = [
   muArg => String.raw`${mathArgBest("min", "P")}\left[I\left(P\right) - 2\vec{q}\cdot \vec{\mu}\left(${muArg}\right)\right]`,
-  muArg => String.raw`${mathArgBest("max", "P")}\left[\cos\left(\angle \left(\vec{q}, \vec{\mu}\left(${muArg}\right)\right)\right)\right]`,
+  muArg => String.raw`${mathArgBest("min", "P")}\left[-\cos\left(\angle \left(\vec{q}, \vec{\mu}\left(${muArg}\right)\right)\right)\right]`,
   muArg => String.raw`${mathArgBest("min", "P")}\left[${state.meanArgument > 0 && state.includeScaleInDist ? String.raw`\frac{\left|P\right|}{\left|${muArg}\right|}` : ""} \left|\left| \vec{q} - \vec{\mu}\left(${muArg}\right) \right|\right|^2\right]`,
   muArg => String.raw`${mathArgBest("min", "P")}\left[\angle \left(\vec{q}_{\perp}, \vec{\mu}\left(${muArg}\right)_{\perp} \right)\right]`,
+  muArg => String.raw`${mathArgBest("min", "P")}\left[-I\left(P\right)\right]`,
 ].map(s => muArg => TeXZilla.toMathML(s(muArg)));
 
 const muArgs = [
@@ -240,12 +243,12 @@ const updateObjective = () => {
     } else {
       const qyMod = normQY ? renderNorm : c => c;
       tex = TeXZilla.toMathML(String.raw`
-        ${mathArgBest(includeX ? "min" : "max", "P")}
+        ${mathArgBest("min", "P")}
         \left[
           ${includeX ? String.raw`I\left(P\right)` : ""}
           ${closeCoeff === 0 ? "" : String.raw`
-              ${includeX ? "-" : ""}
-              ${(includeX && closeCoeff !== 1) ? closeCoeff : ""}
+              -
+              ${closeCoeff}
               ${qyMod("\\vec{q}")}
               \cdot
               ${qyMod(String.raw`\vec{\mu}\left(${muArg}\right)`)}
@@ -521,7 +524,7 @@ const onMetricChanged = skipScore => {
   state.metric = metric;
   checkClusterMeanWarning();
   checkScaleByClusterToggle();
-  if (state.metric === 4) { // Custom
+  if (state.metric === 5) { // Custom
     showCustomControls();
     onCustomControlsChanged(skipScore); // triggers rescore
   } else {