MCPcopy Create free account
hub / github.com/dblalock/bolt / fit_query

Method fit_query

experiments/python/main.py:280–312  ·  view source on GitHub ↗
(self, q, quantize=True, **sink)

Source from the content-addressed store, hash-verified

278 return idxs + self.offsets # offsets let us index into raveled dists
279
280 def fit_query(self, q, quantize=True, **sink):
281 quantize = quantize and self.quantize_lut
282 self.q_dists_ = self._fit_query(q, quantize=quantize)
283
284 if quantize:
285 # print "min, max lut values: {}, {}".format(np.min(self.q_dists_),
286 # np.max(self.q_dists_))
287 assert np.min(self.q_dists_) >= 0
288 assert np.max(self.q_dists_) <= 255
289
290 if False:
291 _, axes = plt.subplots(3, figsize=(9, 11))
292 sb.violinplot(data=self.q_dists_, inner="box", cut=0, ax=axes[0])
293 axes[0].set_xlabel('Codebook')
294 axes[0].set_ylabel('Distance to query')
295 axes[0].set_ylim([0, np.max(self.q_dists_)])
296
297 sb.heatmap(data=self.q_dists_, ax=axes[1], cbar=False, vmin=0)
298 axes[1].set_xlabel('Codebook')
299 axes[1].set_ylabel('Centroid')
300
301 sb.distplot(self.q_dists_.ravel(), hist=False, rug=True, vertical=False, ax=axes[2])
302 axes[2].set_xlabel('Centroid dist to query')
303 axes[2].set_ylabel('Fraction of centroids')
304 axes[2].set_xlim([0, np.max(self.q_dists_) + .5])
305
306 # plot where the mean is
307 mean_dist = np.mean(self.q_dists_)
308 ylim = axes[2].get_ylim()
309 axes[2].plot([mean_dist, mean_dist], ylim, 'r--')
310 axes[2].set_ylim(ylim)
311
312 plt.show()
313
314
315# ================================================================ Main

Callers

nothing calls this directly

Calls 2

_fit_queryMethod · 0.95
meanMethod · 0.45

Tested by

no test coverage detected