Эх сурвалжийг харах

Further beta metric improvements

Kirk Trombley 3 жил өмнө
parent
commit
5daccfcd97
3 өөрчлөгдсөн 21 нэмэгдсэн , 29 устгасан
  1. 11 16
      web/convert.js
  2. 2 1
      web/listeners.js
  3. 8 12
      web/metrics.js

+ 11 - 16
web/convert.js

@@ -19,22 +19,17 @@ const buildVectorData = (vector, toHue, toLightness, toChroma, toHex) => {
 };
 
 const calcImportance = (chroma, lightness, proportion) => (
-  // scale the final result by 100 just for clarity
-  100
-  // ramp the proportion value such that 
-  //    proportion > 85% => basically guaranteed to be most important, gets bonus
-  //    proportion < 15% => no way to be most important, goes negative
-  //    otherwise => depend approximately on sqrt(proportion)
-  * ( Math.tanh(100 * (proportion - 0.85))
-    + Math.tanh(100 * (proportion - 0.15))
-    + Math.sqrt(proportion) )
-  // consider the chroma based on the sqrt of its part of chroma + lightness
-  * Math.sqrt(chroma / (chroma + lightness)) 
-  // ramp the lightness value such that
-  //    lightness >> 50% => scale by 3
-  //    lightness << 50% => scale by 1
-  //    otherwise => slightly steep ramp
-  * (2 + Math.tanh(10 * (lightness - 0.5)))
+  // proportion component - linear, with penalties
+  proportion
+  + Math.tanh(100 * (proportion - 0.05)) // penalty for being <5%
+  + Math.tanh(100 * (proportion - 0.15)) // penalty for being <15%
+  + Math.tanh(100 * (proportion - 0.75)) // penalty for being <75%
+  // chroma component - scaled, with penalty
+  + (chroma / (chroma + lightness)) // consider chroma as portion of chroma + lightness
+  + (Math.tanh(10 * (chroma - 0.25))) // penalty for being <25%
+  // lightness component - linear, with penality
+  + lightness
+  + (Math.tanh(10 * (lightness - 0.5))) // penalty for being <50%
 );
 
 const buildClusterData = (size, inertia, mu1, mu2, mu3, nu1, nu2, nu3, totalSize, toHue, toLightness, toChroma, toHex) => {

+ 2 - 1
web/listeners.js

@@ -6,7 +6,8 @@ const { rerenderSearch, onSearch, onRandomName } = (() => {
   if (DEBUG_MODE) {
     // set of some pokemon with interesting edge cases
     starting = [
-      "latias", "wailmer", "luxray", "seaking", "blastoise", "oranguru", "blacephalon", "crustle", "rolycoly"
+      "latias", "wailmer", "luxray", "seaking", "blastoise", "oranguru", "victreebel",
+      "blacephalon", "crustle", "rolycoly", "lucario", "abomasnow", "typhlosion",
     ];
     starting.forEach(x => clusterToggles[`${x}-search-pkmn-expand-toggle`] = true)
     results = pokemonData.filter(p => starting.includes(p.name));

+ 8 - 12
web/metrics.js

@@ -116,18 +116,14 @@ const metrics = {
     displayName: String.raw`\beta`,
     displayBody: p => String.raw`
       \begin{aligned}
-          &100 \\
-        * &\left[
-            \begin{aligned}
-              &\sqrt{\frac{\left|${p}\right|}{\left|P\right|}} \\
-            + &\tanh{\left(100\left(\frac{\left|${p}\right|}{\left|P\right|} - 0.85\right)\right)} \\
-            + &\tanh{\left(100\left(\frac{\left|${p}\right|}{\left|P\right|} - 0.15\right)\right)}
-            \end{aligned}
-          \right] \\
-        * &\sqrt{\frac{C\left(${p}\right)}{C\left(${p}\right) + L\left(${p}\right)}} \\
-        * &\left[
-            2 + \tanh{\left(10\left(L\left(${p}\right) - 0.5\right)\right)}
-          \right]
+        &\frac{\left|${p}\right|}{\left|P\right|} \\
+      + &L\left(${p}\right) \\
+      + &\frac{C\left(${p}\right)}{C\left(${p}\right) + L\left(${p}\right)} \\
+      + &\tanh{\left(100\left(\frac{\left|${p}\right|}{\left|P\right|} - 0.05\right)\right)} \\
+      + &\tanh{\left(100\left(\frac{\left|${p}\right|}{\left|P\right|} - 0.15\right)\right)} \\
+      + &\tanh{\left(100\left(\frac{\left|${p}\right|}{\left|P\right|} - 0.75\right)\right)} \\
+      + &\tanh{\left(10\left(C\left(${p}\right) - 0.25\right)\right)} \\
+      + &\tanh{\left(10\left(L\left(${p}\right) - 0.5\right)\right)}
       \end{aligned}
     `,
     evaluate: data => data.importance,