<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Oren Zeev Ben Mordehai on Medium]]></title>
        <description><![CDATA[Stories by Oren Zeev Ben Mordehai on Medium]]></description>
        <link>https://medium.com/@zbenmo?source=rss-764c6dbf392e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*oByZFY7B_ZRtx-Hj.</url>
            <title>Stories by Oren Zeev Ben Mordehai on Medium</title>
            <link>https://medium.com/@zbenmo?source=rss-764c6dbf392e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 19:47:04 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@zbenmo/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Bulk Labelling the Mona Lisa]]></title>
            <link>https://zbenmo.medium.com/bulk-labelling-the-mona-lisa-98acd5ea8ce2?source=rss-764c6dbf392e------2</link>
            <guid isPermaLink="false">https://medium.com/p/98acd5ea8ce2</guid>
            <dc:creator><![CDATA[Oren Zeev Ben Mordehai]]></dc:creator>
            <pubDate>Mon, 05 Dec 2022 13:24:40 GMT</pubDate>
            <atom:updated>2022-12-05T14:25:38.235Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*-wmbsIawojYURBqhjaHEFg.png" /><figcaption>Image by Peter Schmidt from Pixabay</figcaption></figure><p>When your dataset is not yet labelled, or you suspect that some of the labels were wrongly annotated, it would have been nice to bootstrap and to have a visual way to select the most interesting data points for (re)labeling / verification. Potentially it can be an iterative process in which you label some of the data points, train a model, use the model predictions to (re)examine the data, and label some more. But how to start and what tools can be helpful in this chore?</p><p>I came across two short Explosion (spaCy, prodigy) videos by Vincent Warmerdam, referring to image labelling. Those two videos are packed with useful tips and know how, I strongly recommend to watch those. I’ll do my best to share the main ideas below.</p><p><a href="https://www.youtube.com/watch?v=s0Y45xscE-0">Quick, Draw! Eiffel tower</a> (finding bad labels, straight forward embeddings).</p><p><a href="https://www.youtube.com/watch?v=DmH3JmX3w2I&amp;t=1s">Cats vs. Dogs</a> (bootstrap labelling, pretrained CNN DNN embeddings and task-specific bootstrapped embeddings).</p><p>The suggested pipeline is to create 2-D embeddings for each data point, and to plot those as a point cloud. Then you can hopefully see a few interesting emerging clusters that are worth investigating. The next step would be to select a cluster and examine a few data points from that cluster. <strong>If indeed there is something special</strong> about the (say images) in the cluster. Maybe it turns out that all the data points in the cluster <strong>should be labeled the same</strong>. Even if only 90% of them are cats for example, then it would be nice to have those defaulted to ‘cat’ which can speed labeling with a tool such as prodigy. Identify a cluster of bad labels (and removing those data points or fixing the labels) can be a boon. You can also Identify “hard” regions, where the embedding does not do really good in separating the classes, and consider starting the manual labeling with examples from there.</p><p>Let’s enumerate the steps above:</p><ol><li>Create 2-D embeddings for the data points. The embedding should be meaningful in the sense that they help in clustering visually different samples with some relevance to the downstream task(s). How to get there? It is a trial and error. But Vincent suggests to try some SOTA n-dimensional embeddings and to use UMAP as a dimensionality reduction technique, as to wind up with 2 dimensions.</li><li>Visualize as a scatter plot. This can be done in a Jupyter notebook. Your 2-D embeddings are the ‘x’ and the ‘y’ of each point.</li><li>Select visually a cluster. We can identify an interesting rectangle and draw it on the scatter plot to verify we got the relevant ‘x’s and ‘y’s.</li><li>Examine data points from the selected cluster. We can sample datapoints that fall in that rectangle, and for each of those plot the relevant image (or other relevant information). As a complementary tool for the notebooks, Vincent provided the ‘<a href="https://pypi.org/project/bulk/">bulk</a>’ utility installable as a Python package. The added value of ‘bulk’ is that we can visually select and, the functionality for displaying the selected datapoints as well as exporting is given.</li><li>Export findings regarding to the selected points to the next in the chain tool expected format. This should be done by some combination of scripts and / or the bulk utility. With a knowledge and support of the target labeling tool.</li><li>Use findings in additional labeling tools and / or machine learning models. For example using prodigy by Explosion or another.</li><li>Keep track of history of data points and labelling to avoid repetitive work and infinite cycles.</li></ol><pre>fig, ax = plt.subplots(figsize=(6, 6))<br>plt.scatter(x_tfm[:, 0], x_tfm[:, 1], alpha=0.002)<br>ax.add_patch(<br> matplotlib.patches.Rectangle((3.0, 6.6), 3, 2, color=&#39;r&#39;, fill=False))</pre><p>Example Python snippet for items 2–3. above.</p><p>I have decided to replicate what Vincent is showing in the first video. He was using there images from <a href="https://quickdraw.withgoogle.com/">Google Quick, Draw!</a> Vincent selected specifically the Eiffel tower dataset, each image is 28x28 monochromatic image, and in the video we learn to quickly find images that are not really good samples of a Eiffel tower drawing. The dataset is interesting as users where given 20 seconds or so to quickly draw an image representing Eiffel tower and other categories (a total of 345 categories). And surprising enough a machine learning model can now figure out, very fast, what you are drawing (out of the given categories). But if we want to build such a ML model ourselves, it makes sense first to remove samples that are obviously wrong.</p><p>Vincent picked images of the Eiffel tower, and since all those images are of the same category, then we hope that in a good clustering visualization, what seems to be grouped together is indeed similar, for example for Vincent he got a single big blob of the “good examples” and a smaller identified blob of mostly not good Eiffel tower samples.</p><p>For me, with the Mona Lisa category, I have found even nicer pattern. I have used Jupyter notebook and the bulk utility. To prepare an input for the bulk utility, I have used a code similar to below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/916/1*wPHm4T7vQVSI9-uKKU_W6g.png" /><figcaption>preparing a CSV for the bulk utility: x, y, path (disclaimer: a URL path may not be supported yet in bulk)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/616/1*oHITyKfHsc0R6_2vnsuI4Q.png" /><figcaption>Created in a notebook (with matplotlib)</figcaption></figure><p>After examining the clusters above, in the bulk utility actually, I believe above tags are representative: ‘single frame’, ‘double frame’, ‘no frame’, and ‘not really Mona Lisa’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/543/1*a8yIRdNp6DG-GGF0ETQJAg.png" /><figcaption>no frame</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/985/1*Uwngmzw9fE0Tj3fQF8Zg4A.png" /><figcaption>single frame</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/886/1*imGnDcrmjnmsXGk_XidHbw.png" /><figcaption>double frame</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/791/1*ha2o0iFhjZjpIHTctaLmOg.png" /><figcaption>Mona Lisa???</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=98acd5ea8ce2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mammals dataset, Tidy data, & Streamlit]]></title>
            <link>https://zbenmo.medium.com/mammals-dataset-tidy-data-streamlit-6ed7ccc7b2ae?source=rss-764c6dbf392e------2</link>
            <guid isPermaLink="false">https://medium.com/p/6ed7ccc7b2ae</guid>
            <dc:creator><![CDATA[Oren Zeev Ben Mordehai]]></dc:creator>
            <pubDate>Sat, 16 Jan 2021 17:58:46 GMT</pubDate>
            <atom:updated>2021-01-16T18:11:06.089Z</atom:updated>
            <content:encoded><![CDATA[<p>I got a hold of a nice dataset about the presence of various mammal species in Europe. I thought it would be nice to play with it, practice some data tidying with pandas and show it in Streamlit. The data contain in each row, a specific grid-cell where you are given some Bioclimatic features, like the average temperature in a specific month of the year, or precipitation of wettest month, etc. For each grid cell you have also a binary column per mammal species, ‘found here or not’.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pGGm6CONLEbgP3P77cVOLA.png" /><figcaption>Loading the dataset from ARFF format to a pandas dataframe</figcaption></figure><p>Following ideas from this great PyData, Youtube recording: <a href="https://www.youtube.com/watch?v=iYie42M1ZyU&amp;t=4675s">Daniel Chen: Cleaning and Tidying Data in Pandas | PyData DC 2018 — YouTube</a>, I have extracted three tables out of the original table, and made sure to be able to reconnect by introducing a new ‘cell_id’ column, which will be selected in each.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/911/1*WSMwP9MhnSwcN4IWZqrDJw.png" /><figcaption>Splitting into ‘df_grid’, ‘df_monthly’, and ‘df_mammals’.</figcaption></figure><p>Why did I need three different dataframes? Think of it like a database normalization. The information about the grid, can be kept in one table. Then we have some information per month, ex. mean_temp_march_utm. And finally, the relation regarding the presence of a specific mammal species in a specific cell grid. I did not have a table with a row per mammal species, but this can be added, like, the common name, Latin name, link to Wikipedia article, etc.</p><p>For example, for the per month information, I had the following code:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1004/1*hUIovsKIPWf1kZVer_LTmA.png" /></figure><p>You can see above, that I took the ‘cell_id’ and the relevant columns. Then I’ve used ‘melt’ keeping only ‘cell_id’ from melting, so that we have now the columns ‘variable’ and ‘value’. Then the values in ‘variable’ are being split into two columns: ‘statistics’ and ‘month’, and finally, I use ‘pivot’ to have each statistic in its own column.</p><p>Consider the following aggregation:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ioCRhpLF5wxzoibKznTkdA.png" /><figcaption>Aggregation: how many different mammal species?</figcaption></figure><p>We can draw (distorted) map, pretending that (longitude, latitude) are a cartesian coordinates:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/544/1*bnfXgXHJ7B0PDMBwwwDuIw.png" /><figcaption>Distorted map based on (longitude, latitude) as (x, y).</figcaption></figure><p>I then moved from the Jupyter notebook to a script (Streamlit), and made use of pydeck to display a proper map:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/890/1*MrHKWqC41rZI2xoT-LLuTw.png" /></figure><p>And while in Streamlit, I had a selector of the mammal species, to fetch its Wikipedia page (displayed in an iframe), and then a map showing the grid cells where this species is found.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/923/1*10aMJswj2W0-UrTG3azL2g.png" /><figcaption>Crete spiny mouse is found in..</figcaption></figure><p>Overall it was a very nice experience, and pandas and Streamlit, do the job.</p><p>You can find a link to the Github repository below, and also a link to YouTube two parts description of above.</p><p>The credentials for the data are:</p><p>Mitchell-Jones, A.J., Amori, G., Bogdanowicz, W., Krystufek, B., Reijnders, P.J.H., Spitzenberger, F.,Stubbe, M., Thissen, J.B.M., Vohralik, V. &amp; Zima, J. (1999) The atlas of European mammals. Academic</p><p>Press, London.</p><p>The Github link is: <a href="https://github.com/zbenmo/mammals">zbenmo/mammals: mammals dataset with streamlit (github.com)</a></p><p>And the YouTube videos are in: <a href="https://youtube.com/playlist?list=PL9WgRVRjJLlYXGnHCso7SQAegjbQ8yio6">https://youtube.com/playlist?list=PL9WgRVRjJLlYXGnHCso7SQAegjbQ8yio6</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6ed7ccc7b2ae" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>