<?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 Estelle Scifo on Medium]]></title>
        <description><![CDATA[Stories by Estelle Scifo on Medium]]></description>
        <link>https://medium.com/@st3llasia?source=rss-506d892fb653------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*rsm3mrRIoIEg8LN5.jpg</url>
            <title>Stories by Estelle Scifo on Medium</title>
            <link>https://medium.com/@st3llasia?source=rss-506d892fb653------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 09:58:57 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@st3llasia/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[Graph Data Science with Neo4j Book]]></title>
            <link>https://medium.com/@st3llasia/graph-data-science-with-neo4j-book-e7f32cfa41cc?source=rss-506d892fb653------2</link>
            <guid isPermaLink="false">https://medium.com/p/e7f32cfa41cc</guid>
            <category><![CDATA[neo4j]]></category>
            <category><![CDATA[book-recommendations]]></category>
            <category><![CDATA[authors]]></category>
            <category><![CDATA[graph-data-science]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Estelle Scifo]]></dc:creator>
            <pubDate>Sat, 11 Feb 2023 16:44:54 GMT</pubDate>
            <atom:updated>2023-02-11T16:44:54.193Z</atom:updated>
            <content:encoded><![CDATA[<h4>Why and what’s different from my previous book</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/960/1*27-URblIuu5acFavRs9mHA.png" /><figcaption>Book comparison — by the author</figcaption></figure><h3>TL;DR</h3><p>Latest book <em>Graph Data Science with Neo4j</em> (<em>GDSN</em>) covers new features of the Neo4j’s Graph Data Science library, including its handy <strong>Python client</strong> and the introduction of <strong>machine learning pipelines</strong> (classification and link prediction) directly in the library. It also contains a new chapter about the <strong>Pregel API</strong>, the way to go to extend the GDS and implement your own algorithm. On the other hand, it has less focus on the algorithm internal working compared to its older brother, <em>Hands-on Graph Analytics with Neo4j</em> (HOGAN).</p><p>As a general advice, I would suggest to start from the newest one (<em>GDSN</em>), which is more <strong>up to date</strong>. If you have specific needs in terms of algorithm understanding, then you can focus on chapters <strong>6</strong> (for centrality measures) and <strong>7</strong> (for community detection algorithms) of HOGAN.</p><p>On the other hand, if you have already read my previous book, <em>Hands-On Analytics with Neo4j</em> <em>(HOGAN)</em>, the following chapters from <em>GDSN</em> will bring new information to you: chapters 5, 6, 8 and 10.</p><p>Slightly more details are given below, about the content of the new book and who could still be interested in the first one.</p><h3>New book: target audience and content</h3><p><em>Graph Data Science with Neo4j</em> is for <strong>Data Scientists</strong> even with little practical experience with data science. Topics like classification, model training, training sets or confusion matrix are used in this book without prior explantation, but it does not dive much deeper. On the other hand, it assumes no or very little knowledge about Neo4j and Graph Data Science. Here is a summary of the topics covered in this book:</p><ol><li><strong>Graph dataset</strong>: what it is, how to<strong> find or build a graph dataset</strong></li><li>How to <strong>understand a graph dataset</strong>: similar to classical metrics like mean value or standard deviation, what are the graph metrics that help us understand how the graph looks like. This is done using Neo4j and <strong>neodash</strong> for chart visualization. Introduces <strong>centrality</strong> and <strong>community detection algorithms</strong>.</li><li><strong>Graph visualization</strong>, using the Neo4j Bloom application or Gephi</li><li><strong>Machine Learning on Graphs</strong>: using the tools available in the GDS, such as pipelines and <strong>embedding</strong> algorithms, we learn how to make predictions on a graph dataset, using both node classification and link prediction techniques.</li><li><strong>Extend the GDS with Pregel API</strong>: an implementation of <strong>PageRank</strong> is shown, including unit tests.</li></ol><p>In the next section, I’ll try to explain why you may want to read this book now.</p><h3>Why reading it today?</h3><p>Depending on whether you have already read my first book, <em>Hands-On graph Analytics with Neo4j </em>(<em>HOGAN</em>) or not, here are the reasons that could make you choose to read this newly released book.</p><h4>Option A: you are new to the field of graph data science</h4><p>In other words, you have not read <em>Hands-On Graph Analytics with Neo4j</em>. Then it is probably better for you to start from the most up-to-date book, since all code is running with the latest versions of the software used in the book (Neo4j and GDS mainly).</p><p>Compared to other books on the same topic on the market, the approach is oriented towards the “how”, rather than the “what”, in a beginner-friendly way.</p><h4>Why HOGAN is still worth a read?</h4><p><em>HOGAN </em>was released in 2020<em>.</em> It was already relying on the Neo4j Graph Data Science library. A large part of it was dedicated to algorithm understanding, the reader was guided through a few implementations of PageRank or Louvain algorithms. In the latest book <em>GDSN</em>, this part has been reduced, and only a few lines are talking about the PageRank algorithm in the last chapter, when we implement it using the Pregel API. So, if you are interested in a deeper understanding of these algorithms, you can have a look at chapters 6 (for centrality algorithms) and 7 (for community detection algorithms) of <em>HOGAN</em>.</p><p>Note that <em>HOGAN</em> chapter 4 about spatial data is partly outdated and has not been updated in the new book. Maybe room for some future blog posts.</p><h4>Option B: you have already read HOGAN</h4><p>In this case, you will find some overlapping between the two books, which are about very similar topics. I would not recommend reading <em>GDSN</em> from end-to-end, since you will find a lot of content you already know about. However, the following chapters cover really new topics, that you may find interesting:</p><ul><li><strong>Chapter 5</strong>: Visualizing Graph Data: covers tools like Neo4j Bloom and Gephi</li><li><strong>Chapter 6</strong>: Building a Machine Learning Model with Graph Features: use of the GDS Python client</li><li><strong>Chapter 8</strong>: Building a GDS Pipeline for Node Classification Model Training: introduction to pipelines in the GDS</li><li><strong>Chapter 10</strong>: Writing your Custom Graph Algorithm with the Pregel API in Java: how to extend the GDS by writing your own message passing algorithm.</li></ul><p>If you have any remaining question, please feel free to reach out to me, I’ll try to guide you as best as I can.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e7f32cfa41cc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Writing Custom Procedures for Neo4j]]></title>
            <link>https://medium.com/@st3llasia/writing-custom-procedures-for-neo4j-d20e28dc7afe?source=rss-506d892fb653------2</link>
            <guid isPermaLink="false">https://medium.com/p/d20e28dc7afe</guid>
            <category><![CDATA[neo4j]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[cypher]]></category>
            <dc:creator><![CDATA[Estelle Scifo]]></dc:creator>
            <pubDate>Fri, 25 Nov 2022 11:21:57 GMT</pubDate>
            <atom:updated>2022-11-25T11:21:57.141Z</atom:updated>
            <content:encoded><![CDATA[<h4>Extend Neo4j with your own plugin to add custom features. Compatible with Neo4j 5.0!</h4><p>This is the first part of a series where we investigate how to extend Neo4j through custom plugins. In this first part, we will write a generic Neo4j plugin to compute simple quantities.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_nvLAWljknAj9Qz8oeGtcA.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@rishabhdharmani?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Rishabh Dharmani</a> on <a href="https://unsplash.com/s/photos/puzzle-missing-piece?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><blockquote><strong>Caveat</strong>: Plugins for Neo4j needs to be written in Java, which is not the language I use day to day. That means that Java experts will likely find some weird stuffs in the code below, apologies in advance (btw, I’d love to get your feedback on how to improve this weirdness).</blockquote><h3>Neo4j Plugins</h3><p>If you have already used Neo4j, you’ve probably already head about plugins. The most famous one is <strong>APOC</strong>, that’s so useful that it is bundled with the official Neo4j Docker image. Two other famous plugins are the <strong>neosemantics</strong> plugin to deal with RDF data, and the <strong>Graph Data Science library</strong>, for graph analytics (and much more).</p><p>In practice, plugins are JAR files that needs to be placed in the plugins folder of the Neo4j database. These JAR files are automatically loaded at startup, and immediately available from Cypher. For instance, the following Cypher query is using the APOC function to capitalize the first letter of the input string:</p><pre>RETURN<strong> </strong><a href="https://neo4j.com/labs/apoc/4.3/overview/apoc.text/apoc.text.capitalize/"><strong>apoc.text.capitalize</strong></a><strong>(&quot;my text&quot;)</strong></pre><p>In order for this process to work, of course, the plugin needs to follow some conventions, namely it needs to use the Neo4j Java API, so that Neo4j can find the relevant information on startup and when calling the custom functions.</p><h3>The plugin public API</h3><p>So, how do we write a Neo4j plugin? It is actually quite simple, as usual when you know the recipe :) Almost everything is managed through specific class and attribute annotations, which take care of registering your Java method as a Neo4j function or procedure, with the proper input parameters and return types.</p><h4>Difference between function and procedure</h4><p>Before going further, let’s clarify an important detail: the distinction between a function and a procedure for Neo4j, since they will be implemented slightly differently:</p><ul><li><strong>Functions</strong>: they are “simple”, take one or more parameters and return <strong>a single value</strong>.</li><li><strong>Procedures</strong>: on the other hand can return a stream of results. It will become clearer in the last section of this story, where we’ll see an example.</li></ul><h4>Getting started</h4><p>Let’s get started and add required dependencies in the pom file:</p><pre># pom.xml<br>&lt;dependency&gt;<br>  &lt;groupId&gt;org.neo4j&lt;/groupId&gt;<br>  &lt;artifactId&gt;neo4j&lt;/artifactId&gt;<br><strong>  &lt;version&gt;5.1.0&lt;/version&gt;</strong><br>  &lt;scope&gt;provided&lt;/scope&gt;<br>&lt;/dependency&gt;<br><br>&lt;dependency&gt;<br>  &lt;groupId&gt;org.neo4j&lt;/groupId&gt;<br>  &lt;artifactId&gt;procedure-compiler&lt;/artifactId&gt;<br><strong>  &lt;version&gt;5.1.0&lt;/version&gt;</strong><br>  &lt;optional&gt;true&lt;/optional&gt;<br>&lt;/dependency&gt;</pre><p>Here is the project structure, we are going to add code to the Price class:</p><pre>src/<br>├── main<br>│   └── java<br>│       └── neoplus<br>│           ├── Price.java</pre><p>We’ll start by creating a simple function that computes a discounted price based on a price and discount (%) in the Price class.</p><h3>A custom function with two parameters</h3><p>In order to understand how functions work, we are going to use a simple example. Imagine you are storing somehow product information into nodes. Each product has a fixed price, but sometimes, you want to grant some discount on the product. In these cases, a discount property will be attached to the product node as well as a price property. Our task is to compute the discounted price. We will assume that discount is a percentage between 0 and 100, and this assumption is upstream in our application.</p><p>Let’s first create a few nodes to play with in Neo4j:</p><pre>CREATE (:Product {pid: 1, price: 100.0, discount: 0})<br>CREATE (:Product {pid: 2, price: 200.0, discount: 15})<br>CREATE (:Product {pid: 3, price: 150.0, discount: 10})<br>CREATE (:Product:Featured {pid: 4, price: 200.0, discount: 30})</pre><p>We can compute the discounted price with the following Cypher:</p><pre>MATCH (p:Product)<br>RETURN price * (1 - discount / 100) as discountedPrice</pre><p>But in this story, we’ll learn how to extract this piece of business logic into a Neo4j plugin. Plugins need to be written in Java, so here is a Java method that performs the same computation, still assuming discount is a percentage between 0 and 100:</p><pre>public Double computeDiscountedPrice(<br>        Double price,<br>        Double discount<br>) {<br>    if (price == null || discount == null) {<br>        return null;<br>    }<br>    return price * (1 - discount/100);<br>}</pre><p>In order to turn this method into a custom function, we just need to add annotations. To keep the code cleaner and split the neo4j-related stuff from the “logic”, let me create a new method, and add the annotations there:</p><pre><strong>@UserFunction</strong><br>public Double <strong>discountedPrice</strong>(<br>        @Name(&quot;price&quot;) Double price,<br>        @Name(&quot;discount&quot;) Double discount<br>) {<br>    return computeDiscountedPrice(price, discount);<br>}</pre><p>You can already compile this code (e.g. using mvn clean package), and copy the generated JAR file (you’ll find it in the target folder) into a Neo4j database plugins directory. After restarting the database, your function is now usable from Cypher. Type for instance the following query in Neo4j Browser:</p><pre>RETURN neoplus.<strong>discountedPrice</strong>(100.0, 10.0)</pre><p>It returns a single value, corresponding to the discounted price. We can use the function to compute the discounted price for all our product nodes, as we did in the first query of this story:</p><pre>MATCH (p:Product)<br>RETURN neoplus.discountedPrice(p.price, p.discount)</pre><p>That’s already pretty cool, isn’t it?</p><p>Now, let’s go a bit deeper. Instead of extracting node properties from Cypher, we will do it from Java.</p><h3>A custom function with input nodes</h3><p>We can slightly modify the above function to take a node as input, and read price and discount values from its property list:</p><pre><strong>@UserFunction(name = &quot;neoplus.discountPriceForNode&quot;)</strong><br>public Double getDiscountedPrice(<br><strong>        @Name(&quot;node&quot;) Node node</strong><br>) {<br><strong>    Double price = (Double) node.getProperty(&quot;price&quot;);</strong><br><strong>    Double discount = (Double) node.getProperty(&quot;discount&quot;);</strong><br>    return this.discountedPrice(price, discount);<br>}</pre><p>Compared to our previous function, we have changed a few things:</p><ul><li>First, we specify a name for the function in Cypher, that will be called neoplus.discountPriceForNode (and not neoplus.getDiscountPrice, which is the name of the Java method, used by default if no name is specified)</li><li>The parameter type has been changed to Node</li><li>We are retrieving the node properties with the node.getProperty(&lt;PropertyName&gt;) method.</li></ul><p>This function is used in the following way:</p><pre>MATCH (p:Product {id: 1})<br>RETURN neoplus.discountedPriceForNode(p) AS discountedPrice</pre><p>When multiple nodes match the first expression, the discountedPricreForNode function will be called once per node. Check it by running the following query:</p><pre>MATCH (p:Product)<br>RETURN p.pid AS pid, neoplus.discountedPriceForNode(p) AS discountedPrice</pre><p>The result looks like this:</p><pre>╒═════╤═════════════════╕<br>│&quot;pid&quot;│&quot;discountedPrice&quot;│<br>╞═════╪═════════════════╡<br>│1    │100.0            │<br>├─────┼─────────────────┤<br>│2    │170.0            │<br>├─────┼─────────────────┤<br>│3    │135.0            │<br>├─────┼─────────────────┤<br>│4    │140.0            │<br>└─────┴─────────────────┘</pre><p>Let’s continue and add more functionalities to our Java code. What if the MATCH could be done there as well?</p><h3>Creating a procedure to compute price for all nodes</h3><p>Procedures are slightly more complex than functions, in the sense that they return more complex results, usually multiple rows and sometimes multiple columns. A procedure result is represented by a class. Each class attribute corresponds to a “column” of the result set, while each row in the result stream will be an instance of that class. For our case, we will create the following Result class to hold the discounted price computation:</p><pre>public static class Result {<br>    public Node node;<br>    public double discountPrice;<br><br>    public Result(Node node, Double discountPrice) {<br>        this.node = node;<br>        this.discountPrice = discountPrice;<br>    }<br>}</pre><p>The method that performs the computation and returns the result stream is the following:</p><pre>@Context<br>public Transaction tx;</pre><pre><strong>@Procedure(name = &quot;neoplus.discountedPriceForLabel&quot;, mode=Mode.READ)</strong><br>@Description(&quot;Computes discounted price for all nodes with a given label&quot;)<br>public <strong>Stream&lt;Result&gt;</strong> priceForLabel(<br>        @Name(&quot;label&quot;) String label,<br>        @Name(&quot;priceProperty&quot;) String priceProperty,<br>        @Name(&quot;discountProperty&quot;) String discountProperty,<br>        @Name(&quot;defaultDiscountValue&quot;) Double defaultDiscountValue<br>) {<br>    return tx.findNodes(Label.<em>label</em>(label)).stream().map(<br>            n -&gt; {<br>                Double price = (Double) n.getProperty(priceProperty);<br>                Double discount = defaultDiscountValue;<br>                try {<br>                    discount = (Double) n.getProperty(discountProperty);<br>                } catch (Exception ignored) {<br>                }<br>                <strong>return new Result</strong>(n, this.discountedPrice(price, discount));<br>            });<br>}</pre><p>If we detail the code, we are:</p><ol><li>Defining a transaction object, that will be created by Neo4j, we do not have to worry about it that much at that stage.</li><li>Defining a custom procedure, whose name (within Cypher) will be neoplus.discountedPriceForLabel) and that returns a stream of Result , Result here being the class we discussed earlier.</li><li>Defining our computation method with four parameters: the node label that we will seek for, the name of the properties holding the price and the discount and a default value for the discount in case there is not such property on the node</li><li>Then, thanks to the transaction, we are fetching all nodes matching the provided label</li><li>For each of these nodes, we extract the price property and we try to extract the discount property. If this discount does not exist, then we fallback on the defaultDiscountValue. Then, we can return an instance of the Result class, holding the node object together with the newly computed discounted price.</li></ol><p>After rebuilding the project and replacing the JAR file, we can use the procedure thanks to the Cypher CALL statement, like this:</p><pre><strong>CALL neoplus.discountedPriceForLabel(<br>    &quot;Product&quot;, &quot;price&quot;, &quot;discount&quot;, 0<br>)<br>YIELD node, discountedPrice<br></strong>RETURN node.pid, discountedPrice</pre><p>Inside the YIELD , we have to use the “column” names as defined in our Result class. The result of this query are similar to the previous one, using the neoplus.discountedPriceForNode function.</p><p>Last, you can check that the label filter is working fine, by replacing the &quot;Product&quot; label in the preceding query with &quot;Featured&quot; . Only the product with pid=4 will be returned, since it’s the only node having the Featured label.</p><p>And that’s it for now!</p><h3>Conclusion</h3><p>In this story, you’ve learned how to write your own functions and procedures to extend Neo4j with a custom plugin. We used here a toy example which we could more easily do with pure Cypher, but the fact that the plugins let you use any Java code makes them super powerful and the possibilities are infinite. You can extend the Cypher capabilities to match your own business requirements.</p><p>Hope you had fun and it gave you some ideas about how to take advantage of this feature for your own projects!</p><p>The code for this story is available in the following repository:</p><p><a href="https://github.com/stellasia/neoplus">GitHub - stellasia/neoplus: A test project to build custom Cypher procedure for Neo4j</a></p><p>In the following stories, we will write custom algorithms and create a plugin for the GDS library using the Pregel API to take advantage of all the amazing work done by the GDS team regarding projected graph, stream/write modes, etc.</p><p>Stay tuned!</p><h3>Further Resources &amp; Readings</h3><ul><li>The Neo4j documentation: <a href="https://neo4j.com/developer/cypher/procedures-functions/#_extending_cypher">https://neo4j.com/developer/cypher/procedures-functions/#_extending_cypher</a>, <a href="https://neo4j.com/docs/java-reference/current/extending-neo4j/procedures/#user-defined-procedures">https://neo4j.com/docs/java-reference/current/extending-neo4j/procedures/#user-defined-procedures</a>, <a href="https://github.com/neo4j-examples/neo4j-procedure-template">https://github.com/neo4j-examples/neo4j-procedure-template</a></li><li>“Superchage Neo4j with Plugins” by <a href="https://medium.com/u/e5a52ceb0b7c">Max De Marzi</a> (<a href="https://maxdemarzi.com/2012/11/26/extending-neo4j/">https://maxdemarzi.com/2012/11/26/extending-neo4j/</a>)</li><li>Explore the <a href="https://github.com/stellasia/neoplus/tree/master/src/test/java/neoplus">tests</a> folder to see how to test the functions and procedures</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d20e28dc7afe" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Using Weaviate to Find Similar Images]]></title>
            <link>https://medium.com/@st3llasia/using-weaviate-to-find-similar-images-caddf32eaa3f?source=rss-506d892fb653------2</link>
            <guid isPermaLink="false">https://medium.com/p/caddf32eaa3f</guid>
            <category><![CDATA[weaviate]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[opencv-python]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[computer-vision]]></category>
            <dc:creator><![CDATA[Estelle Scifo]]></dc:creator>
            <pubDate>Fri, 29 Apr 2022 17:12:58 GMT</pubDate>
            <atom:updated>2022-04-29T17:12:58.111Z</atom:updated>
            <content:encoded><![CDATA[<h4>Vector database in action to identify stamps</h4><figure><img alt="An English stamp on an enveloppe" src="https://cdn-images-1.medium.com/max/1024/1*wDGQ5ymYMjNiSrmGSd5QxA.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/es/@brett_jordan">Brett Jordan</a> on <a href="https://unsplash.com/s/photos/stamp">Unsplash</a>.</figcaption></figure><h3>Problem statement</h3><p>I had a long-lasting idea of building a machine learning powered tool to identify stamps in my collection from an image of them (picture or scan). The final goal would be to do an estimation of a collection from pictures of album pages for instances.</p><p>I quickly wanted to extract a vector representation of images (an embedding), but didn’t know how to do efficient pairwise comparison to find the closest image.</p><blockquote><strong>Disclaimer</strong>: this is probably the first time I have to deal with image data, so be indulgent! If you find any bad practice while reading this story, kindly let me know in a comment. Thanks.</blockquote><p>A few months ago, I discovered <a href="https://weaviate.io/">Weaviate</a> at a conference and it seems to be a good candidate to fix the above issue. Let’s see how we can use it to identify stamps from a picture.</p><h3>You said “Weaviate”?</h3><p>Weaviate defines itself as:</p><blockquote>an open source vector search engine that stores both objects and vectors, allowing for combining vector search with structured filtering with the fault-tolerance and scalability of a cloud-native database.</blockquote><p>It is an awesome le tool for NLP, letting users ask questions with a GraphQL-like syntax, and get incredibly relevant result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*52xQpmaQ2p4h02jVcDSEZw.gif" /><figcaption>Image from the Weaviate GitHub repository: <a href="https://github.com/semi-technologies/weaviate">https://github.com/semi-technologies/weaviate</a></figcaption></figure><p>In short, weaviate will store the vector representation of your observation, and use it when performing queries, so that you can easily find close vectors. Sounds interesting? Bare with me then!</p><h3>Dataset</h3><p>For this task, I have extracted a few images from a stamp listing website. Since this is only a proof of concept, I have not spent time on scraping scripts and so on, just downloaded images manually. Here is a sample of the dataset used:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z3JaTH6FkPAAjUelF-JNrA.png" /><figcaption>Example data</figcaption></figure><p>It contains around 200 stamps with various sizes, orientations, colors… Not a large dataset, but it is good enough for a first prototyping.</p><h3>Show me the code</h3><p>Let’s stop talking and actually build stuff. We’ll be using Jupyter notebooks and… weaviate. I assume you know how to install and start Jupyter, but let’s see how to setup Weaviate on your local machine.</p><h4>Firing-up Weaviate in Docker</h4><p>Weaviate is super easy to setup since you’ll only need docker compose to be installed on your machine.</p><p>Following this <a href="https://weaviate.io/developers/weaviate/current/retriever-vectorizer-modules/img2vec-neural.html">tutorial</a>, I have used the following docker-compose.yml file:</p><pre># docker-compose.yml<br>version: &#39;3.4&#39;<br>services:<br>  weaviate:<br>    command:<br>    - --host<br>    - 0.0.0.0<br>    - --port<br>    - &#39;8080&#39;<br>    - --scheme<br>    - http<br>    image: semitechnologies/weaviate:1.12.2<br>    ports:<br>    - 8080:8080<br>    restart: on-failure:0<br>    environment:<br>      IMAGE_INFERENCE_API: &#39;http://i2v-neural:8080&#39;<br>      QUERY_DEFAULTS_LIMIT: 25<br>      AUTHENTICATION_ANONYMOUS_ACCESS_ENABLED: &#39;true&#39;<br>      PERSISTENCE_DATA_PATH: &#39;/var/lib/weaviate&#39;<br>      DEFAULT_VECTORIZER_MODULE: &#39;img2vec-neural&#39;<br>      ENABLE_MODULES: &#39;img2vec-neural&#39;<br>      CLUSTER_HOSTNAME: &#39;node1&#39;<br>  i2v-neural:<br>    image: semitechnologies/img2vec-pytorch:resnet50<br>    environment:<br>      ENABLE_CUDA: &#39;0&#39;</pre><p>Then simply run:</p><pre>docker-compose up</pre><p>And your Weaviate container will be up and running after a few minutes depending on your internet connection.</p><p>Once started, it exposes endpoints to interact with the database schema and the data it contains. You can for instance inspect the data schema with the following command:</p><pre>curl -s <a href="http://localhost:8080/v1/schema">http://localhost:8080/v1/schema</a></pre><p>But in the rest of this story, I’ll use the <a href="https://pypi.org/project/weaviate-client/">Python client</a> for convenience, which can be installed with pip:</p><pre>pip install weaviate-client</pre><p>First thing is to instantiate a new client. With the above configuration, it is as simple as:</p><pre>import weaviate</pre><pre>client = weaviate.Client(&quot;<a href="http://localhost:8080/">http://localhost:8080</a>&quot;)</pre><p>We’ll use this client in the following sections to define the database schema, insert data and perform searches.</p><h4>Creating the class to store Stamps</h4><p>In order to add data to our database, we have to define its schema, made of a name, list of properties and the information Weaviate needs to be able to vectorize the objects. Here is our definition of the “Stamp” class:</p><pre>def define_schema(client):<br>    class_obj = {<br>       &quot;class&quot;: &quot;Stamp&quot;,<br>       &quot;description&quot;: &quot;Stamp with an image blob and a path to the image file&quot;,  <br>       &quot;properties&quot;: [<br><strong>            {<br>                &quot;dataType&quot;: [<br>                    &quot;blob&quot;<br>                ],<br>                &quot;description&quot;: &quot;Image&quot;,<br>                &quot;name&quot;: &quot;image&quot;<br>            },</strong><br>            {<br>                &quot;dataType&quot;: [<br>                    &quot;string&quot;<br>                ],<br>                &quot;description&quot;: &quot;&quot;,<br>                &quot;name&quot;: &quot;path&quot;<br>            }<br>            <br>        ],<br>        &quot;vectorIndexType&quot;: &quot;hnsw&quot;,<br><strong>        &quot;moduleConfig&quot;: {<br>            &quot;img2vec-neural&quot;: {<br>                &quot;imageFields&quot;: [<br>                    &quot;image&quot;<br>                ]<br>            }<br>        },<br>        &quot;vectorizer&quot;: &quot;img2vec-neural&quot;</strong><br>    }<br>    <br>    client.schema.create_class(class_obj)<br></pre><pre>define_schema(client)</pre><p>We create a class named “Stamp”, with two properties (think “columns” in SQL):</p><ul><li>the image path on disk (not necessary, just stored for convenience)</li><li>we’ll need to store the b64-encoded image as blob, so we create the image property of type blob</li></ul><p>We also tell weaviate that the blob is the image property (in case there as several of them). Finally, we specify which encoder has to be used to vectorize each data point, here the img2vec-neural encoder. Each time we insert data into the “Stamp” collection, weaviate will take the data in the image field and extract its vector representation thanks to the model img2vec-neural . This vector will be saved internally, so that it can be used for queries. But let’s try not to skip steps. In the next section, we are going to insert some data in the database.</p><h4>Importing data</h4><p>In order to import data, we’ve put all stamp images we downloaded into the data/stamps folder.</p><p>Stamp images as the ones displayed on the previous image have various sizes and shapes. In order for them to be “comparable”, I apply a preprocessing treatment in order to “standardize” their size, using the Python OpenCV package.</p><pre>import os<br>import cv2  # opencv-python package<br>import uuid<br>import base64</pre><pre>DATA_DIR = &quot;data/stamps&quot;<br>IMAGE_DIM = (100, 100)<br></pre><pre>def _prepare_image(file_path):<br>    img = cv2.imread(file_path)<br>    # resize image<br>    resized = cv2.resize(img, IMAGE_DIM, interpolation= cv2.INTER_LINEAR)<br>    return resized</pre><p><em>Note: in a first version, I had converted images to grayscale in the preparation step, but it seems to be counter productive and lead to lowest prediction scores.</em></p><p>Once the image is prepared, we can extract its base 64 encoding, and insert data in Weaviate:</p><pre>def insert_data(client):<br>    for file_name in os.listdir(DATA_DIR):<br>        file_path = os.path.join(DATA_DIR, file_name)<br>        img = _prepare_image(file_path)</pre><pre>        # encode image as base64 string<br>        jpg_img = cv2.imencode(&#39;.jpg&#39;, img)<br>        b64_string = base64.b64encode(jpg_img[1]).decode(&#39;utf-8&#39;)</pre><pre>        # define properties as expected by the class definition<br>        data_properties = {<br>            &quot;path&quot;: file_name,<br>            &quot;image&quot;: b64_string,<br>        }</pre><pre>       # create data of type &quot;Stamp&quot; with a random UUID<br>       r = client.data_object.create(<br>            data_properties, <br>            &quot;Stamp&quot;, <br>            str(uuid.uuid4())<br>        )<br>        print(fp, r)<br></pre><pre>insert_data(client)</pre><p>Our database now contains some data, let’s try and use them to find stamps from a picture.</p><h4>Finding similar images</h4><p>When users upload their pictures, it won’t necessarily be well centered and oriented. Before we can compare the image to the ones in our database, we need to clean it.</p><p><strong>Image cleaning</strong></p><p>Image cleaning is done by the clean_image function reproduced below. After converting the image to gray scale, we look for the greatest contour and crop the image to it, then we resize the cropped image so that it matches the size of the images in our database:</p><pre>def clean_image(image_path, tmp_file_name=&quot;test_image.jpg&quot;):<br>    # convert to gray scale<br>    gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)</pre><pre>    _, thresh = cv2.threshold(gray, 180, 255, cv2.THRESH_BINARY_INV)<br>    contours, _ = cv2.findContours(thresh, cv2.RETR_LIST, cv2.CHAIN_APPROX_NONE)<br>    # find largest contour<br>    cnt = max(contours, key=cv2.contourArea)</pre><pre>    # crop image based on the largest contour<br>    x, y, w, h = cv2.boundingRect(cnt)<br>    cropped_contour = img[y:y+h, x:x+w]</pre><pre>    # resize (same size as train data)<br>    resized = cv2.resize(cropped_contour, (100, 100), interpolation= cv2.INTER_LINEAR)</pre><pre>    return img, resized</pre><p>Finally, the function returns the initial and prepared image, so that we can visualize them together. An example output is show below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/454/1*QovRHSt0iR0OyMtJnmuwag.png" /><figcaption>Image transformation: cropping and resizing</figcaption></figure><p><strong>Searching the database</strong></p><p>In order to search for the most similar image in the database, we’ll build a Weaviate query using the Python client:</p><pre>def search(client, test_image_path):</pre><pre>    # prepare query and payload<br>    near_image = {<br>        &quot;image&quot;: tmp_file_name,<br>    }<br>    query = client.query.get(<br><strong>        &quot;Stamp&quot;,  # get data from class &quot;Stamp&quot;<br>        [&quot;path&quot;]  # return the &quot;path&quot; property<br></strong>    )<br><strong>    .with_near_image(<br>        near_image   # find &quot;Stamp&quot; close to img in embedding space<br>    )<br></strong>    .with_limit(3)  # limit result to first 3 best matches</pre><pre>    # perform query<br>    res = query.do()</pre><pre>    # return results<br>    # (res is a dict following GraphQL syntax)<br>    return res[&quot;data&quot;][&quot;Get&quot;][&quot;Stamp&quot;]</pre><p>We can then use the last two functions in combination:</p><pre># read test image and transform it<br>test_image = os.path.join(TEST_DIR, &quot;photo.jpg&quot;)<br>_, prepared = clean_image(test_image)</pre><pre># save prepared image into a tmp file<br>test_image_prepared = &quot;test_image.jpg&quot;<br>cv2.imwrite(test_image_prepared, prepared)</pre><pre># perform query<br>res = search(client, test_image_prepared)<br>print(res)</pre><h3>Results</h3><p>The following images show a few results, obtained by comparing stamp pictures from my collection to the train data using the procedure described above.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XOLa-KRmASaNu0zQeNUjLQ.png" /><figcaption>Search result from the “student” stamp</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HiG7CadfpWwA9jCeBqv8Sw.png" /><figcaption>Search result for the “Claudine” stamp (character from a series of novels by Colette)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OTF_MCUdZ6qx71t_uO-x1A.png" /><figcaption>Search result for Michelangelo sculpture</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9FmVnR98WQ9DMIXsXZwGNw.png" /><figcaption>Search result for the comic “Blake and Mortimer — The Yellow Mark”</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*33fwwz0cWOX2KN8ZpRXSTw.png" /><figcaption>Search result for Marilyn by Andy Warhol</figcaption></figure><p>While we can see from the “Cleaned” image that the data preparation and image cleaning process can be improved (see next section), the results already look quite promising.</p><h3>Next steps</h3><p>This is a very simple approach, which, is a real-life project, won’t be ready yet for production. Here are some ideas to improve it and make it user-friendly:</p><ol><li>Improve image preparation: the tests performed here are done with pictures I have taken myself, so showing the full stamp in the proper orientation, that won’t be always the case! Image preparation needs to be improved: for instance, taking the largest contour is probably not the best option.</li><li>Extend the training dataset: right now, the train dataset contains few observation (about 200), we can use web scraping to download more images and more information about the stamps.</li><li>Create metric to evaluate model: perhaps labeling test images?</li><li>Add more filters: maybe users already know the year the stamp was issued or the country it comes from? Usually, both information are written on the stamp itself, so we can also try and improve our CV approach to read this information from the stamp, which would considerably reduce the possible matches.</li><li>Build UI for users to find out their stamps from a picture: users usually don’t use notebooks :)</li></ol><p>If you want to play with the code, the notebooks used in this story are available on <a href="https://github.com/stellasia/stamp-identifier">GitHub</a>.</p><h3>Going further</h3><p>In addition to the inline links, you can explore the following resources to learn more about this topic:</p><ul><li>Weaviate documentation: <a href="https://weaviate.io/developers/weaviate/current/">https://weaviate.io/developers/weaviate/current/</a></li><li>The restnet50 model: <a href="https://towardsdatascience.com/understand-and-implement-resnet-50-with-tensorflow-2-0-1190b9b52691">https://towardsdatascience.com/understand-and-implement-resnet-50-with-tensorflow-2-0-1190b9b52691</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=caddf32eaa3f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[6 reasons to write a tech book]]></title>
            <link>https://medium.com/@st3llasia/6-reasons-to-write-a-tech-book-bf4a77a64106?source=rss-506d892fb653------2</link>
            <guid isPermaLink="false">https://medium.com/p/bf4a77a64106</guid>
            <category><![CDATA[growth]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[writing]]></category>
            <dc:creator><![CDATA[Estelle Scifo]]></dc:creator>
            <pubDate>Wed, 13 Apr 2022 16:05:24 GMT</pubDate>
            <atom:updated>2022-04-13T16:05:24.349Z</atom:updated>
            <content:encoded><![CDATA[<h4>The reasons why I decided to write my first technical book, and I loved it</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3zYAILMN_OwNsG2JoO006A.jpeg" /><figcaption>Source: <a href="https://unsplash.com/photos/PeUJyoylfe4">https://unsplash.com/photos/PeUJyoylfe4</a></figcaption></figure><p>In 2019, a publisher offered me to write a technical book. After the first “WOW, that would be such a great experience!”, many questions came to my mind such as “Am I really good enough to write on this topic?”, “Can I find enough material in a relatively short amount of time (a few months)?”, or said differently: “Do I have enough experience to share?”. Here are the reasons why I have finally accepted the offer.</p><h3>1. Share your Passion</h3><p>We all have something that makes us get up in the morning, and about which we could talk for hours, whether it is your job, your favorite sport or artist. This topic is important for you and writing a book is the opportunity for you to let everybody know <em>why it matters</em> so much. In tech, it can be a specific language or framework, code best practice, how to be a good leader… The list of topics is endless!</p><h3>2. Go out of your comfort zone!</h3><p>Writing puts you in a totally different position. From user, you become teacher. In other words, you go from your comfort zone, consisting in what you do all day, to the outside: telling a story about this.</p><p>Doing something new is stressful in some way, but it is an incredible way to learn, grow, both professionally (hard skills) and on a human perspective (soft skills). You learn where your limits are, and, most of the time, you push them forward.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vsABx0Q_hlQDaZFth9b4UA.png" /><figcaption>Source: <a href="https://theyellowspot.com/blogs/is-comfort-zone-really-that-comfortable/">https://theyellowspot.com/blogs/is-comfort-zone-really-that-comfortable/</a></figcaption></figure><p>How is writing a book a big challenge? Writing is a challenge by itself, building a story so that readers can go from the beginning to the end, staying focused and understanding each step is not easy! But as for any exercise, the more you practice, the better you get at the exercise, and the easiest the exercise becomes.</p><p>If the step is too high, start by writing small blog posts. Then develop them, create series of posts. Ask reviews and feedback to your friends or colleagues at each step. You’ll see that the book is not too far away.</p><h3>3. Defeat the “Impostor syndrome”?</h3><p>You probably don’t have a PhD on the topic you choose to write about, maybe you haven’t written a single line of code in that framework?</p><p>But still, you are not an imposter. How do I know? Look at the following image:</p><h3>JavaScript is not available.</h3><p></p><p>Basically, I translate it like this: we can find a better expert for any of the topics covered in the book, but <strong>the range of topics covered is unique to you,</strong> your experience and your understanding of a field. Chosen parts of this experience are organized for the highest benefit of the readers. Even experts, in one or the other topic, will be able to learn something new about another topic.</p><h3>4. Teaching is learning</h3><p>When you’ll start creating the draft outline of your book or story, you’ll start by defining who your target audience is and you’ll have to think carefully about what they already know, what are the problems they have, how they are solving them for now (if they are)… You’ll put yourself in the <strong>beginner’s mind:</strong> try and remind you how you started, what is the path you followed to understand the topic. It will also make you realize the number of pain-points you manage to solve to arrive at a certain level of expertise (and part of solve point number 3, the imposter syndrome!).</p><p>On a personal basis, remember that:</p><blockquote>Teaching is the highest form of understanding.<br>–Aristotle</blockquote><p>Being able to explain how things work is the best proof of understanding ever.</p><blockquote>Preparing a course is a good opportunity to ask yourself “Why?”.</blockquote><p>Why am I always declaring my variables as const? Why am I using this package installer and not another? Why am I organizing my source files the way they are? Why…</p><p>It will force your to look for references, review some documentation… And either be convinced that you do it the right way, or change your way of doing!</p><p>So, writing a book, you will teach yourself at least in two ways:</p><ul><li>By organizing ideas and remembering the initial pain points, the problems to be solved;</li><li>With the “Why” questioning, again going back to the roots of the problem.</li></ul><h3>5. Challenge your understanding with reviewers</h3><p>It is also a good opportunity to contact other field experts and ask some questions you have. Remember that there is nothing to be ashamed of.</p><p>Before publishing your book, I’ll highly encourage you to choose reviewers who will help you check the book consistency, technical details, typos and so on and so forth. It is an amazing opportunity to contact other field experts — the ones with a higher level of expertise in some particular areas — and validate your understanding.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/828/1*rJWMWY3V-KZioZ8B-p6czg.jpeg" /></figure><blockquote>Side story: after a while of coding in Python and seeing these # noqa comments without getting what they were meant to do, I decided to google it. And guess what, I found out that Guido van Rossum, the founder of Python himself, has asked this question before (<a href="https://github.com/PyCQA/pycodestyle/issues/476">source</a>). Two conclusions: 1: my question was not stupid; 2: even the founder of Python is not ashamed of asking questions, even publicly on GitHub.</blockquote><p>If you are writing with a publisher, they’ll help you choose reviewers for each aspect of the book: spelling, typography, technical review, code review… But you don’t need a publisher to get started. Tools like <a href="https://leanpub.com/">Leanpub</a> for instance let you create your book on your own, deciding on everything from layout to the final price.</p><p>But in any case, reviews are important and should not be underestimated. Embrace critics and improve yourself!</p><p>Even once the book is published, you may get customers reviews: take them into account to provide an even better experience to your readers for the second edition of your book — or the next one, now that you are used to the exercise!</p><h3>6. Be Proud of Yourself</h3><p>That moment when you finally have the book in your hands is like magic! Like with any challenge, whether it is intellectual or physical, that moment you realize you made it is pure happiness. The most important is not the new line in your resume, it’s the path towards it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/705/1*sobrZHg2m3QnpCmZ6EpUlA.jpeg" /></figure><h3>Conclusion</h3><p>There is for sure a topic you like, whether it is a programming language, a framework, a design pattern, code architecture, team organization, project planning, hardware choice… Start gathering ideas and related topics. Choose a target audience and start building an outline, step by step, you’ll see that it will evolve as you start writing anyway. Talk to people around you, colleagues, conference speakers, experts. Challenge yourself and your understanding, learn by teaching others!</p><p>********<br><em>For those interested, here is the book I have written after these considerations: “Hands-On Graph Analytics with Neo4j”, which is available to ready online on the </em><a href="https://www.packtpub.com/product/hands-on-graph-analytics-with-neo4j/9781839212611"><em>publisher website</em></a><em> and as hard-cover on </em><a href="https://www.amazon.com/gp/product/B08FBJ3B1S"><em>Amazon</em></a><em>.<br>*********</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bf4a77a64106" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Comprehensive Guide to Cypher Map Projection]]></title>
            <link>https://medium.com/neo4j/a-comprehensive-guide-to-cypher-map-projection-2622b879e886?source=rss-506d892fb653------2</link>
            <guid isPermaLink="false">https://medium.com/p/2622b879e886</guid>
            <category><![CDATA[graphql]]></category>
            <category><![CDATA[json]]></category>
            <category><![CDATA[cypher]]></category>
            <category><![CDATA[neo4j]]></category>
            <dc:creator><![CDATA[Estelle Scifo]]></dc:creator>
            <pubDate>Mon, 07 Mar 2022 10:26:54 GMT</pubDate>
            <atom:updated>2022-05-05T18:24:47.722Z</atom:updated>
            <content:encoded><![CDATA[<h4>Let Neo4j Format Your Cypher Result as a Ready-to-Use JSON Object for GraphQL or Object-Graph Mapping Applications</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OMahKfESz53AOBDp7PCl0w.jpeg" /><figcaption>Credits: <a href="https://unsplash.com/photos/qDG7XKJLKbs">https://unsplash.com/photos/qDG7XKJLKbs</a></figcaption></figure><p><a href="https://neo4j.com/developer/cypher/">Cypher</a> is a visual graph query language used by the Neo4j graph database. It lets you write very precise pattern matching queries like:</p><pre>MATCH (movie:Movie {title: “The Matrix”})<br>       &lt;-[:ACTED_IN]-(person:Person)<br>WHERE person.born &gt; 1960<br>RETURN person</pre><p>This returns the people who acted in the movie “The Matrix” and were born after 1960.</p><p>But a lesser known feature also allows you to determine with equal precision what gets returned by the query in a JSON format similar to a GraphQL output. This post is all about this fantastic feature.</p><h3>The “Classical” Return Statement and Its “Drawbacks”</h3><p>Let’s start from a very simple example:</p><pre>MATCH (movie:Movie {title: “The Matrix”})<br>RETURN movie</pre><p>If you run this query, you’ll get a node object, whose representation looks like the following (this is the result as displayed in the Neo4j Browser — you may have different results if running the query through a specific driver):</p><pre>{<br>  &quot;identity&quot;: 0,<br>  &quot;labels&quot;: [<br>    &quot;Movie&quot;<br>  ],<br>  &quot;properties&quot;: {<br>&quot;tagline&quot;: &quot;Welcome to the Real World&quot;,<br>&quot;title&quot;: &quot;The Matrix&quot;,<br>&quot;released&quot;: 1999<br>  }<br>}</pre><p>That’s fine, but maybe your application does not need the tagline? It’d be better to exclude this field in order to reduce the size of data transferred. Then you can replace the preceding return statement with:</p><pre>RETURN movie.title, movie.released</pre><p>The result here is quite different: instead of a single column containing a JSON element, you end up with a two-column result:</p><pre>╒═════════════╤════════════════╕<br>│&quot;movie.title&quot;│&quot;movie.released&quot;│<br>╞═════════════╪════════════════╡<br>│&quot;The Matrix&quot; │1999            │<br>└─────────────┴────────────────┘</pre><p>If you also want to retrieve the actors involved in this movie in the same query, you have to write:</p><pre>MATCH (movie:Movie {title: “The Matrix”})<br>       &lt;-[:ACTED_IN]-(person:Person)<br>RETURN movie.title, movie.released, person.name</pre><p>This returns a table with a lot of duplicate information:</p><pre>╒═════════════╤════════════════╤════════════════════╕<br>│&quot;movie.title&quot;│&quot;movie.released&quot;│&quot;person.name&quot;       │<br>╞═════════════╪════════════════╪════════════════════╡<br>│&quot;The Matrix&quot; │1999            │&quot;Emil Eifrem&quot;       │<br>├─────────────┼────────────────┼────────────────────┤<br>│&quot;The Matrix&quot; │1999            │&quot;Hugo Weaving&quot;      │<br>├─────────────┼────────────────┼────────────────────┤<br>│&quot;The Matrix&quot; │1999            │&quot;Laurence Fishburne&quot;│<br>├─────────────┼────────────────┼────────────────────┤<br>│&quot;The Matrix&quot; │1999            │&quot;Carrie-Anne Moss&quot;  │<br>├─────────────┼────────────────┼────────────────────┤<br>│&quot;The Matrix&quot; │1999            │&quot;Keanu Reeves&quot;      │<br>└─────────────┴────────────────┴────────────────────┘</pre><p>The movie’s title and release date are repeated as many times as the number of actors in the movie! So, what can we do to avoid these repetitions and always return a consistent data type?</p><h3>Using Map Projection</h3><p>Map projection is a Cypher feature inspired by GraphQL. If you don’t know GraphQL, the only relevant characteristic here is the ability to customize the return fields for each query.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1SwrcODvDJ60f6vkNP6DKg.png" /><figcaption>Image from <a href="https://medium.com/neo4j/introducing-graphql-architect-19b0f2035e21">https://medium.com/neo4j/introducing-graphql-architect-19b0f2035e21</a></figcaption></figure><p>With Cypher, you can hence write:</p><pre>MATCH (movie:Movie {title: “The Matrix”}) <br>RETURN movie {.title, .released }</pre><p>This query returns a single row with a single column named movie, which contains a nicely formatted JSON:</p><pre>{<br>  &quot;title&quot;: &quot;The Matrix&quot;,<br>  &quot;released&quot;: 1999<br>}</pre><p>You can also use the wildcard * if you want to retrieve all properties of a given node, like this:</p><pre>MATCH (movie:Movie {title: “The Matrix”}) <br>RETURN movie {.* }</pre><h4>“Collecting” Results in a Single Array</h4><p>What if we have several movies matching the query? If we write:</p><pre>MATCH (movie:Movie)<br>RETURN movie { .title, .released }</pre><p>We end up with a result containing several rows, each of them similar to the above object. If you want a single JSON array, you can use collect:</p><pre>MATCH (movie:Movie)<br>RETURN collect(movie { .title, .released })</pre><p>This time, we get an array of JSON elements similar to:</p><pre>[<br>  {<br>    &quot;title&quot;: &quot;The Matrix&quot;,<br>    &quot;released&quot;: 1999<br>  },<br>  {<br>    &quot;title&quot;: &quot;The Matrix Reloaded&quot;,<br>    &quot;released&quot;: 2003<br>  },<br>....<br>]</pre><p>That’s already a nice result! But let’s go ahead and include the actors.</p><h3>Traversing Relationships</h3><p>We now want to retrieve the person who acted in a given movie. This is achieved thanks to the following MATCH statement:</p><pre>MATCH (movie:Movie {title: &quot;The Matrix&quot;})<br>       &lt;-[:ACTED_IN]-(person:Person)</pre><h4>Collecting Traversed Relationships</h4><p>Inside the map projection, you have access to previously MATCHed elements, like movie and person:</p><pre>MATCH (movie:Movie {title: &quot;The Matrix&quot;})<br>       &lt;-[:ACTED_IN]-(person:Person)<br>RETURN movie { <br>          .title, <br>          <strong>actors: collect( person { .name } )<br>       </strong>}</pre><p>In this new syntax, we add a new key called actors in the final result. The value is built by <strong>collecting</strong> all matched person for a given movie and extracting their property called name (as we did in the previous example retrieving several movies):</p><pre>{<br>  &quot;title&quot;: &quot;The Matrix&quot;,<br>  &quot;actors&quot;: [<br>    {<br>      &quot;name&quot;: &quot;Emil Eifrem&quot;<br>    },<br>    {<br>      &quot;name&quot;: &quot;Hugo Weaving&quot;<br>    },<br>    {<br>      &quot;name&quot;: &quot;Laurence Fishburne&quot;<br>    },<br>    {<br>      &quot;name&quot;: &quot;Carrie-Anne Moss&quot;<br>    },<br>    {<br>      &quot;name&quot;: &quot;Keanu Reeves&quot;<br>    }<br>  ]<br>}</pre><p>Ok, but what if the objects we want to retrieve are not in the MATCH statement?</p><h4>Traversing Relationships in the Projection (Local Scope)</h4><p>That’s not a problem, since map projection also has the ability to understand patterns. The preceding query is hence equivalent to the following one:</p><pre>MATCH (movie:Movie {title: “The Matrix”})<br>RETURN movie {<br>     .title, <br>     actors: <strong>[(movie)&lt;-[:ACTED_IN]-(person:Person) <br>                 | person { .name }<br>            ]</strong><br>}</pre><p>In the preceding example, we’ve used <a href="https://neo4j.com/docs/cypher-manual/current/syntax/lists/#cypher-list-comprehension">Cypher list comprehension</a> to parse the result. The bold part of the query actually means: “find all persons who acted in movie and for each of them, extract her name”. The result of this query is strictly identical to the result of the preceding query (the order in which the persons are returned is not guaranteed).</p><h4>Extracting Relationship Data</h4><p>Similarly to the way we retrieved related node data for Person, we can extract relationship properties. In the following query, we’re extracting the roles property of the ACTED_IN relationship between a person and a movie:</p><pre>MATCH (movie:Movie {title: “The Matrix”})<br>RETURN movie {<br>     .title, <br>     actors: [(movie)&lt;-[<strong>rel</strong>:ACTED_IN]-(person:Person) <br>                 | person { .name,<strong> roles: rel.roles }</strong><br>            ]<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bfmy8kPiMriNjLcdGU5yeg.png" /><figcaption>Result of the previous query, with relationship data extraction. Click to zoom in.</figcaption></figure><h3>Limiting Results With WHERE Clause</h3><p>With normal Cypher, we can add constraints on the related nodes using WHERE conditions:</p><pre>MATCH (movie:Movie {title: &quot;The Matrix&quot;})<br>       &lt;-[:ACTED_IN]-(person:Person)<br><strong>WHERE person.born &gt; 1965<br></strong>RETURN movie, person</pre><p>This is also doable in a map projection, like this:</p><pre>MATCH (movie:Movie {title: “The Matrix”})<br>RETURN movie {<br>     .title, <br>     actors: [(movie)&lt;-[:ACTED_IN]-(person:Person) <br><strong>               WHERE person.born &gt; 1965</strong><br>                 | person { .name }<br>            ]<br>}</pre><p>In both cases, the result will only contain the actors whose date of birth is greater than 1965.</p><h3>Pagination: Order by, Limit, Skip (or Offset)</h3><p>We would like to be able to write:</p><pre>MATCH (movie:Movie {title: “The Matrix”})<br>RETURN movie {<br>     .title, <br>     actors: [(movie)&lt;-[:ACTED_IN]-(person:Person) <br>               WHERE person.born &gt; 1965 <br>               <strong>ORDER BY person.born LIMIT 1 SKIP 2</strong><br>                 | person { .name }<br>            ]<br>}</pre><p>However, as of March 2022 and Neo4j 4.4, this is not (yet?) possible.</p><p>The good news is that we can achieve similar result using the APOC plugin, and more specifically the apoc.coll.sortMaps function. That will sort a list of maps based on a specific key — “born” in this example:</p><pre>MATCH (movie:Movie {title: &quot;The Matrix&quot;})<br>RETURN movie {<br>     .title, <br>     actors: <strong>apoc.coll.sortMaps(</strong><br>              [<br>                 (movie)&lt;-[:ACTED_IN]-(person:Person) <br>                 | person {.name, .born }<br>               ], <br><strong>               &quot;born&quot;<br>             )[0..3]</strong><br>}</pre><p>The final [0..3] selector lets us return only the first three actors, sorted by date of birth.</p><h3>When to Use Map Projection?</h3><p>I introduced map projection in a GraphQL context, making it easier to take full advantage of GraphQL queries by fetching only the required fields from the database (they do not have to transition through another layer of filtering in your backend). But another application of this concept I like is the ability to write “Object-Graph mappers” (OGM) in an easy way. You can even imagine having a graph schema different from your “domain” schema, and still build proper objects thanks to map projection. Here is an example graph schema featuring products and categories:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*47eQX6wpNSfBi3XAPyQH0A.png" /><figcaption>Product/category graph schema — built with <a href="https://arrows.app/">https://arrows.app/</a></figcaption></figure><p>With the following Product model, containing information about the category it belongs to, you can use map projection in the get_products function in order to build Product objects with all their fields:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/7cd2a686d049da1f3c549343669b9062/href">https://medium.com/media/7cd2a686d049da1f3c549343669b9062/href</a></iframe><p>NB: In the previous example, a product belongs to only one category, for the sake of simplicity. Feel free to adapt the example for a multiple category case — for instance by changing the type of Product.cateogry to list[str].</p><h3>Conclusion</h3><p>That’s all folks! I hope this helped you better understand what map projection is and when it can be useful!</p><h3>References</h3><ul><li><a href="https://neo4j.com/blog/cypher-graphql-neo4j-3-1-preview/">New Cypher Features Inspired by GraphQL [Neo4j 3.1 Preview]</a></li><li><a href="https://neo4j.com/docs/cypher-manual/current/syntax/maps/">Cypher map projection documentation</a></li><li><a href="https://neo4j.com/labs/apoc/4.2/overview/apoc.coll/apoc.coll.sortMaps/">APOC documentation</a></li><li><a href="https://graphql.org/">GraphQL, a query language for your API</a></li><li><a href="https://neo4j.com/docs/api/python-driver/current/index.html">The Neo4j Python driver</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2622b879e886" width="1" height="1" alt=""><hr><p><a href="https://medium.com/neo4j/a-comprehensive-guide-to-cypher-map-projection-2622b879e886">A Comprehensive Guide to Cypher Map Projection</a> was originally published in <a href="https://medium.com/neo4j">Neo4j Developer Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[From Python to Rust: Some Key Differences and Takeaways]]></title>
            <link>https://medium.com/better-programming/from-python-to-rust-some-key-differences-and-takeaways-151da8293b9a?source=rss-506d892fb653------2</link>
            <guid isPermaLink="false">https://medium.com/p/151da8293b9a</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[rust]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Estelle Scifo]]></dc:creator>
            <pubDate>Fri, 25 Feb 2022 16:31:15 GMT</pubDate>
            <atom:updated>2022-03-02T11:25:08.925Z</atom:updated>
            <content:encoded><![CDATA[<h4>With side by side code snippets</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Aklv9U9MPkx5ylQv" /><figcaption>Photo by <a href="https://unsplash.com/@altumcode?utm_source=medium&amp;utm_medium=referral">AltumCode</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Python has been my first programming language for almost 10 years. After spending 3 years working with C++, I loved how simple Python was — there was no need to worry about allocating memory, null pointers, or references: a dream come true!</p><p>However, in the last few months, I spent quite some time working with Rust, for reasons explained below, and I’ll share at the end of this story some features I love about Rust which are not part of the Python language.</p><p><strong><em>NB.</em></strong><em> this is not yet another story about which language is better. I am just sharing my thoughts after several weeks of learning and using Rust, coming from a mostly Pythonic environment.</em></p><h3>Motivation</h3><p>I have used Python for scripting, building websites with template rendering (hi Django!) and training machine learning models, while maintaining language consistency in a large code base, which is quite convenient. So when starting a new project from scratch, it was quite natural to also use Python.</p><p>So, why I am considering another language now? It’s true I like to learn new things all the time, but this is not the only reason.</p><blockquote><strong>On a general basis, it is always a good thing, at some point, to question your processes and choices. Always using the same language or tool, just because you are used to it, is not always the best decision making process.</strong></blockquote><p>So it is good practice to keep an eye on the tools other people are using, understanding how they work so that you can quickly identify when they are a good fit for you. And people talked a lot about Rust recently. It is even the most loved language according to the last Stack Overflow developers survey (2021):</p><blockquote>Most loved, dreaded, and wanted <a href="https://insights.stackoverflow.com/survey/2021/#technology-most-loved-dreaded-and-wanted">https://insights.stackoverflow.com/survey/2021/#technology-most-loved-dreaded-and-wanted</a><br>- Stack Overflow 2021 developers survey</blockquote><p>In addition, I was involved in a project where the use of Python started to be questioned, for two main reasons. The first one was performances. Since the application we were building was doing many things behind the hood. The second reason was code obfuscation.</p><p>Even if I am enthusiastic about open source, it can not always be applied, especially without a clear business model. Due to these two points, Rust seems to be a good candidate to investigate, and that’s the reason why I started reading <a href="https://doc.rust-lang.org/stable/book/"><em>the book.</em></a> And it turned out I found other advantages of learning language with totally different paradigms compared to Python!</p><h3>How to transition from Python to Rust</h3><p>The two languages are fundamentally different. While Python lets you write code without having to worry about your program memory allocation, thanks to a garbage collector program running in parallel with your code, Rust achieves memory safety through other mechanisms, its “ownership rules”. Understanding them is not the goal of this story, but you can find below an illustration of the different ways to access and “move” a variable (from one function to another for instance).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/990/1*tM3kNr_w5V7NQeT-Zkhzgg.png" /><figcaption>Source: <a href="https://rufflewind.com/2017-02-15/rust-move-copy-borrow">https://rufflewind.com/2017-02-15/rust-move-copy-borrow</a></figcaption></figure><p>But to me, understanding ownership and lifetimes is not the most difficult when moving from Python to Rust — maybe because I already had some background with C/C++ and the concepts of references were not new to me. The most difficult was the impossibility to use Object-Oriented Programming and inheritance with Rust (NB: this is not totally true, and you can mimic some behaviors with Rust, but this is definitely not the way Rust developers think). It forces me to think the code in totally different ways. People more familiar with languages using interfaces (like Java) would probably find it easier.</p><p>In the next section, I’ll talk about a few aspects of Rust that, in my opinion, can really help developers write better code. Better here mean easier to read, maintain and use.</p><h3>Rust from a Python developer perspective</h3><h4>Privacy and immutability by default</h4><p>In Python, everything (variables, classes, methods and attributes of classes…) is public and can be accessed from anywhere in your package. We rely on conventions to mimic privacy (like prefixing your variable name with an underscore; your IDE will raise of warning if you use that variable outside of its scope, but your code will run). On the contrary, in Rust, everything is by default private and you have to explicitly declare public objects with pub prefix, and export them to the parent module. It looks like a detail, but it has forced me to better think about public API for an application, which are the elements that I want other developers in my company to access in their own module, which are the ones that I want to expose to external developers and which are the ones that I consider should not be used outside of a very reduced scope?</p><h4>Ownership</h4><p>As a normal Python developer, ownership is something you have probably never heard about, but it is very powerful. The mind-blowing example of this concept which made me love Rust is the following. Consider a database transaction, from which you can execute queries, then commit or rollback and finally close the transaction.</p><p>The following list shows how one would implement a Transaction object (actual method implementation is not relevant for the current topic, so I have omitted them). We can use this object in a do_stuff function, and as you can see, Python will let you close the transaction twice if you do not pay attention: once inside the do_stuff function, and once after do_stuff is done in the main function. It would inevitably lead to runtime error (we could discuss that closing the transaction inside the do_stuff function is bad design, but again, the point here is that Python lets you do it, and no one can say (s)he has never made this kind of mistake).</p><p>The next file shows the almost same code written in Rust, taking advantage of the Rust ownership system.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/80c547934800e3a74ccd9cea6b4d5e23/href">https://medium.com/media/80c547934800e3a74ccd9cea6b4d5e23/href</a></iframe><p>This is all about <strong>&amp;</strong>self VS self in the method signature! The execute_query method takes a reference to self as first parameter, meaning the object the method is called on still exists after the method is done (the object is only “borrowed”). On the other hand, the close method takes the object itself as first parameter (it is “steeled”), meaning it won’t exist anymore after the function. In other words, after the line do_stuff(tx), the variable tx can not be used anymore, the Rust <strong>compiler</strong> won’t let you use it again and will issue an error if you try to. Such behavior than can’t reach production, even if you <em>forget</em> to test your code.</p><h4>Add features with traits</h4><p>I am sure you can understand the concepts and rules of ownership with a couple of examples. As I stated above, the most difficult part to me is doing without object oriented programming! I am used and I like the idea of inheritance, allowing to encapsulate shared behaviors. This is not possible in Rust, or at least, Rust was not made with this target design. Instead, you would define a structure (containing attributes, the data) and traits (containing function definition). Then you can implement a trait for a given structure to describe how a given structure will behave under some actions.</p><p>Traits are similar to interfaces. The closest we have in Python are mixins, which you can use to add some possible actions to your objects. However, they are at the real core of Rust and hence offer more powerful capabilities.</p><p>Consider the following example, where we create a mixin (Python version) and a trait (Rust version) for cache-able objects: they need to expose two methods, get_key and serialize. The resulting code is shown in the first two files below in the following code snippet.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/1c0ff7567b8ab543ecbde1387707b267/href">https://medium.com/media/1c0ff7567b8ab543ecbde1387707b267/href</a></iframe><p>These two implementations are quite similar and we are not yet seeing real benefits here, except that, again, while Python will let you “forget” to implement some methods, Rust compilation will stop with <strong>meaningful</strong> error message if you forget any of the required methods in a trait.</p><p>There is much more to say about traits in Rust, I’ll let you read through the following example for instance, which mimic a kind of “inheritance”, but I’ll it up to you to find out more. As an exercise, you can try and think about how you would implement an equivalent behavior with Python.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2fbc0e983b7344920e667ba9141b1f5d/href">https://medium.com/media/2fbc0e983b7344920e667ba9141b1f5d/href</a></iframe><h4>Generics with constraints &amp; dynamic dispatch</h4><p>Third and last point I want to talk about today are generics. Since Rust is a strongly-typed language, it can become difficult to cover all cases. With the preceding example of a Cachable trait, we already have to deal with twice the almost same code, with only one difference: the type of the returned value from the serialize method. We can rewrite it using generics, by convention named T:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/43697a50d2c65995943258469d7af75f/href">https://medium.com/media/43697a50d2c65995943258469d7af75f/href</a></iframe><p>A nice feature of Rust is its ability to find the proper method to call, depending on the expected type of the variable. Declaring that serialized_data_str must be of type String is enough for it to find out that it must use the serialize method of Cachable&lt;String&gt; and not the one from Cachable&lt;HashMap&lt;String, String&gt;&gt; . Neat, isn’t it?</p><p>Let’s go one step further (and then I stop, I promise!). The previous code snippet would let us implement the Cache trait for any type of generic T . In some situations, we want T to satisfy some constraints, like having some methods, or, in Rust terms, implementing some other traits. For instance, we will add to our Cachable trait a method serialize_and_print that will just print the result of the serialize method. In Rust, in order to be printed, a type must implement some trait from the standard library, like Display or Debug . For the sake of simplicity, we will require the type T to implement the Debug trait here with the syntax: T: Debug :</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/76f74f60586932f79a45a3171a691a57/href">https://medium.com/media/76f74f60586932f79a45a3171a691a57/href</a></iframe><p>If you replace Debug with Display , the Rust compiler will error because HashMap does not implement the Display trait. Python does not provide this type of safeguards. In a mixin, you can use a method that is not implemented in this mixin, but you can just <em>assume</em> that the method will be implemented elsewhere. Rust checks that it <em>is</em> implemented, at compile time.</p><p>Well, I have already gone further than expected with this story, so I’ll stop here for now.</p><h3>Takeaways</h3><p>I have been experimenting with Rust for a few months now. I think it provides a degree of safety and trust unreachable with Python. It has definitely broaden my mind in terms of code organization, beyond OOP.</p><p>I do not feel comfortable enough to start moving the whole codebase I am using to Rust yet. I feel like I am still missing some “idiomatic” ways of using Rust, sometimes still trying to make my code too “object-oriented”. But Rust also integrates quite well with Python, and my current reading is all about how to take advantage of the speed of Rust for key components, while keeping the advantages of Python for your API/SDK… (see the “Further Readings” section).</p><p>But besides explicitly using Rust, exploring how the Rust community structures their code, and some capabilities of Rust such as the ones exposed in this story, has given me brand new insights, and I can already feel the impact on my Python code. I will illustrate this in a follow-up story, stay tuned!</p><h3>Further Readings</h3><p>Here are the resources I have used in my Rust learning path:</p><ul><li>All about Rust: <a href="https://doc.rust-lang.org/stable/book/"><em>The Rust Programming Language</em></a> (Rust official documentation)</li><li>Learn Rust “from scratch” with <a href="https://www.amazon.com/Complete-Rust-Programming-Reference-Guide/dp/1838828109/r"><em>The Complete Rust Programming Reference Guide</em></a><em> </em>by Rahul Sharma, Vesa Kaihlavirta and Claus Matzinger (Packt Publishing)</li><li>Using Rust within Python: <a href="https://www.amazon.com/Speed-Your-Python-Rust-performance/dp/180181144X/"><em>Speed up your Python with Rust</em></a> by Maxwell Flitton (Packt Publishing)</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=151da8293b9a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-programming/from-python-to-rust-some-key-differences-and-takeaways-151da8293b9a">From Python to Rust: Some Key Differences and Takeaways</a> was originally published in <a href="https://betterprogramming.pub/">Better Programming</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Solving a Social Distancing Problem using Genetic Algorithms]]></title>
            <link>https://medium.com/data-science/solving-a-social-distancing-problem-using-genetic-algorithms-e5f1709c87a1?source=rss-506d892fb653------2</link>
            <guid isPermaLink="false">https://medium.com/p/e5f1709c87a1</guid>
            <category><![CDATA[deap]]></category>
            <category><![CDATA[editors-pick]]></category>
            <category><![CDATA[genetic-algorithm]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[machine-lear]]></category>
            <dc:creator><![CDATA[Estelle Scifo]]></dc:creator>
            <pubDate>Sat, 26 Sep 2020 11:09:03 GMT</pubDate>
            <atom:updated>2022-07-28T08:03:14.086Z</atom:updated>
            <content:encoded><![CDATA[<h4><em>An example application of Genetic Algorithms using the DEAP python package.</em></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yol8YWIfsXdYG-dOF8QX9A.jpeg" /><figcaption>Source: <a href="https://en.wikipedia.org/wiki/File:Plasma_fractal_theartproblem_1935.jpg">https://en.wikipedia.org/wiki/File:Plasma_fractal_theartproblem_1935.jpg</a></figcaption></figure><p>“Social distancing” has become very popular these days but it is not always obvious how the rules can fit our daily life. In this story, we are going to study a social distancing problem and find solution to it using Genetic Algorithms. After setting the problem and its constraints, I’ll summarize the principles of Genetic Algorithms (GA) before applying these principles to our problem.</p><h3>The problem</h3><p>This summer (August 2020), people from <a href="https://medium.com/neo4j">Neo4j</a> (the graph database) proposed weekly challenges to be solved with graphs. The <a href="https://medium.com/neo4j/summer-of-nodes-week-1-the-barbecue-ead98d441a91">advanced barbecue challenges of week 1</a> comprises a social distancing task, whose rules where the following:</p><ul><li>20 guests from 11 families are invited to join a barbecue (replace barbecue with wedding, Thanksgiving dinner, whatever party depending on the time of the year). The data is a CSV file with format:</li></ul><pre>Guest,Family  # headers added for clarity<br>Host,A<br>Jane,B<br>Jun,C<br>Oliver,C<br>....</pre><ul><li>You can place them on 6 tables having 6 seats each, where two consecutive seats are one-meter apart from each other (we consider tables are circular)</li><li>Each table must contain guests from at least two different families</li><li>Each table must not have more than two guests from the same family</li><li>Guests from different families must be seated at least two meters apart from each other</li></ul><p>While this problem can be solved with graphs (see the proposed solution here: <a href="https://medium.com/neo4j/summer-of-nodes-week-1-the-barbecue-ead98d441a91">https://medium.com/neo4j/summer-of-nodes-week-1-the-barbecue-ead98d441a91</a>), it sounds to me like a constraint problem that can be addressed with other techniques. In this post, I investigate the use of GA to solve this specific problem.</p><p>Talking about GA, let’s focus on the main principles behind this technique and how this kind of algorithms can help solving the above problem.</p><h3>Genetic Algorithm principles in a nutshell</h3><p>Contrarily to the common approaches, GA does not consider a single solution and update it depending on some conditions (gradient….). Instead, GA will consider a <strong>population of solutions</strong>, and evolve them over several <strong>generations</strong> based on a selection process biased towards the “best” individuals. This involve being able to determine “how good” a solution is, or how far it is from the best solution through a fitness function. The steps of the algorithm are hence:</p><ol><li>For each <strong>individual</strong> in the population, a <strong>fitness function determines how close the individual is from the solution</strong></li><li>A <strong>selection</strong> process takes place to create the next generation of possible solutions, with a bias towards “best individuals”, meaning individuals with highest fitness</li><li><strong>Individuals are mutated</strong>, meaning that solutions are changed based on some rules (e.g.: swapping two positions) and <strong>cross-over</strong> happens which basically swap some part of an individual with another (the difference between mutation and cross-over is explained <a href="https://ai.stackexchange.com/a/9079">here</a>).</li><li>The iterative process restarts from step 1, until a stopping criteria is met (number of iterations, fitness function reaching a given threshold…)</li></ol><p>Let’s now come back to our social distancing problem.</p><h3>Problem formulation</h3><p>A solution for us will be a list with the seat assigned to each guest. A seat is an integer whose value is equal to</p><pre>table_number * 10 + seat_number</pre><p>For instance, the seat 2 in table 4 corresponds to the integer 42.</p><blockquote>This works fine as long as we have less than 10 seats per table.</blockquote><p>Hence, <em>a </em>solution can be written:</p><pre>[10, 31, 19, 20, 23, 35, 22, 5, 6, 13, 3, 17, 33, 8, 1, 28, 27, 24, 25, 15]</pre><p>The guest with index 0 (the Host) is assigned to table 1 (0-based indexed) and seat 4. The equivalent tables are reproduced below:</p><pre>[[-1, &#39;Ren&#39;, -1, &#39;Mohamed&#39;, -1, &#39;Jeremy&#39;],<br> [&#39;Avery&#39;, -1, &#39;Rowan&#39;, -1, &#39;Host&#39;, -1],<br> [-1, &#39;Hugo&#39;, -1, &#39;Isabella&#39;, -1, &#39;Maria&#39;],<br> [-1, &#39;Jun&#39;, &#39;Oliver&#39;, -1, &#39;Milan&#39;, &#39;Mia&#39;],<br> [&#39;Fatima&#39;, &#39;Marc&#39;, -1, &#39;Hannah&#39;, &#39;Ali&#39;, -1],<br> [-1, &#39;Jane&#39;, -1, &#39;Aarav&#39;, -1, &#39;Sophie&#39;]]</pre><p>-1 is the default value for empty seats.</p><p>Now that we have a representation for each solution, let’s define its fitness, i.e. its “closeness” to an satisfactory solution.</p><h3>Fitness definition</h3><p>To define fitness, we have to take into account each of the three constraints defined in the problem definition section, plus the fact that each seat must be assigned only once. Each time a constraint is violated, the fitness will be increased accordingly.</p><h4>Each seat is assigned a single guest</h4><p>In order to count how many times a seat is assigned, we use the collections.Counter python object and check that each value appears less than once. Otherwise, we return a high fitness value:</p><pre>c = Counter(solution)<br>if any( v &gt; 1 for v in c.values()):<br>    return 100</pre><p>After that, we can create the tables, a 2D matrix whose <em>ij</em> elements contains the guest family for seat <em>j </em>of table <em>i</em>. For instance:</p><pre>[[-1, &#39;I&#39;, -1, &#39;G&#39;, -1, &#39;D&#39;],<br> [&#39;E&#39;, -1, &#39;I&#39;, -1, &#39;A&#39;, -1],<br> [-1, &#39;F&#39;, -1, &#39;K&#39;, -1, &#39;H&#39;],<br> [-1, &#39;C&#39;, &#39;C&#39;, -1, &#39;D&#39;, &#39;D&#39;],<br> [&#39;K&#39;, &#39;K&#39;, -1, &#39;J&#39;, &#39;J&#39;, -1],<br> [-1, &#39;B&#39;, -1, &#39;H&#39;, -1, &#39;D&#39;]]</pre><h4>Each table must contain guests from at least two families</h4><p>For each table (row), we can count how many families are represented and increase the violations for this table by 1 if there are less than two families on that table:</p><pre>c = Counter([k for k in table if k != -1])<br>if len(c) &lt; 2:  # allow for empty tables (extra rule)<br>    v += 1</pre><h4>Each table must not have more than 2 guests from the same family</h4><p>Using the same counter, we can count how many individuals from the same family are seated at the same table, and increase the fitness if too many of them are present:</p><pre>s = sum(v &gt; 2 for k, v in c.items())<br>v += s</pre><p>Finally comes the most complex part: the social distancing between guests from different families.</p><h4>People from different families must be at least 2 seats apart</h4><p>To compute this constraint, we are going to use collections.deque objects which comes with a practical .rotate() method. Practical because we have a boundary condition for guests seated on seat 0 and 5 of the same table, which are only 1 meter apart (and not 5). First, we create the deque:</p><pre>td = deque(table)</pre><p>Then, we create another instance with the same input list, but this deque is then rotated:</p><pre>tdr = deque(table)  # table rotated<br>tdr.rotate()</pre><p>For instance, starting from the table:</p><pre>table = [-1, &#39;I&#39;, -1, &#39;G&#39;, -1, &#39;D&#39;]</pre><p>The td and tdr variables would contain:</p><pre>deque([-1, &#39;I&#39;, -1, &#39;G&#39;, -1, &#39;D&#39;])  # td<br>deque([&#39;D&#39;, -1, &#39;I&#39;, -1, &#39;G&#39;, -1])  # tdr</pre><p>From there, we can iterate over both deque . If the two values are equals to -1 (meaning no guest is assigned to that seat), we do nothing. Otherwise, we check that the two guests seated next to each other are from the same family, otherwise we increase the fitness:</p><pre>for seat, prev_seat in zip(td, tdr):<br>    if seat == -1 or prev_seat == -1:<br>        continue<br>    if seat != prev_seat:<br>       v += 1</pre><p>And here we go, our fitness function is finally ready!</p><p>We have only done half of the work though, since we need to configure the genetic algorithm parameters. Hopefully, we won’t have to code all of them ourselves, since very smart people have already done it for us (thank you!).</p><h3>Full code and solution</h3><p>In order to implement the GA part of our problem, we are going to rely on the DEAP (<em>Distributed Evolutionary Algorithms in Python</em>) Python package.</p><p>The main steps are reproduced below:</p><pre># start algorithm configuration<br>toolbox = base.Toolbox()</pre><pre># our objective is to minimize the fitness<br>creator.create(&quot;FitnessMin&quot;, base.Fitness, weights=(-1.0,))</pre><pre># create the Individual class (list of integers)<br>creator.create(&quot;Individual&quot;, list, typecode=&#39;i&#39;, fitness=creator.FitnessMin)</pre><pre># create an operator that generates randomly shuffled indices<br>toolbox.register(&quot;randomOrder&quot;, lambda : random.sample(range(NUM_TABLES * NUM_SEATS_PER_TABLE), k=len(GUESTS)))<br># create the &#39;individual creation&#39; operator to fill up an Individual instance with shuffled indices<br>toolbox.register(&quot;individualCreator&quot;, tools.initIterate, creator.Individual, toolbox.randomOrder)<br># create the &#39;initial population creation&#39; operator to generate a list of individuals<br>toolbox.register(&quot;populationCreator&quot;, tools.initRepeat, list, toolbox.individualCreator)</pre><pre># fitness calculation - compute the total distance of the list of cities represented by indices<br># &#39;get_fitness&#39; is our own fitness function containing the rules defined above<br>toolbox.register(&quot;evaluate&quot;, get_fitness)<br># Genetic operators<br>toolbox.register(&quot;select&quot;, tools.selTournament, tournsize=10)<br>toolbox.register(&quot;mate&quot;, tools.cxTwoPoint)<br>toolbox.register(&quot;mutate&quot;, tools.mutShuffleIndexes, indpb=1.0/len(GUESTS))</pre><pre># create initial population (generation 0):<br>population = toolbox.populationCreator(n=POPULATION_SIZE)</pre><p>Some more details :</p><ul><li>Initial population generation, from a random selection of NB_GUESTS seats (between 0 and NUM_TABLES * NUM_SEATS_PER_TABLE)</li><li>Fitness calculation using the above defined function</li><li>Selection <a href="https://deap.readthedocs.io/en/master/api/tools.html#deap.tools.selTournament">tournament</a>: solutions are compared two by two and the one with the lowest fitness is kept for the next generation (check also: <a href="https://en.wikipedia.org/wiki/Tournament_selection">wikipedia</a>)</li><li>Cross-over: <a href="https://deap.readthedocs.io/en/master/api/tools.html#deap.tools.cxTwoPoint">cxTwoPoint</a>: parts from two randomly chosen solutions are swapped, as illustrated on the following image:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*dqEcLTc1rGMS-VTkfADOxw.png" /><figcaption>Source: <a href="https://commons.wikimedia.org/wiki/File:TwoPointCrossover.svg">https://commons.wikimedia.org/wiki/File:TwoPointCrossover.svg</a></figcaption></figure><ul><li>Mutation: <a href="https://deap.readthedocs.io/en/master/api/tools.html#deap.tools.mutShuffleIndexes">mutShuffleIndexes</a>: shuffle the indices in each solution with a probability P_MUTATION</li></ul><p>The core of the algorithm is then encapsulated into:</p><pre>population, logbook = algorithms.eaSimple(<br>    population,  # initial population<br>    toolbox,   # above defined rules<br>    # extra parameters:<br>    cxpb=P_CROSSOVER, <br>    mutpb=P_MUTATION,  <br>    ngen=MAX_GENERATIONS, <br>    # results:<br>    stats=stats, <br><strong>    halloffame=hof, </strong><br>    verbose=False<br>)</pre><p>The hall of fame contains best performing individual, regardless of the generation they belongs to. They are the solutions we are interested in.</p><p>After running the full code (available <a href="https://github.com/stellasia/medium/blob/master/social_distancing/social_distancing_genetic_algorithm.ipynb">on GitHub</a>), we can see that the 10 best performing individuals in the hall of fame all have a 0 fitness, meaning no constraint violation. One of them is reproduced here:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/774/1*s1s7rrU7MGESqPs21iqQcw.png" /><figcaption>First solution from the Hall of Fame</figcaption></figure><p>You can see that:</p><ul><li>Table 1 contains guests from 3 families, only one guest per family and they are all separated by at least one empty seat.</li><li>Same observation for table 2, 3 and 6</li><li>Table 4 have guests from two families (C and D), two guests from each family. Jun and Oliver are seated next to each other but they come from the same family ( C ) so this is fine, same for Milan and Mia from the D family. No guest from C is seated directly near a guest from D, so the last constraint is also satisfied.</li><li>The same applies for table 5 with members from family K and J.</li></ul><p>Here we go, we have solved a social distancing problem using the power of Genetic Algorithms. <em>You will be able to meet your friends at a barbecue while limiting the risks related to Covid-19!</em></p><p>You can download this code and try and modify the parameters and see how the solver behaves. Both the input parameters (guests, number of tables…), and the model parameters (size of the population, probability of mutation, type of cross over…) can be changed.</p><h3>Further Reading</h3><p>Enjoyed this post? Check following related readings to know more.</p><ul><li>DEAP documentation: <a href="https://deap.readthedocs.io/en/master/">https://deap.readthedocs.io/en/master/</a></li><li>Eyal Wiransky, “<a href="https://www.amazon.com/Hands-Genetic-Algorithms-Python-intelligence-ebook/dp/B0842372RQ/">Hands-On Genetic Algorithms</a>” (2020), <em>Packt</em>: this well documented book gives many examples of problems that can be solved with GA, from combinatorial problems to Machine Learning. I have learned a lot from it and can only recommend it!</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e5f1709c87a1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/solving-a-social-distancing-problem-using-genetic-algorithms-e5f1709c87a1">Solving a Social Distancing Problem using Genetic Algorithms</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why you should  read “Hands-On Graph Analytics with Neo4j”?]]></title>
            <link>https://medium.com/@st3llasia/why-you-should-read-hands-on-graph-analytics-with-neo4j-b1a65c7ce654?source=rss-506d892fb653------2</link>
            <guid isPermaLink="false">https://medium.com/p/b1a65c7ce654</guid>
            <category><![CDATA[book-review]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[neo4j]]></category>
            <category><![CDATA[graph-algorithms]]></category>
            <dc:creator><![CDATA[Estelle Scifo]]></dc:creator>
            <pubDate>Sun, 06 Sep 2020 10:16:45 GMT</pubDate>
            <atom:updated>2020-09-06T10:16:45.553Z</atom:updated>
            <content:encoded><![CDATA[<h3>Why you should read “Hands-On Graph Analytics with Neo4j”?</h3><p><strong><em>Disclaimer</em></strong>: <em>I am the author of this book. I am writing this story not to sell the book to everybody, but to guide readers and let them decide whether this book can be useful for them or not, trying to be </em><strong><em>as objective as possible</em></strong><em>.</em></p><p>Yet another new book in the Neo4j ecosystem! Released end of August 2020, “<a href="https://www.amazon.com/gp/product/B08FBJ3B1S"><em>Hands-On Graph Analytics with Neo4j</em></a>” is an almost 500 pages book about Neo4j, Cypher, knowledge graphs, graph analytics, graph machine learning (still in the context of Neo4j) and their applications. In this post, I’ll explain what is different in this book compared to others, what drove the outline and who will be interested in reading it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/405/1*ZocvPcImzurPHAbqwMueog.jpeg" /></figure><h3>Related books</h3><p>You can find many books about graph databases and Neo4j. Here is a non-exhaustive list of such books with somehow comparable contents:</p><ul><li><a href="https://www.amazon.com/Learning-Neo4j-3-x-performance-visualization-ebook/dp/B071KTHQV4/ref=sr_1_2">Learning Neo4j 3.x</a> (J. Baton &amp; R. Van Bruggen, Packt Publishing): this book will teach you the concepts behind graph databases and Neo4j in particular. It will also drive you through Cypher, the Neo4j query language. This is a nice prerequisite for the book we are talking about right now.</li><li><a href="https://www.amazon.com/Graph-Algorithms-Practical-Examples-Apache/dp/1492047686/ref=sr_1_1">Graph Algorithms: Practical Examples in Apache Spark and Neo4j</a> (M. Needham &amp; A. Hodler, O’Reilly): written by two people working at Neo4j, especially Mark is one of the authors of the Graph Algorithm Library, it is a nice resource for learning about the graph algorithms covered by this library, their use cases and discover practical examples.</li><li><a href="https://www.amazon.com/Graph-Powered-Machine-Learning-Alessandro-Nego/dp/1617295647/ref=sr_1_1">Graph powered Machine Learning</a> (A. Negro, Manning Publication): even if not stated in the title, most examples use Cypher. It is a comprehensive review about Machine Learning applications, with a special focus on recommendation engines and fraud detection techniques relying on graph technologies (several chapters are dedicated to each of these topics).</li></ul><p>All of these offer qualitative content and are good readings! So, why yet another book on similar topic?</p><h3>Book content</h3><p>“<em>Hands-On Graph Analytics with Neo4j</em>” assumes the reader has some prior knowledge about Neo4j (and Cypher) and Machine Learning, even if some quick remainders are given on both topics. The goal of the book was to let you <strong>appreciate the whole range of applications Neo4j offers</strong> in terms of data analysis, including its <strong>large</strong> number of community-based plugins and apps.</p><p>That’s actually one of the reasons that pushed me to write this book: the Neo4j world is big, with many plugins/extensions, and it is sometimes difficult to find your own path. <strong>I see this book as a guide</strong>, that will help you to get how things are organized and understand other graph-related content better if you want to dig deeper into the topic (which I encourage you to do!).</p><h4>Section 1: Graph Modeling with Neo4J</h4><p>The first section is dedicated to a review of Neo4j principles and Cypher usage (data import, pattern matching, query planner). The last chapter is largely covers <strong>knowledge graphs</strong>. It gives extensive examples about how to create and extend a knowledge graph (KG) (using NLP or external data sources such as <a href="http://wikidata.org/">Wikidata</a>). This chapter also presents the ideas behind some nice applications of KG, such as graph-based search or recommendation engines.</p><h4>Section 2: Graph Algorithms</h4><p>The second section is totally focused on graph algorithms, with a high bias towards the algorithms implemented in the newly released Graph Data Science library (GDS) (released in March 2020). As far as I know, it is <strong>the first book using the GDS</strong>. This section will take you from the GDS building principles (introduce and manage the projected graphs, get the algorithm results) to the details of the main algorithms (PageRank, Label Propagation or the Louvain algorithms).</p><p>The main graph algorithms are presented with the objective that the reader understands what is going on under the hood in order to choose when to use them: <strong>example implementations are provided</strong> (in Python) with an example <strong>numeric calculations</strong>.</p><p>A chapter is also dedicated to <strong>spatial data management and visualization</strong> using both the Neo4j spatial built-in types and the neo4j-spatial plugin. Combined with the shortest path algorithms from the GDS, an example routing engine is built.</p><p>Several subsections detail how to create graph visualizations using JavaScript and the Neo4j JS driver.</p><h4>Section 3: Machine Learning on Graphs</h4><p>This section uses the knowledge gained during the previous section to build efficient Machine Learning models, step by step incorporating graphs in the pipeline.</p><p>From node classification to link prediction, <strong>several graph related machine learning tasks are implemented in Python </strong>through Jupyter notebooks. Node embedding algorithms are approached, with examples using the latest release of the GDS (which includes implementation for several graph embedding algorithms). The last subsection gives an overview of Graph Neural Networks, the rising neural network architecture in ML.</p><h4>Section 4: Neo4j for Production</h4><p>Finally, this last section talks about the tools to use Neo4j to create a production quality application. Chapter 11 will make you build a web application using either the Python Flask framework or the GRAND stack (React JS) for a nicer user experience.</p><p>Still curious about the content? You can check the code used in the book on <a href="https://github.com/PacktPublishing/Hands-On-Graph-Analytics-with-Neo4j">GitHub</a>.</p><p>Before explaining who can be interested in this book (in my opinion), let me first warm you about what is NOT covered in the book.</p><h3>What this book is NOT</h3><p>This book is not:</p><ul><li>an introduction to graph databases, nor databases core concepts</li><li>an introduction to Data Science or Machine Learning</li><li>a survey about recommendation / fraud detection / other applications methodologies, only the core concepts are described</li><li>a detailed course about Graph Deep Learning. Even though the concept of GNN is briefly explained, the book contains barely no equations, skips the concepts of loss or activation functions. If interested in Graph Machine Learning and especially GNN and deep learning, I recommend for instance: <a href="https://cse.msu.edu/~mayao4/dlg_book/"><em>Deep Learning on Graphs</em></a>.</li></ul><p>So, still wondering whether you should read this book? Let me give you the <strong>persona</strong> that guided me during the writing process.</p><h3>Target audience</h3><p>In this section, I’ll try to give you some hints about why you would like to read this book, depending on your background.</p><h4>Data scientists</h4><p>You are definitely the main target audience. You build models everyday (or almost). You have an understanding of Machine Learning and are curious about these graphs everybody (almost) is talking about? This book will guide you through all the steps from creating the graph data model (in the database) <strong>to data mining to predictions to production</strong>! All of this using Neo4j and modern technologies (Python, React JS when needed).</p><h4>Data analysts</h4><p>You are used to write SQL queries to extract information from a database and use data mining models to extract some valuable insights from data. This book will give you the same skills in the context of graph databases and you will be able to write Cypher queries to get a better understanding of this data and use algorithms in the GDS to characterize a graph.</p><p>However, note that section 3 requires basic understanding of a Data Science pipeline (model training, binary classification, model performance evaluation). Jupyter notebooks are provided such that you can replay everything, improve the performances and, why not, try with your own data?</p><h4>Developers &amp; computer scientists</h4><p>You are working in a company using graph databases and wonder what can be achieved with them? You will find answers in this book. If you have some computer science background, section 2, which shows different algorithms, should not be a problem for you.</p><p>However, as stated earlier, in section 3, the book assumes you have some knowledge about Data Science. No need to be an expert, you just have to understand what a training set is and what classification means.</p><p>Chapter 11 should be a quite straightforward for you, since it details how to build a web application with Neo4j, using either Python or React and introducing the <strong>GraphQL</strong> API spec.</p><h3>So, interested?</h3><p>Interested? The book is available <a href="https://www.amazon.com/gp/product/B08FBJ3B1S">on Amazon</a>!</p><p>If you have read the book, or even part of it, I would be happy to hear from you. Do you still have pain-points? Any questions you had that have not been answered in the book? What do you plan to build with this new knowledge? Please DM me on <a href="https://twitter.com/st3llasia">Twitter</a> or use the <a href="https://stellasia.github.io/contact">contact form on my website</a>!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b1a65c7ce654" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Analyzing ArXiv data using Neo4j — Part 1]]></title>
            <link>https://medium.com/@st3llasia/analyzing-arxiv-data-using-neo4j-part-1-ccce072a2027?source=rss-506d892fb653------2</link>
            <guid isPermaLink="false">https://medium.com/p/ccce072a2027</guid>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[neo4j]]></category>
            <dc:creator><![CDATA[Estelle Scifo]]></dc:creator>
            <pubDate>Sun, 06 Sep 2020 09:16:05 GMT</pubDate>
            <atom:updated>2022-07-06T14:02:12.647Z</atom:updated>
            <content:encoded><![CDATA[<h3>Analyzing ArXiv data using Neo4j — Part 1</h3><p>Exploring the public ArXiv dataset with Neo4j</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RmH78U0c4qER1-3cM81MGA.png" /></figure><p>All scientists know the famous website <a href="https://arxiv.org/">ArXiv</a>, which makes accessible over 1.7 millions scientific papers in the fields of mathematics, physics, computer science or economy (and the list is not exhaustive!).</p><p>Recently, the Cornell University, who has been managing ArXiv for 30 years, released a dataset containing all the articles of the platform in the public domain. Information about this dataset can be found here: <a href="https://www.kaggle.com/Cornell-University/arxiv">https://www.kaggle.com/Cornell-University/arxiv</a> (see also, the introduction blog post <a href="https://medium.com/@kaggleteam/leveraging-ml-to-fuel-new-discoveries-with-the-arxiv-dataset-981a95bfe365">here</a>).</p><p>The dataset uploaded to Kaggle contains metadata for each article (DOI, title, authors, categories, abstract…). Even if the full PDFs are also accessible, we will only use this metadata file in this post.</p><p>In this post, we will go through this dataset and import the data into Neo4j for further analysis. The steps we are going to follow are:</p><ol><li>Import the data into Neo4j using the Neo4j import tool</li><li>Simple data analysis</li></ol><h3>Data import</h3><p>Since the dataset is quite large, we will import it using the <a href="https://neo4j.com/docs/operations-manual/current/tutorial/import-tool/">Neo4j import tool</a>, which is super fast. It processes input CSV files containing the nodes and relationships definition. Some data parsing and formatting is needed beforehand for the data to be understood by this tool so that we are going to:</p><ol><li>Data parsing: read the raw data</li><li>Data cleaning: remove duplicates</li><li>Data formatting: format the data for Neo4j</li><li>And finally, import the data</li></ol><h4>Parsing raw json</h4><p>Each row in the raw data contains a JSON element with the following keys:</p><pre>{<br> <strong>   &quot;id&quot;: str,</strong><br>    &quot;submitter&quot;: str, <br>    &quot;authors&quot;: str,  # authors as they appear in the paper<br>   <strong> &quot;title&quot;: str,</strong><br>    &quot;comments&quot;: str,<br>    &quot;journal-ref&quot;: str,<br>    &quot;doi&quot;: str,<br>    &quot;report-no&quot;: str,<br>    &quot;categories&quot;: str,   # comma separated list of categories<br>    &quot;licence&quot;: str,<br>    &quot;abstract&quot;: str,<br>    &quot;version&quot;: list,<br>    &quot;update_date&quot;: str,<br>    <strong>&quot;author_parsed&quot;: list</strong><br>}</pre><p>The bold fields are the ones we are going to use in the following to create a graph whose schema is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/223/1*M18gPAU2fiuUYgTXTsMCZA.png" /><figcaption>Author — WROTE -&gt; Article</figcaption></figure><p>As a first step, we will parse each row as JSON and extract the information we need to create a graph:</p><ul><li>The article ID (that will be its unique identifier), its title and DOI</li><li>Article’s authors. The author ID is the concatenation of all the elements in the author_parsed entry of each author. <br>E.g.</li></ul><pre>[<br>  [&quot;Balázs&quot;, &quot;C.&quot;,&quot;&quot;],   # ==&gt; &quot;Balázs_C.&quot;<br>  [&quot;Berger&quot;, &quot;E. L.&quot;, &quot;&quot;],  ==&gt; &quot;Berger_E.L.&quot;<br>]</pre><p>Probably, we will have some homonyms, but let’s ignore this for now.</p><ul><li>A list of article to author ID (the relationships)</li></ul><p>So, here is the Python code to extract these three lists out of the raw data:</p><pre>import json</pre><pre># extracting data<br>author_list = []<br>article_list = []<br>article_to_author_list = []</pre><pre>with open(&quot;arxiv-metadata-oai-snapshot.json&quot;, &quot;r&quot;) as f:<br>    for l in f:<br>        d = json.loads(l)<br>        article_id = d[&quot;id&quot;]<br>        <br>        article_list.append(<br>            {<br>                &quot;articleId&quot;: article_id,<br>                &quot;doi&quot;: d[&quot;doi&quot;],<br>                &quot;title&quot;: d[&quot;title&quot;],<br>            }<br>        )<br>        <br>        authors = d[&quot;authors_parsed&quot;]<br>        for a in authors:<br>            author_id = &quot;_&quot;.join(a)<br>            <br>            author_list.append({<br>                &quot;authorId&quot;: author_id, <br>                &quot;name&quot;: a[0]<br>            })<br>            article_to_author_list.append({<br>                &quot;articleId&quot;: article_id, <br>                &quot;authorId&quot;: author_id,<br>            })</pre><p>Some more steps are still required to be able to process the data with Neo4j, so let’s create pandas DataFrame from theses lists, which will make the data processing step easier:</p><pre>article_df = pd.DataFrame.from_records(article_list)<br>author_df = pd.DataFrame.from_records(author_list)<br>article_to_author_df = pd.DataFrame.from_records(article_to_author_list)</pre><p>The lengths of these dataframes are:</p><pre>len(article_df)=1753042<br>len(author_df)=7268183<br>len(article_to_author_df)=7268183</pre><h4>Data cleaning</h4><p>By default, the Neo4j import tool fails if several rows have the same node ID, so we will take care of cleaning the data and removing these duplicates. For the author file, we can just keep the first occurrence and use the <a href="https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.drop_duplicates.html">drop_duplicates</a> method of pandas. Even if the article ID should be unique, it turns out that there are a couple of duplicates, probably to mistakes in data extraction. Since there are very few examples, we will just apply the same rule and keep only the first occurrence. Finally, we make sure that the IDs in the relationship data are present in each of the node files:</p><pre>article_df = article_df.drop_duplicates(subset=[&quot;articleId&quot;])<br>author_df = author_df.drop_duplicates(subset=[&quot;authorId&quot;])<br>article_to_author_df = article_to_author_df[<br>    article_to_author_df.articleId.isin(article_df.articleId)<br>    &amp; article_to_author_df.authorId.isin(author_df.authorId)<br>]</pre><blockquote>NB: we could also have used the option --skip-duplicate-nodes=true when importing the data, but I prefer to manage here whose rows are kept.</blockquote><h4>Preparing data for the Neo4j import tool</h4><p>To use this tool, we will need three CSV files:</p><ul><li><em>authors.csv</em> containing unique authors, with following headers: authorId:ID,name</li><li><em>articles.csv</em> containing unique articles: articleId:ID,doi,title</li><li><em>wrote.csv</em> containing the relationship between authors and articles: :START_ID,:END_ID</li></ul><p>The :ID , :START_ID and :END_ID annotations are required to tell Neo4j which column of the CSV file is the unique node identifier and whose columns contain the identifiers of the start and end nodes in the relationship.</p><p>So let’s rename the columns of our DataFrame that require such annotations:</p><pre>article_df = article_df.rename(columns={&quot;articleId&quot;: &quot;articleId:ID&quot;})<br>author_df = author_df.rename(columns={&quot;authorId&quot;: &quot;authorId:ID&quot;})<br>article_to_author_df = article_to_author_df.rename(columns={<br>    &quot;authorId&quot;: &quot;:START_ID&quot;,<br>    &quot;articleId&quot;: &quot;:END_ID&quot;,<br>})</pre><p>Finally, our dataframes are ready and we can save them to CSV, excluding the index which is not relevant here:</p><pre>article_df.to_csv(&quot;articles.csv&quot;, index=False)<br>author_df.to_csv(&quot;authors.csv&quot;, index=False)<br>article_to_author_df.to_csv(&quot;wrote.csv&quot;, index=False)</pre><p>At the end, we have three CSV files that we will be able to import into a newly created Neo4j graph. Let’s go ahead.</p><h4>Finally, importing the data</h4><p>To import this data, follow these steps:</p><ol><li>Create a new Neo4j graph <strong>WITHOUT STARTING IT YET</strong></li><li>Through the management tab, open a terminal and copy the CSV files we have just created into the import folder</li><li>Run the following command from the NEO4J_HOME (default location when you open a terminal from your graph management panel):</li></ol><pre>bin/neo4j-admin import \<br>    --nodes=Article=import/articles.csv \<br>    --nodes=Author=import/authors.csv \<br>    --relationships=WROTE=import/wrote.csv \<br>    --multiline-fields=true</pre><p>Neo4j will process the data for you, and after a few seconds, you should see something like:</p><pre><strong>IMPORT DONE in 16s 109ms. </strong><br>Imported:<br>  3155051 nodes<br>  7268183 relationships<br>  7223379 properties<br>Peak memory usage: 755.5MiB</pre><p>which means the import completed successfully.</p><p>You can start the database and it’s now time for some data analysis!</p><h3>Analyzing data</h3><h4>Number of articles per author</h4><p>There are many things we can do with a graph, we can for instance compute the number of articles per author:</p><pre>MATCH (author:Author)-[:WROTE]-&gt;(paper:Article)  // pattern matching<br>WITH author, count(paper) as numberOfArticles  // aggregation<br>RETURN author.name, numberOfArticles    // result</pre><p>We can run this query from Python to extract the data again in a dataframe:</p><pre>import neo4j</pre><pre>driver = neo4j.GraphDatabase.driver(&quot;bolt://localhost:7687&quot;, auth=(&quot;neo4j&quot;, &quot;&lt;password&gt;&quot;))</pre><pre>with driver.session() as session:<br>    res = session.run(<br>        &quot;&quot;&quot;MATCH (author:Author)-[:WROTE]-&gt;(paper:Article)<br>           WITH author, count(paper) as numberOfArticles<br>           RETURN author.name, numberOfArticles<br>        &quot;&quot;&quot;<br>    )<br>    data = res.data()<br>    df = pd.DataFrame.from_records(data)<br>df.head()</pre><p>Let’s get an idea of the distribution of this numberOfArticles variable with a df.describe():</p><pre>           numberOfArticles<br>count      1.402012e+06<br>mean       5.184109e+00<br>std        1.743480e+01<br>min        1.000000e+00<br>25%        1.000000e+00<br>50%        1.000000e+00<br>75%        3.000000e+00<br>max        1.513000e+03</pre><p>Apparently, we have at least one outlier with more than 1000 papers (A LOT!), but most of the distribution is between 1 and 3 papers per author. The distribution in the range [0, 20] is reproduced below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/392/1*OjN17hB76TKXF2efx-rJQg.png" /></figure><p>If we look more carefully at the authors with the highest number of papers:</p><pre>df.sort_values(&quot;numberOfArticles&quot;, ascending=False).head(20)</pre><p>we’ll find the ATLAS and CMS collaborations, which are international groups made of hundreds of physicists, so the fact that they have issued almost 1000 papers each is not surprising (<em>fun fact: I was part of the ATLAS collaboration during my Ph.D</em>). On the other hand, we find names such as Zhang, Li or Smith, which are very common and likely to be related to the homonym issue we talked about at the beginning of this post.</p><p>In a following post, we will study the community structure of this dataset using the Neo4j Graph Data Science library!</p><p>Stay tuned!</p><blockquote><strong>PS: want to practice by yourself? Try and import the articles’ categories as well! You will then be able to answer questions such as: “how many articles are there for each category?” or “how many categories a given author contributes to in average?”</strong></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ccce072a2027" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Computing Node Embedding with a Graph Database: Neo4j & its Graph Data Science Library]]></title>
            <link>https://medium.com/data-science/computing-node-embedding-with-a-graph-database-neo4j-its-graph-data-science-library-d45db83e54b6?source=rss-506d892fb653------2</link>
            <guid isPermaLink="false">https://medium.com/p/d45db83e54b6</guid>
            <category><![CDATA[graph]]></category>
            <category><![CDATA[neo4j]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[python]]></category>
            <dc:creator><![CDATA[Estelle Scifo]]></dc:creator>
            <pubDate>Sun, 12 Jul 2020 16:13:23 GMT</pubDate>
            <atom:updated>2020-07-15T11:53:48.463Z</atom:updated>
            <content:encoded><![CDATA[<h4><em>Using the new version of the Neo4j Graph Data Science plugin to compute node embedding and extract them into a pandas DataFrame thanks to pygds.</em></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SoaWoM5IzH-Z7pWiaWnaDw.png" /><figcaption>Image by <a href="https://pixabay.com/fr/users/geralt-9301/">Gerd Altmann</a></figcaption></figure><p>Machine Learning these days is all about vectors. Performing a classification task requires that your data is well-arranged into rows (observations), each one containing the same amount of features (columns). While this is <em>easy</em> to obtain from data originally stored in an Excel sheet or in SQL or noSQL databases, the transformation is far from obvious when the problem involves complex objects such as texts, images or graphs.</p><p>For these objects to be represented as vectors, embedding techniques are used. Embedding algorithms assign a vector with given “small” size to each of these complex objects that would require thousands (at least) of features otherwise. The challenge of embedding is to preserve some characteristics of the object you are trying to model, while reducing the number of features. For instance, word embedding will try and capture the word <em>meaning,</em> such that words semantically close to each other have similar vector representations.</p><h3>Graph embedding</h3><p>Graph embedding covers several techniques, depending on the objects to be represented. The most common ones are node embedding, where the entities to be represented as vectors are nodes, but we can also find edge embedding or whole-graph embedding. This post will focus on the former one, node embedding.</p><h3>Graph databases and Neo4j</h3><p>The primary purpose of graph databases is to make relationships easier to manage, whether we are talking about a web application with complex ManyToMany relationships, or graph data science. Interest for this kind of store is almost constantly increasing, especially since the Cypher query language has been introduced into Neo4j.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*-jsqhjOmv58S6MIIj9K92w.png" /><figcaption>Source: <a href="https://db-engines.com/de/blog_post/53">https://db-engines.com/de/blog_post/53</a></figcaption></figure><p>Cypher makes it so easy to write intuitive queries. For instance, I am sure you will get instantaneously what this query is doing:</p><pre>MATCH (:User {name: &quot;Emil&quot;})-[:FOLLOWS]-&gt;(u:User)<br>WHERE NOT u.name STARTS WITH &quot;neo&quot;<br>RETURN u.name, u.dateJoined</pre><p>A few things to note from the above query:</p><ul><li>Nodes, delimited by parenthesis (), have a label, that can be identified thanks to the leading :</li><li>Relationships, delimited by square brackets [], must have a type. Conventionally, relationship types are capitalized.</li></ul><h4>Trying Neo4j</h4><p>Convinced to give a try to Neo4j? You have two ways to do it:</p><ul><li>Using a sandbox that will run a Neo4j instance for you during a limited period (3 days, that can be extended for 7 more days): <a href="https://sandbox.neo4j.com/">https://sandbox.neo4j.com/</a></li><li>Download Neo4j Desktop and run it locally and enjoy all the features: <a href="https://neo4j.com/download/">https://neo4j.com/download/</a></li></ul><p>In both cases, this is totally free. I’ll be using the later in this blog, creating a new graph using Neo4j 4.1.</p><h4>Importing some data</h4><p>Let’s import some data into our graph. To do so, we are going to use the “Game Of Thrones” dataset using the got browser guide. Type:</p><pre>:play got</pre><p>in the browser, and follow the instructions.</p><p>Once you have imported the data, the graph schema looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/239/1*ygW71Sbfz5ZsdSWR56HFJQ.png" /><figcaption>The “Game Of Thrones” graph schema. (CALL db.schema.visualization)</figcaption></figure><p>It contains one node label, Character , and five relationship types depending on which book the characters were found to interact with each other, and a global INTERACTS relationship. We are going to use only the last one for the rest of this post. If you want to visualize some of the data, you can use:</p><pre>MATCH (n)<br>RETURN n<br>LIMIT 200</pre><p>Let’s go ahead and proceed to the graph analysis and node embedding.</p><h3>The Graph Data Science plugin (GDS)</h3><p>The GDS is the successor of the Graph Algorithm plugin whose first release date back to 2018. It’s goal is to enable the use of graph algorithms, from path finding algorithms to graph neural networks, without having to extract data from Neo4j.</p><p>Follow the steps in <a href="https://neo4j.com/docs/graph-data-science/current/installation/#_neo4j_desktop">https://neo4j.com/docs/graph-data-science/current/installation/#_neo4j_desktop</a> for installation.</p><h4>Projected graph</h4><p>The Neo4j graph usually contains a lot of data: nodes with different labels, relationships with different types and properties attached to them. Most of the time, a data science algorithm requires only a small portion of these entities: only some node labels or some relationship type and only one property (relationship weight for shortest path algorithm for instance). That’s why the GDS does not run on the full Neo4j graph, but on a <strong>projected </strong>(lighter) version. So, let’s start and build our projected graph. In the Neo4j browser, execute:</p><pre>CALL gds.graph.create(<br>    &quot;MyGraph&quot;, <br>    &quot;Character&quot;, <br>    &quot;INTERACTS&quot;<br>)</pre><p>Here we create a projected graph named MyGraph, containing all nodes with label Character. Additionally, we add to this projected graph relationships with type INTERACTS.</p><p>Here we are, our projected graph is created, we can go ahead and execute algorithms on it.</p><h4>Executing Node2vec</h4><p>The simplest way to run the node2vec algorithm on the MyGraph projected graph is to use this simple query:</p><pre>CALL gds.alpha.node2vec.stream(&quot;MyGraph&quot;)</pre><p>The result in the browser looks like the following image, where a list of numbers gets assigned to each node (identified by its internal Neo4j ID, nodeId):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HjI8QkBLu1hna8wxPltGJg.png" /><figcaption>Output of the node2vec procedure with default parameters.</figcaption></figure><p>If you know a bit about how node2vec works, you know there are many configuration parameters to configure how:</p><ul><li><strong>the training data is build</strong> (random walks parameters): number of steps, number of generated walks per node, in-out and return factors.</li><li><strong>the skip-gram neural network is trained</strong>: embedding size, initial learning rate, etc.</li></ul><p>The full list of parameters is reproduced below, from the GDS documentation page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YJwSWjw2TzOr-xnX4B2_GA.png" /><figcaption>Node2vec parameters from the GDS documentation <a href="https://neo4j.com/docs/graph-data-science/current/algorithms/node-embeddings/node2vec/">https://neo4j.com/docs/graph-data-science/current/algorithms/node-embeddings/node2vec/</a></figcaption></figure><p>Let’s try for instance to reduce the embedding size:</p><pre>CALL gds.alpha.node2vec.stream(“MyGraph”, {walksPerNode: 2, embeddingSize: 10})</pre><p>Without surprise, the output now looks like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7qXGlUMHh39N6p_MIOpK8g.png" /></figure><p>Before dealing with the usage of these results, let’s see how to use another embedding algorithm, GraphSAGE.</p><h4>Executing GraphSAGE</h4><p>While Node2vec only takes into account the graph structure, GraphSAGE is able to consider node properties, if any.</p><p>In our GoT graph, nodes only have a name property which is not that meaningful for embedding. We will then use only the node degree, or number of relationships attached to it, as property:</p><pre>CALL gds.alpha.graphSage.stream(&quot;MyGraph&quot;, {degreeAsProperty: true})</pre><p>The full list of parameters includes configuration of the properties (nodePropertyNames), the aggregator function (mean by default), the batch size… See image below for a full list.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_RJB1dmkqmojvosaPagmoA.png" /><figcaption>GraphSAGE parameters from the GDS documentation: <a href="https://neo4j.com/docs/graph-data-science/current/algorithms/alpha/graph-sage/">https://neo4j.com/docs/graph-data-science/current/algorithms/alpha/graph-sage/</a></figcaption></figure><h3>Making use of the results with Python</h3><p>Neo4j provides a python driver that can be easily installed through pip. However, in this post, I will talk about a small tool that I have developed allowing to call GDS procedures from Python without effort: <a href="https://github.com/stellasia/pygds">pygds</a>. It still needs to be heavily tested, so feel free to report issues if you find any.</p><p>Let’s start by installing the package in your favorite python environment:</p><pre>pip install &quot;pygds&gt;=0.2.0&quot;</pre><p>Then, you can import the library and define the credentials to connect to your Neo4j graph:</p><pre>from pygds import GDS<br><br>URI = &quot;bolt://localhost:7687&quot;<br>AUTH = (&quot;neo4j&quot;, &quot;&lt;YOUR_PASSWORD&gt;&quot;)</pre><p>Usage of pygds is as follows:</p><pre>with GDS(URI, auth=AUTH) as gds:<br>    # create the projected graph<br>    # NB: make sure a graph with the same does not already exists<br>    # otherwise run CALL gds.graph.drop(&quot;MyGraph&quot;) <br>    gds.graph.create(<br>        &quot;MyGraph&quot;, <br>        &quot;Character&quot;, <br>        &quot;INTERACTS&quot;,<br>    )</pre><pre>    # run any algorithm on it<br>    </pre><p>For instance, to run the node2vec algorithm, we will write:</p><pre>result = gds.alpha.node2vec.stream(<br>    &quot;MyGraph&quot;, <br>    {<br>        &quot;walksPerNode&quot;: 2, <br>        &quot;embeddingSize&quot;: 10<br>    }<br>)</pre><p>The result can then be parsed into a DataFrame:</p><pre>import pandas as pd</pre><pre>_tmp = pd.DataFrame.from_records(result)<br>df = pd.DataFrame(_tmp[&quot;embedding&quot;].tolist())<br>print(df.head())</pre><p>Starting from there, you can perform any Machine Learning algorithm, from PCA for visualization to classification if nodes also have some target class…</p><blockquote>As a last step, whether you are working with Cypher or pygds, you have to drop the projected graph which is stored in the live memory of your computer: gds.graph.drop(&quot;MyGraph&quot;)</blockquote><h3>Want to know more?</h3><p>That’s great! The GDS contains much more fantastic algorithms implementations (path finding, node importance, community detection, node similarity, link prediction) and features (e.g. writing the algorithms results as node properties to persist the result in the graph instead of streaming them).</p><p>Here are a few online resources you can check if you are interested in learning more about graph algorithms and Neo4j:</p><ul><li>Free Book “Graph Algorithms: Practical Examples in Apache Spark and Neo4j” by <a href="https://medium.com/u/68584b0be0fb">Mark Needham</a>: <a href="https://neo4j.com/graph-algorithms-book/">https://neo4j.com/graph-algorithms-book/</a> (caveat: this book was written using the Graph Algorithm library, predecessor of the GDS, but is still a must-read to understand graph algorithms use-cases (and a migration guide is available <a href="https://neo4j.com/docs/graph-data-science/1.0/appendix-b/">here</a> together with <a href="https://towardsdatascience.com/introducing-the-neo4j-graph-data-science-plugin-with-examples-from-the-graph-algorithms-19b831f66f2">updated examples using the GDS</a>); caveat 2: it may not be free indefinitely and the end of its “free-period” is periodically announced by Neo4j and so far has always been extended but who knows)</li><li>Check the GraphAcademy created by <a href="https://medium.com/u/26bec2028463">Neo4j</a> and its data science course:<br><a href="https://neo4j.com/graphacademy/online-training/data-science/part-0/">https://neo4j.com/graphacademy/online-training/data-science/part-0/</a></li><li>You can follow <a href="https://medium.com/u/57f13c0ea39a">Tomaz Bratanic</a> on medium and his blog to see many interesting use cases for all the algorithms of the GDS: <a href="https://tbgraph.wordpress.com/">https://tbgraph.wordpress.com/</a></li><li>And of course, read the doc: <a href="https://neo4j.com/docs/graph-data-science/current/">https://neo4j.com/docs/graph-data-science/current/</a></li><li>For more information about the algorithms discussed here, see for instance <a href="https://towardsdatascience.com/a-gentle-introduction-to-graph-neural-network-basics-deepwalk-and-graphsage-db5d540d50b3">A Gentle Introduction to Graph Neural Networks (Basis, DeepWalk and GraphSage)</a> by <a href="https://medium.com/u/2fc7b9c3f02a">Kung-Hsiang, Huang (Steeve)</a>:</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d45db83e54b6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/computing-node-embedding-with-a-graph-database-neo4j-its-graph-data-science-library-d45db83e54b6">Computing Node Embedding with a Graph Database: Neo4j &amp; its Graph Data Science Library</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>