<div dir="ltr">Hi all! I have been using the TSNE module in python’s sklearn to visualize n-dimensional binary valued dataset using ‘hamming’ as the distance metric. I plan on packing the n-dimensional dataset into bits in a uint8 array using numpy’s ‘packbits’ function. To use the TSNE module on the packed dataset, I would have to unpack the new dataset and use the ‘hamming’ distance metric as I have been doing in my original dataset. I however want to write a simple callable function that will unpack just two instances in the packed dataset and measure the hamming distance. In my initial attempt, I used a lambda function as a metric which takes two input arrays, unack them and outputs the hamming distance between the two. Here's an example given 'myPackedDataset' is the packed dataset:<div><br></div><div>tsneCluster = TSNE(learning_rate=rate_val, perplexity=per_val, n_iter=iter_val, metric=lambda x, y: distance.hamming(np.unpackbits(x), np.unpackbits(y)))<br><div>fit_result = tsne.fit_transform(myPackedDataset)<br></div></div><div><br></div><div>I get this error at the TSNE declaration:</div><div><br></div><div><pre style="box-sizing:border-box;overflow:auto;font-size:14px;padding:1px 0px;margin-top:0px;margin-bottom:0px;line-height:inherit;color:rgb(0,0,0);word-break:break-all;border:0px;border-radius:0px;white-space:pre-wrap;vertical-align:baseline"><span class="gmail-ansi-red-fg" style="box-sizing:border-box;color:rgb(231,92,88)">TypeError</span>: Expected an input array of unsigned byte data type</pre><pre style="box-sizing:border-box;overflow:auto;font-size:14px;padding:1px 0px;margin-top:0px;margin-bottom:0px;line-height:inherit;color:rgb(0,0,0);word-break:break-all;border:0px;border-radius:0px;white-space:pre-wrap;vertical-align:baseline"><br></pre><pre style="box-sizing:border-box;overflow:auto;padding:1px 0px;margin-top:0px;margin-bottom:0px;line-height:inherit;word-break:break-all;border:0px;border-radius:0px;vertical-align:baseline"><span style="color:rgb(34,34,34);font-size:small;white-space:normal;font-family:Arial,Helvetica,sans-serif">I am still trying to understand how the callable function option of the TSNE's metric parameter works but I would really appreciate any help. </span><font color="#000000"><span style="font-size:14px;white-space:pre-wrap">
</span></font></pre><pre style="box-sizing:border-box;overflow:auto;font-size:14px;padding:1px 0px;margin-top:0px;margin-bottom:0px;line-height:inherit;color:rgb(0,0,0);word-break:break-all;border:0px;border-radius:0px;white-space:pre-wrap;vertical-align:baseline"><br></pre></div><div><br></div></div>