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

Discussion: Add _featureProjection (optimized for visualization) to GraphQL and REST API #1139

Closed
bobvanluijt opened this issue May 13, 2020 · 7 comments

Comments

@bobvanluijt
Copy link
Member

Some end-users use Weaviate to visualize data and results. Normalizing the data to 2 and 3 dimensions is helpful for those types of users.

Questions:

  • Is the wording correct?
  • What algos are available to calculate these distances?
  • Would this also work inside the __meta results as proposed here?

Example query and results

Query

{
  Get {
    Things {
      Article(
        explore: {
          concepts: ["beatles"]
        }
        limit: 1
      ) {
        title
        __meta {
          dimensions(
              algorithm: foobar, # which algo should be used to determine the positions?
              fullVectorSpace: boolean # are the results relative to the complete vector space or only the results?
          ) {
              2D
              3D
              fullD
          }
        }
      }
    }
  }
}

Result

{
  "data": {
    "Get": {
      "Things": {
        "Article": [
          {
            "title": "Opinion | John Lennon Told Them ‘Girls Don’t Play Guitar.’ He Was So Wrong."
            "__meta": {
                "dimensions": [{
                    "2D": [0.0, 0,0], // 2D
                    "3D": [0.0, 0,0, 0,0], // 3D
                    "fullD": [0.0, 0.0, 0.0, 0.0, etc] // contains all vectors
                }
            }
          }
        ]
      }
    }
  },
  "errors": null
}

Example in Python

import matplotlib.pyplot as plt
import numpy as np

def indic(data):
    #alternatively you can calulate any other indicators
    max = np.max(data, axis=1)
    min = np.min(data, axis=1)
    return max, min

# "fashion"
word1 = np.asarray([0.07655,-0.137151,0.07835,-0.392998,0.072685,-0.146832,0.113512,0.130071,-0.19113,-0.414321,0.633359,-0.530731,-0.191116,0.012984,-0.045579,-0.086583,0.079788,-0.086416,0.441468,-0.147333,-0.267467,-0.561935,-0.229391,0.277805,-0.672299,-0.339999,0.315659,-0.139294,-0.401233,-0.032434,-0.228802,-0.160716,-0.00601,0.008174,0.074854,-0.425195,-0.356296,0.415796,0.757146,-0.409038,-0.70905,-0.991883,0.236134,0.458376,0.26832,-0.138425,-0.063779,-0.09229,0.238704,-0.005163,-0.066798,-0.6151,0.45186,0.563144,0.095815,0.096551,-0.090798,-0.270439,0.344654,-0.570884,-0.340308,-0.73626,-0.035822,0.083229,-0.106268,0.635569,-0.506906,-0.520397,-0.213085,0.385653,-0.441684,-0.134853,0.909819,-0.122999,0.066589,-0.535037,-0.020075,-0.258741,-0.180739,0.303122,0.16585,0.481656,-0.070247,-0.374652,0.696681,-0.262914,-0.465286,0.347529,-0.781475,-0.266601,-1.136426,-0.196691,-0.248654,0.159138,-0.644566,0.111121,0.547727,-0.233514,-0.155198,0.456435,0.431365,-0.050944,-0.416236,-0.057991,0.589959,0.508293,-0.007824,-0.158656,-0.011496,0.018673,0.111597,-0.484025,-0.220264,0.24011,0.006941,-0.451819,-0.312314,0.249398,0.559422,-0.351144,0.39806,-0.064285,0.010785,-0.059851,0.018142,-0.204662,0.136271,-0.005089,0.377457,-0.471489,-0.704531,0.181635,0.254021,0.070044,0.685151,-0.320578,0.196757,0.469761,0.180152,0.104317,0.844241,0.017567,0.484882,-0.463201,-0.386116,1.041326,0.27592,0.448787,0.910783,0.20155,-0.92621,0.253901,0.716841,0.13181,-0.783828,0.360555,-0.050198,0.165152,-0.528331,-0.007915,-0.159805,-0.883246,-0.392091,0.045593,-0.199013,0.29506,0.513743,0.766999,-0.36508,0.185668,-0.08641,-0.454063,0.172128,0.880402,0.687631,-0.003163,-0.085436,0.477485,-0.020104,0.288347,0.303434,-0.221817,-0.245862,-0.436656,0.121052,-0.721617,0.169611,0.1849,-0.179834,-0.829672,0.431966,0.390068,0.021134,0.28996,-0.310009,-0.378922,-0.077232,0.362725,0.230884,-0.781913,-0.221456,-0.029122,-0.329704,-0.47795,-0.711396,-0.076088,0.294187,-0.425926,-0.327361,-0.089109,0.227116,0.59237,0.49822,0.061007,-0.304495,-0.562214,-0.268303,0.47996,0.413709,-0.151394,-0.064887,0.44668,0.845433,0.198388,0.396043,-0.249692,-0.405229,-0.143991,0.10919,-0.356322,0.435029,0.102188,0.205608,0.92135,-0.380464,0.098543,-0.654967,0.471009,0.287836,0.002938,0.746745,-0.488849,0.557295,-0.36435,0.475649,0.180489,0.80148,-0.204379,-0.341478,-0.388818,-0.063719,0.11203,0.197918,0.186345,-0.205672,0.294841,-0.265687,-0.318235,0.175663,-0.118036,-0.304499,0.433773,-0.477675,0.057431,0.757433,-0.229841,-0.26618,-0.514648,-0.347389,-0.274255,0.809413,0.471341,-0.091479,0.523209,0.48022,0.58512,-0.606165,-0.691057,-0.042951,0.308613,0.236227,0.174552,0.059148,-0.32243,0.288494,0.151482,0.006442,-0.239924,0.146384,-0.432936,-0.066526,0.027513,-0.272777,0.232751,-0.462495,0.246388,-0.461821,0.048441,0.105145,-0.249091,0.555139,0.422939,0.131613,-0.433079,-0.177423,-0.330569,0.430779,0.075303,0.224233,0.376083,-0.638128,-0.106964,0.426186,0.057201,-0.438694,-0.177331,0.27648,-0.190251,0.468919,-0.220797,0.393159,-0.06115,0.036851,0.134269,-0.168347,-0.174714,0.156677,-0.425536,-0.15805,0.183494,-0.21699,-0.647586,0.021202,0.747876,-0.458661,0.417665,0.20287,-0.18857,0.18081,0.506391,-0.325168,0.191457,-0.764245,-0.467078,0.170439,0.394305,-0.622891,-0.419261,-0.336429,-0.157621,-0.443707,0.389839,1.144677,0.434442,0.46803,0.164109,0.387208,-0.052942,-0.278872,0.181136,-0.05521,-0.239427,0.311221,-0.380181,-0.392641,-0.236175,-0.485506,0.644103,0.314808,-0.658797,0.048376,0.441455,0.173838,0.376469,0.135767,-0.200885,0.3406,0.132224,0.093676,-0.136374,0.466677,0.030839,0.481519,-0.307897,0.12791,-0.385147,-0.770121,0.119458,0.219387,-0.234942,0.102422,-0.653135,-0.389174,-0.212455,-0.215225,-0.014836,-0.317539,0.33247,-0.596213,0.534563,-0.498681,-0.090667,-0.260861,-0.104011,0.101203,0.371964,-0.489224,-0.2032,-0.242138,-0.440579,-0.431884,0.063124,-0.28484,-0.447212,0.485429,-0.433085,-0.361551,-0.260754,0.008101,0.100687,0.171089,0.458609,0.223046,-0.346977,-0.253084,0.256073,0.586526,0.409929,0.282539,0.063803,-0.425431,0.827501,0.135036,-0.483787,0.217829,0.702683,0.17279,-0.349,-0.529138,-0.06306,-0.24004,0.164086,0.166203,0.569552,-0.125284,0.398413,-0.114458,-0.617463,0.495735,0.342224,0.201017,0.117438,-0.622614,-0.275125,-0.085794,0.607932,0.2722,0.083993,0.195914,0.313351,0.647383,0.821814,-0.299769,0.279889,0.466182,0.579524,-0.357433,0.274181,-0.337294,-0.121772,-0.52281,-0.276123,-0.091341,-0.331886,-0.357046,-0.405798,-0.190481,0.253037,-0.329184,-0.047703,-0.394454,-0.151832,-0.490707,-0.543276,0.580825,-0.207426,0.028208,0.248666,0.190474,-0.198198,-0.52503,0.325049,-0.103628,-0.63762,-0.225301,0.12101,0.356279,-0.584782,0.51898,0.645864,-0.26391,0.307391,0.44762,-0.260318,-0.02998,-0.15362,-0.537362,-0.058806,0.144662,-0.443341,-0.457268,-0.265795,-0.414257,-0.268532,0.079249,0.48668,0.177659,-0.121394,-0.586254,-0.363313,-0.055374,-0.035424,-0.237076,0.435612,-0.304661,0.40394,-0.405071,-0.135693,0.091153,-0.055214,-0.119589,0.344179,-0.002907,-0.586826,-0.675694,-0.01769,0.740085,-0.200547,0.127746,0.412837,-0.208251,0.449039,0.252333,-0.347597,0.264763,-0.168518,0.275258,0.200538,-0.458499,-0.02978,-0.326648,-0.06521,-0.020474,0.286379,-0.517929,-0.089874,0.227852,-0.467781,-0.235887,-0.402352,0.400812,-0.360739,-0.301803,0.716842,0.436905,-0.366139,0.50308,0.123221,-0.082687,-0.024371,-0.050273,-0.021149,0.555708,0.084376,0.266099,0.201851,0.644151,0.346759,0.577601,-0.20228,0.03461,0.087218,0.566475,0.468494,-0.291359,-0.189415,-0.578016,-0.225085,-0.603282,-0.386738,0.002412,-0.03658,0.036796,-0.042667,-0.85096,-0.322869,0.071832,0.060363,-0.070748,0.401852])
# "vogue"
word2 = np.asarray([-0.325878,-0.051906,-0.37603,-0.182929,-0.289532,0.259482,0.104426,-0.282405,-0.297063,-0.598667,0.387944,-0.257873,0.224801,0.454855,0.403701,-0.155561,0.315589,-0.334644,0.259375,-0.007421,-0.411844,-0.425155,-0.337687,0.242219,-0.224906,-0.205858,0.560455,0.389912,-0.278207,0.197726,0.003909,-0.443084,-0.155043,-0.256773,0.435555,-0.205959,0.084579,0.389474,0.175139,-0.263085,0.119825,-0.023078,0.713487,0.166879,0.241136,0.080435,0.364703,0.075414,0.040766,-0.24934,0.361915,-0.188825,0.381364,0.187397,-0.204268,-0.448148,-0.714938,-0.465856,0.064667,-0.447717,-0.101445,-0.474945,-0.057368,0.320681,0.682514,0.580443,-0.040582,-0.321446,-0.394743,0.226302,-0.248749,-0.365802,0.802739,0.191365,-0.150569,-0.657642,-0.157984,-0.538659,0.189972,0.567839,0.087253,-0.613675,-0.344154,-0.168271,0.650844,-0.162873,-0.448557,0.192,0.001336,0.060049,0.019449,0.029268,0.218848,0.420814,-0.198719,-0.187046,0.338317,-0.049747,-0.16143,-0.21256,-0.127448,0.260607,-0.71966,0.003641,0.239391,0.258579,0.220639,-0.372014,0.070247,-0.388466,-0.15324,-0.022692,-0.013977,-0.260423,0.190926,0.152563,-0.24891,0.329461,0.179993,0.058425,0.290119,-0.014469,-0.315677,-0.199055,-0.282371,0.066821,0.156094,-0.014466,0.580278,-0.293162,-0.467489,0.378981,-0.198172,0.172615,0.655959,-0.068756,0.081222,0.008624,-0.245983,-0.183363,0.481765,0.39137,0.62325,-0.628766,-0.203584,0.572951,0.293498,0.325208,0.38053,-0.409769,-0.457462,0.212961,0.518071,0.059366,-0.189587,0.053305,-0.248828,0.104013,-0.178493,-0.235506,-0.478501,-0.495781,-0.074473,0.169201,0.167309,0.371742,0.91448,0.023091,-0.047393,0.068607,-0.363842,-0.233202,-0.242308,0.623387,0.514692,0.006922,-0.277817,0.766587,0.047431,0.33699,0.200017,-0.229192,-0.584128,0.111835,0.253963,-0.748487,-0.151735,-0.351781,0.026266,-0.580486,0.08337,0.277288,0.107984,0.026838,-0.043761,-0.243684,-0.508826,0.03959,0.769554,0.141305,-0.312607,0.068949,-0.20337,-0.577096,-0.535193,0.046137,0.214778,-0.074032,-0.03686,-0.252996,0.355498,0.172302,0.487624,0.184328,-0.479643,-0.385457,0.376461,0.090871,0.550845,0.049064,0.097808,0.000733,0.586307,0.013577,0.136105,-0.27286,-0.886015,-0.001238,0.053968,0.194252,-0.131167,-0.298567,-0.006953,0.532304,0.162296,0.209239,-0.475633,0.08549,0.310245,-0.03946,0.049521,-0.223766,0.369097,-0.189943,-0.002477,0.248729,0.749139,0.109065,-0.08169,0.127464,-0.350412,-0.026347,0.317235,0.515541,-0.338774,0.111632,-0.258467,0.150062,-0.439015,-0.072502,-0.395673,-0.101416,-0.379778,-0.201735,0.32122,0.470483,-0.143684,0.041137,-0.078464,0.018659,0.367471,-0.190969,-0.376825,0.644256,0.275981,0.421163,-0.338329,-0.130467,0.214511,-0.000056,-0.294999,-0.186361,0.063184,-0.065535,0.185635,0.258696,0.005358,0.09312,-0.607511,-0.107662,0.269488,0.074033,-0.426866,0.254388,-0.008753,0.048528,-0.433596,-0.299997,0.397566,-0.099084,0.152096,0.110376,0.366749,-0.060006,0.00917,-0.071735,0.488412,0.272937,-0.304792,-0.277875,-0.426207,-0.013718,0.043049,-0.232188,-0.676294,-0.022489,0.244013,-0.517795,0.329243,0.021291,0.051066,0.54109,-0.278068,0.3713,0.092466,0.016902,0.158266,-0.19951,-0.371657,-0.082481,0.139541,-0.381659,-0.159226,0.233363,-0.308515,0.291151,0.295979,-0.17297,0.082542,-0.176215,0.12611,0.165729,-0.520778,-0.461135,0.342487,0.340149,-0.447373,-0.206453,-0.100719,0.230841,-0.461233,0.224628,0.416505,0.276775,0.277552,0.550336,-0.249844,-0.061867,0.156319,0.055268,-0.042266,0.370702,-0.109784,-0.170537,-0.035702,0.099459,0.115847,0.945492,0.080171,-0.415494,0.173039,0.369701,-0.240966,0.306814,0.654507,0.564658,-0.388033,-0.082927,0.654049,-0.181192,0.199051,-0.415792,0.088428,0.064297,0.164596,0.031789,-0.774041,0.098628,0.138009,-0.129885,0.233935,-0.401161,0.14044,-0.16398,-0.476955,-0.198819,0.110381,0.092538,0.004186,0.069002,0.152588,-0.349043,-0.329801,-0.177243,-0.144383,0.432648,0.323469,-0.493216,0.277882,-0.40087,0.050647,-0.821003,-0.17368,-0.045115,0.655886,0.055465,-0.364194,-0.066993,-0.116754,-0.125443,0.077612,0.436972,-0.064422,-0.143926,-0.459953,0.028597,0.355426,0.129767,-0.050256,0.087422,-0.438768,0.014023,-0.150609,-0.195926,0.73669,0.581995,0.2554,-0.119931,-0.403759,0.155602,-0.39638,-0.131296,0.194686,0.177582,-0.341072,0.208468,0.332853,-0.079833,-0.191404,-0.003532,0.149789,0.125009,-0.301597,-0.351938,-0.219204,-0.076607,0.380437,0.316555,0.386792,0.270681,0.112101,0.365503,0.197719,0.078062,0.458936,0.602793,-0.212073,-0.012163,0.001881,0.151401,-0.513067,-0.28805,0.236533,-0.499533,-0.515618,-0.401241,-0.423293,0.001411,-0.613331,-0.303379,-0.274903,-0.216499,0.370337,0.29506,0.562572,-0.493474,0.040729,-0.160302,0.338496,-0.185557,-0.463275,0.322311,0.114281,-0.19881,-0.176023,0.504703,-0.575623,-0.369012,0.41237,0.115542,-0.502009,0.274068,-0.002052,-0.554428,-0.373283,-0.11166,-0.15862,-0.478524,-0.01024,-0.310677,-0.020089,-0.598271,-0.169129,-0.373506,0.049867,0.390512,-0.03726,0.083834,-0.226751,-0.313105,-0.275074,0.1201,-0.063727,0.088692,0.456906,-0.059781,-0.363329,0.213678,0.279792,-0.014208,0.166847,0.280529,0.041102,-0.227229,-0.736669,-0.142544,0.242308,-0.291292,0.185663,0.156326,0.34052,0.398723,0.338639,-0.116502,0.071346,-0.611544,0.007135,0.101413,-0.35384,0.246655,-0.357599,-0.121077,-0.205464,-0.004629,-0.367353,-0.186769,0.036838,0.055927,-0.161234,-0.376428,0.527811,-0.130829,-0.06515,0.173485,-0.062258,-0.31356,-0.43089,-0.173916,-0.208501,0.39209,-0.136332,0.264614,0.196367,0.35508,0.330726,-0.472517,0.323792,-0.306545,0.29542,-0.618672,-0.21726,-0.368905,0.671544,0.1942,-0.018397,-0.186765,-0.14165,-0.054651,-0.496472,-0.164041,0.051863,-0.134584,0.455873,0.065854,-0.187762,-0.294099,0.404383,-0.11847,0.38104,-0.256874])
# squarepants
word3 = np.asarray([0.134773,-0.33228,0.175238,-0.273488,-0.156951,0.181141,-0.193615,0.026671,-0.522982,-0.100677,0.42488,-0.092554,-0.107696,-0.304079,-0.519865,-0.076303,-0.334763,0.087587,0.021656,-0.516704,-0.308294,0.535476,0.009387,-0.191539,0.095465,0.086086,0.245902,0.192144,-0.18309,-0.093761,-0.439305,-0.12738,-0.44606,0.401168,0.261619,0.058066,0.386859,-0.28608,0.45283,0.291854,-0.178111,0.077059,-0.090209,0.327331,0.246404,-0.000123,0.145803,0.700178,-0.008514,0.171997,-0.196695,0.028628,0.269527,0.070214,0.208012,-0.521331,-0.310016,0.071633,0.334987,-0.472795,0.237743,0.281781,0.05321,-0.223772,0.344925,0.338463,0.511515,0.122031,-0.086317,0.054799,-0.412218,-0.075616,-0.408703,-0.264243,0.677079,-0.213208,0.007509,-0.364413,-0.373246,-0.214058,0.199604,0.079722,-0.251838,-0.090845,-0.421012,0.429875,0.11515,0.319039,-0.110806,-0.498892,0.1711,-0.327822,-0.304493,-0.312168,-0.144667,-0.178814,0.531867,0.396615,-0.475295,-0.478082,-0.122761,0.027997,-0.249703,-0.155774,-0.065377,-0.031248,0.05087,-0.008884,-0.569098,0.069156,-0.165043,-0.120547,0.173665,0.508773,-0.12195,-0.14028,-0.076414,0.344971,-0.026127,-0.133946,-0.023609,0.363209,-0.230352,0.002261,-0.594976,0.010342,-0.382944,0.528546,0.307132,0.117432,-0.226697,0.130363,-0.124694,0.161067,0.282781,0.386605,0.104518,0.114789,0.172052,0.280664,0.168695,0.33746,-0.179941,0.279491,0.425915,0.199123,-0.027481,-0.377801,0.31925,-0.081634,-0.038207,0.469118,-0.180139,0.130357,-0.360754,0.06489,0.424615,0.154051,-0.276408,0.266223,0.022848,0.017225,-0.049623,0.055277,0.225734,0.188049,-0.348101,0.475537,-0.163572,0.22505,0.269292,-0.322904,-0.056857,-0.338178,0.131452,-0.17842,-0.031523,0.366814,0.226476,-0.022733,0.373449,0.18136,0.082758,-0.174959,-0.024093,0.10517,0.456174,-0.124202,-0.06289,0.007445,-0.475295,0.002866,0.250712,0.139263,-0.179093,0.254592,-0.327572,-0.092751,-0.074071,0.142911,0.408254,-0.536961,0.139389,0.14937,0.302615,-0.05187,0.014776,-0.007785,-0.277502,-0.172476,0.148724,-0.078335,-0.461759,-0.020407,0.145133,0.020425,0.024184,0.09608,0.249326,-0.066049,0.154716,0.086799,-0.10935,0.051476,-0.095236,-0.573984,-0.299073,-0.350304,-0.074376,-0.29331,-0.437377,0.079558,0.144407,-0.128323,0.223494,0.308684,-0.027159,0.350883,-0.032272,0.290063,0.29509,0.061857,0.010531,0.096926,0.077949,0.045358,0.125117,0.005249,-0.256885,-0.086914,0.240459,-0.313861,0.18949,0.039748,0.337342,0.272607,0.216127,0.164692,0.050238,-0.446632,0.21419,0.499544,-0.098412,0.109527,0.042094,-0.301675,-0.409025,0.370249,0.143495,-0.063403,-0.119362,0.169521,0.132795,-0.038105,-0.232227,-0.140607,-0.744314,-0.171722,-0.162691,-0.032233,0.076431,-0.059174,0.166393,0.364559,0.305766,0.241042,0.063415,-0.165843,0.013909,-0.401998,-0.321246,-0.150172,-0.041546,-0.052277,-0.094715,-0.171996,-0.196949,-0.239425,-0.206708,0.009347,0.201739,-0.070051,0.137772,-0.314252,0.005399,-0.107479,-0.344194,0.12233,0.121401,0.132099,0.321106,0.138028,0.29629,-0.372749,-0.318292,-0.060146,-0.093075,-0.061992,-0.189127,-0.299029,0.458822,-0.122837,0.143793,-0.125048,0.323939,-0.099517,-0.029958,-0.348261,0.043958,0.156798,-0.239992,0.435576,0.103277,-0.138816,-0.051779,-0.196076,0.059962,-0.523336,0.000996,-0.489194,-0.181044,-0.310012,0.021966,-0.495353,0.137643,-0.353912,0.34174,0.189195,0.22972,0.14583,0.207189,-0.195769,-0.05826,0.084887,-0.341727,-0.2823,-0.61809,-0.048129,0.001741,0.204023,-0.13985,0.048335,0.740079,-0.279545,-0.05809,-0.22492,-0.218836,0.089303,-0.397475,-0.48638,0.145101,-0.23094,-0.274191,0.327769,0.118033,-0.086289,-0.120373,-0.483273,0.118105,-0.253751,0.112702,0.103797,0.234108,0.687983,-0.117838,-0.101887,0.062113,0.054403,-0.071801,0.06447,0.006211,0.16122,-0.154278,0.168048,0.126579,0.091289,0.156008,-0.354104,0.419008,0.164097,0.136872,0.117704,0.005845,-0.228559,-0.386703,0.065935,0.289776,-0.169168,-0.246554,-0.372667,-0.100691,-0.072655,0.220872,-0.412035,0.197492,0.038957,0.146075,-0.001903,-0.568973,0.364768,-0.035326,0.153542,0.04284,-0.102817,-0.165946,0.205069,-0.145218,0.469649,-0.039997,0.437182,-0.033556,0.481445,0.223937,0.303535,0.141393,-0.240882,0.285596,0.054986,-0.006778,0.108866,-0.11952,0.547883,0.079572,-0.1325,-0.11254,-0.021571,-0.00776,0.469869,0.252255,0.118995,0.183254,-0.059441,0.150587,0.339158,0.553166,0.16213,0.264012,0.161852,-0.185841,-0.023173,-0.097825,0.138632,0.461363,-0.049959,0.222512,-0.105566,-0.103913,-0.029151,-0.164047,0.080732,0.109995,0.487996,-0.163851,-0.314243,0.053785,-0.356482,0.113992,0.145221,0.212262,-0.197876,-0.112732,0.124475,-0.231066,-0.138431,0.10941,-0.239905,-0.213513,-0.217354,0.013053,0.221748,0.197268,-0.037644,-0.231633,0.308174,0.070856,0.020652,0.210802,0.019854,0.122903,0.361702,-0.373232,0.167491,-0.031869,0.0444,-0.259786,0.089875,-0.042016,0.108616,-0.184866,0.039999,-0.271834,0.392855,0.08887,0.867828,-0.375367,0.030548,-0.089608,-0.024766,-0.016658,0.163421,-0.09222,0.323543,-0.008713,0.255564,-0.020237,-0.570658,-0.162921,-0.45404,-0.061257,0.174295,0.256687,-0.300431,-0.037507,0.169243,-0.643566,0.077,0.028276,0.304585,-0.212584,-0.263332,-0.427906,0.037614,-0.1253,0.133156,-0.212443,-0.013109,0.292146,0.037275,-0.272773,0.05808,-0.03293,0.037465,0.085835,-0.028604,-0.140057,-0.03613,0.160049,-0.070763,-0.133366,-0.470192,-0.308537,-0.293247,0.070287,0.132081,0.176672,0.002631,-0.089021,0.12711,-0.076591,0.250014,-0.390064,0.124476,-0.053196,-0.009127,0.108046,-0.154075,0.242588,0.212954,-0.633132,-0.253171,0.230195,0.262817,-0.318266,-0.283773,-0.205074,-0.042223,0.335315,0.172298,0.242188,0.078341,0.18781,-0.165413,0.106726,-0.080102,-0.171244,-0.063795,0.317989,0.129811,0.37276,-0.301992])
# cartoon
word4 = np.asarray([-0.13455,-0.189951,-0.013473,0.119759,0.146918,0.4431,0.32031,0.150195,-1.035399,-0.29899,0.586389,-0.2899,0.04115,-0.75339,-0.112115,-0.25545,0.055991,0.128666,0.247944,-0.615107,-0.374845,0.026447,-0.574903,-0.027289,0.040986,-0.204692,-0.00811,-0.312197,-0.164372,0.130092,-0.542413,-0.329125,-0.098628,0.041755,0.274137,0.043807,0.415683,-0.179035,-0.424959,0.019187,-0.007486,-0.082136,0.192331,0.400324,0.469384,0.332063,0.066342,0.276347,0.364935,0.198142,-0.216111,0.227196,-0.009589,0.172643,-0.345082,-0.037774,-0.182823,-0.040144,0.385288,-0.43966,0.404535,-0.042798,-0.352541,-0.212576,0.430362,-0.012215,0.286784,0.075809,-0.429337,0.39687,-0.121511,-0.084747,0.240355,0.519697,0.415242,0.133163,-0.071546,-0.449682,0.043178,-0.03912,0.049215,0.83084,-0.178892,-0.574345,-0.326339,0.547704,-0.052342,0.156224,-0.698305,-0.233544,0.198623,0.64689,-0.517375,0.092335,0.031487,-0.002226,0.747445,0.199069,-0.174504,-0.152908,-0.384229,0.357776,0.120351,0.041392,-0.256153,0.455221,0.449513,0.229193,-0.127281,-0.022349,0.103825,0.27215,0.148946,0.037321,0.239978,-0.36745,-0.004437,0.026667,-0.161581,-0.66302,0.392062,0.387597,0.395959,0.075678,-0.295216,-0.399943,-0.886552,0.523979,0.245359,0.210354,-0.547949,-0.312415,0.037628,0.649796,0.366955,0.387407,0.418674,0.722438,-0.311673,0.393646,0.023212,0.193634,-0.010199,0.276385,-0.081837,0.169028,-0.357743,-0.534522,-0.104568,0.328404,-0.08973,0.311206,-0.011338,0.08786,0.270268,-0.245088,0.629777,-0.011294,-0.393012,0.516804,-0.004065,-0.462961,-0.235876,0.261354,0.247991,0.28386,0.030149,0.291142,0.361781,0.216728,0.351064,-0.402365,0.057166,0.635015,0.340239,0.317985,-0.27266,0.1376,-0.010345,0.323718,0.162736,0.685106,0.178639,-0.706788,-0.287399,0.065743,0.745889,0.216821,-0.296206,-0.041377,-0.588569,-0.445556,-0.104536,0.001837,-0.452926,0.266617,0.192357,0.295303,-0.079447,0.224089,0.046122,-0.009775,0.245973,-0.251214,-0.189282,-0.388559,0.189037,0.326483,-0.469117,-0.034715,0.46443,-0.017147,0.012729,0.161972,-0.315522,-0.055057,0.060128,0.428849,0.349271,0.09831,-0.28169,0.208159,-0.154747,-0.327186,0.657628,-0.283768,-0.244756,0.119875,-0.317987,-0.299693,-0.384697,0.002995,0.249834,0.201206,0.340825,0.603355,-0.613877,0.066299,0.467835,0.143417,1.019887,-0.486645,0.048365,0.37885,0.565213,0.450711,-0.485956,0.179457,0.40072,-0.252935,0.102629,-0.417071,0.367689,-0.014946,0.237237,0.924976,0.114745,0.24543,0.251115,-0.373996,-0.470583,-0.075161,-0.260334,0.210164,-0.02564,-0.361888,0.040408,0.127198,-0.043608,0.354255,-0.347832,0.373554,-0.116339,0.557872,0.108341,-0.403497,-1.475242,-0.015699,0.336959,-0.309925,-0.396638,0.52896,-0.047946,0.304019,-0.507755,0.34727,0.086608,0.254767,-0.694412,-0.099842,0.03238,0.545836,0.340112,-0.043736,0.052841,0.568772,0.176227,-0.135857,0.260206,0.253383,0.155219,-0.021548,0.300478,-0.352536,0.360397,-0.198995,0.282534,0.315682,0.294884,-0.011333,0.047491,0.494092,0.556941,-0.390042,-0.393575,0.362269,-0.10089,-0.035628,0.420735,-0.269931,0.256398,-0.531838,-0.157155,-0.039514,-0.302489,0.216564,-0.354326,-0.01012,-0.326648,-0.569223,-0.181486,-0.066507,0.083303,0.175804,0.044332,-0.041018,0.082344,-0.363275,-0.402603,-0.383633,-0.903631,0.242457,-0.182245,-0.288061,0.394871,-0.319733,-0.18425,-0.101172,-0.487404,0.037511,0.471626,-0.721096,0.139393,-0.3434,-0.016939,0.554911,-0.795835,-0.247649,0.362791,-0.41505,-0.283704,0.048164,0.430403,-0.000385,-0.441988,-0.728352,-0.292152,-0.368017,-0.082015,-0.215155,0.182544,0.079093,-0.042519,0.833188,-0.134131,-0.099684,-0.253927,-0.191805,-0.110773,-0.115114,-0.539182,-0.016659,0.493556,0.245636,-0.023938,-0.16666,0.115777,-0.325829,-0.260933,-0.217088,0.366763,-0.08703,-0.198847,0.508718,-0.176418,-0.413833,0.009269,-0.481354,0.017169,0.114267,0.028246,0.091301,0.200103,0.119266,-0.497977,0.367969,-0.379857,-0.26383,0.292733,-0.218323,-0.589592,0.147831,0.012937,-0.274532,0.336735,0.200751,0.175241,-0.122046,0.085413,0.21613,-0.125897,0.329277,-0.13408,0.35196,-0.131086,-0.057801,0.24127,0.071301,0.014089,0.282335,-0.26205,0.183196,-0.41357,0.439483,-0.223176,-0.282759,-0.42758,0.112125,-0.073394,-0.032878,-0.307878,0.341906,0.629213,0.014707,0.393171,0.465874,0.30924,0.013741,0.450432,-0.021126,0.205848,0.711744,0.24285,0.135857,0.45011,0.329265,0.19849,0.311707,0.398195,-0.089365,-0.685483,0.221834,0.234617,-0.206061,-0.034781,0.364008,-0.07192,-0.122503,-0.110891,-0.142401,-0.122932,-0.498128,-0.302254,-0.242262,-0.326026,-0.227135,-0.321251,0.086076,0.023164,0.171996,-0.271102,-0.033476,0.013741,0.168034,0.348192,-0.293825,0.58053,-0.126077,0.330065,0.044419,0.101229,0.115614,-0.318257,0.534554,-0.276205,-0.011612,-0.218534,-0.027322,0.579543,0.411908,-0.108819,0.156388,-0.097157,-0.081857,-0.30878,0.058607,0.148423,-0.218013,-0.76492,0.065536,0.036159,0.179578,0.471357,0.365977,-0.082547,0.13686,-0.718237,0.217187,-0.025477,-0.342543,-0.100311,-0.021867,-0.107182,0.389567,0.247425,-0.444468,0.303853,-0.139428,-0.118522,0.382314,0.585605,0.143338,0.430678,-0.366191,-0.727774,0.596184,0.301591,0.658206,-0.008149,-0.835272,-0.37432,0.042559,-0.317387,-0.094317,-0.131869,-0.056565,-0.16338,0.464755,-0.075513,0.086343,0.91094,-0.302049,-0.268563,0.397672,-0.341724,0.174686,-0.256557,-0.597424,-0.402341,-0.350284,-0.044833,0.188793,-0.73048,0.349,0.108516,-0.173408,-0.177789,-0.149706,-0.715912,0.545862,0.212682,0.527069,-0.288603,-0.144865,0.717654,-0.20229,-0.228589,0.067949,-0.514362,0.095297,-0.254159,0.186916,-0.076169,-0.027013,-0.001434,0.740022,0.10141,-0.08612,-0.254753,-0.567002,0.592814,-0.989176,0.152224,-0.500827,-0.383415,-0.611256,0.29372,0.287296,0.242588,-0.036975])
# Determine indic's
x, y = indic([word1, word2, word3, word4])
# plot the points
plt.scatter(x, y)
# annotate per word
plt.annotate('fashion', (x[0], y[0]))
plt.annotate('vogue', (x[1], y[1]))
plt.annotate('squarepants', (x[2], y[2]))
plt.annotate('cartoon', (x[3], y[3]))
# show
plt.show()
@etiennedi
Copy link
Member

Depending on how urgently this is needed and whether a dimensionality reduction algo is available out-of-the box in Go, a temporary solution could also be to add this to the python-based weaviate client and and do the calculations on top of Weaviate until we have ported such an algorithm to go.

Note: The above is based on the assumption that no such algorithm exists in Go and it's sufficiently complex (i.e. more than a day or two of effort) to write it from scratch. If both assumptions prove untrue, this temporary workaround wouldn't add any value.

@bobvanluijt
Copy link
Member Author

Depending on how urgently this [...]

It is not "blocker" urgent but I would like to do this from the Weaviate perspective from the get-go.

@bobvanluijt
Copy link
Member Author

cc: @graphileon

@etiennedi
Copy link
Member

Here is the result from a first experiment with https://github.com/danaugrs/go-tsne to plot the 15NN to the word "car" and "wine" according to their contextionary position. With these 30 results, the dimensionality reduction takes about 14ms which should absolutely be viable for a regular request.

image

@graphileon
Copy link

@bobvanluijt @etiennedi Am I correct understanding this as the 15 best results from submitting a query car or wine ?
If so, can I assume that you plan to add the queries themselves, as well as the concepts that are on the semantic paths from the query to each of those results?

To avoid a lot of clutter, and having in mind our own d3 based viz, I imagine that the semantic path to a specific result is visible when the user selects that result.

@etiennedi
Copy link
Member

@graphileon

Am I correct understanding this as the 15 best results from submitting a query car or wine ?

The above was meant as an experiment to see if we can reduce our n-dimensional vectors to 2d (or 3d) coordinates which seem intuitive to humans. The graph shows two clusters; one is the nearest neighbors (in the contextionary) of the concept car and the other of the concept wine. My underlying assumption was that each cluster has elements close to one another, but completely separate from the other cluster. I.e. the individual words, such as car, driving, road, automobile etc should form a cluster, but not overlap with the individual words around wine. Since that worked, I believe we could use the mentioned algorithms to display our vectors in 2 or 3 dimensions in general.

If so, can I assume that you plan to add the queries themselves, as well as the concepts that are on the semantic paths from the query to each of those results?

This is entirely open at the moment, but definitely an option.

To avoid a lot of clutter, and having in mind our own d3 based viz, I imagine that the semantic path to a specific result is visible when the user selects that result.

In the end we would just list a set of 2d or 3d coordinates and it'd be up to you on how you use them for a visualization. Please note that the semantic path (as outlined in #1126 ) is something very early stage that we're experimenting with at the moment. We have not yet finalized how a path is constructed - or the elements it contains, so it's too early for me to predict how that would translate to a visualization. A first step would just be to visualize the search query and all search results. Ideally that would show that the first result is closer to the query than the last result.

@etiennedi etiennedi changed the title SUGGESTION: Normalized vector representations for visualization to __meta Add _featureProjection (optimized for visualization) to GraphQL and REST API Jun 12, 2020
@etiennedi etiennedi changed the title Add _featureProjection (optimized for visualization) to GraphQL and REST API Discussion: Add _featureProjection (optimized for visualization) to GraphQL and REST API Jun 24, 2020
@etiennedi
Copy link
Member

Closing this analysis issue in favor of #1178 which is used for implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants