Giter Site home page Giter Site logo

neo4j-graph-examples / recommendations Goto Github PK

View Code? Open in Web Editor NEW
45.0 3.0 27.0 121.89 MB

Neo4j Graph Example Movies Recommendation

Home Page: https://sandbox.neo4j.com?usecase=recommendations

C# 10.23% Go 16.93% Java 11.52% JavaScript 54.21% Python 5.84% Shell 1.27%
neo4j recommendations graphdb example-data dataset movie-data cypher algorithms neo4j-approved neo4j-auradb-dev-approved

recommendations's Introduction

icon movie

Recommendations Graph Example

Description: Generate personalized real-time recommendations using a dataset of movie reviews

Nodes 28863 Relationships 166261

model
Figure 1. Model
example
Figure 2. Example
Example Query:
MATCH (m:Movie {title:$movie})<-[:RATED]-(u:User)-[:RATED]->(rec:Movie)
RETURN distinct rec.title AS recommendation LIMIT 20

Setup

This is for Neo4j version: 4.0

The database is also available on https://demo.neo4jlabs.com:7473

Username "recommendations", password: "recommendations", database: "recommendations"

Load graph data via the following:

Dump file: data/recommendations-40.dump

  • Drop the file into the Files section of a project in Neo4j Desktop. Then choose the option to Create new DBMS from dump option from the file options.

  • Use the neo4j-admin tool to load data from the command line with the command below.

bin/neo4j-admin load --from data/recommendations-40.dump [--database "database"]

Code Examples

GraphQL API

See /graphql directory for Node.js GraphQL API server example using @neo4j/graphql

Feedback

Feel free to submit issues or pull requests for improvement on this repository.

recommendations's People

Contributors

alexicawright avatar cj2001 avatar dependabot[bot] avatar fbiville avatar jexp avatar jmhreif avatar johnymontana avatar lju-lazarevic avatar neo4j-oss-build avatar nielsdejong avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

recommendations's Issues

fix padding of names

Neo4j Developer Relations Team,

Thanks for making the Neo4j sandboxes available. I use the movie recommendation sandbox to introduce graph concepts to students who do not have a background in computing.

In using the sandbox,there is a minor issue with the actor and director nodes that you may be aware of, but I figured I would pass it along. Some of the actors and directors have two nodes - one with a space before their name, and some have a single node, but also have a space before their name. Possibly this is due to parsing the data on the commas and not trimming out the spaces.

For the students, I have them run a few queries to fix the issue. They may not be the most efficiently written, but are included below.

Thanks again for providing this resource!

Best,

Scott

// The following query merges actors who have two nodes,
// the one having a space at the start of their name is merged into the other.

MATCH (n:Actor)
WHERE n.name STARTS WITH " " = False
WITH n.name as aname, " "+n.name as paddedname
MATCH (n1:Actor {name: aname}), (n2:Actor {name: paddedname})
WITH [n1,n2] as ns
CALL apoc.refactor.mergeNodes(ns, {properties:'discard'}) YIELD node
RETURN node

// The following query should be run after the query above and removes
// the space at the start of actor names where there was only one node
// for that actor

MATCH (n:Actor)
WHERE n.name STARTS WITH " " = True
SET n.name = TRIM(n.name)
RETURN n

// The following query merges directors who have two nodes,
// the one having a space at the start of their name is merged into the other.

MATCH (n:Director)
WHERE n.name STARTS WITH " " = False
WITH n.name as aname, " "+n.name as paddedname
MATCH (n1:Director {name: aname}), (n2:Director {name: paddedname})
WITH [n1,n2] as ns
CALL apoc.refactor.mergeNodes(ns, {properties:'discard'}) YIELD node
RETURN node

// The following query should be run after the query above and removes
// the space at the start of director names where there was only one node
// for that director

MATCH (n:Director)
WHERE n.name STARTS WITH " " = True
SET n.name = TRIM(n.name)
RETURN n

failed to load the recommendations-40.dump with error 'Not a valid Neo4j archive'

Hi Sirs,
I am trying to build the recommendation database at local by loading the given dump file: recommendations-40.dump, but get the Not a valid Neo4j archive error (same error both on windows and ubuntu)

Besides, I also surveyed and tried the possible solution about the error Knowledge Base neo4j-admin load causes "Not a valid Neo4j archive", but is still got same error.

Is there another limitation about the dumped file? or Is there any idea or suggestion about this?

  • neo4j: 4.0.7
  • with terminal from Neo4j Desktop on Windows
    .\bin\neo4j-admin load --from data\recommendations-40.dump --database "recommendations" --force --verbose
    
  • with docker container on ubuntu 18.04
    docker run --interactive --tty --rm \
        -p 7480:7474 -p 7680:7687 \
        -v /home/$USER/development/data/neo4jdb-movie-bk/data:/data \
        -v /home/$USER/development/data/neo4jdb-movie-bk/backups:/backups \
        --user=$(id -u):$(id -g) \
        neo4j:4.0.7 \
    neo4j-admin load --from=/backups/recommendations-40.dump --database="neo4j" --force
    
    • note the container is build with
    docker run -d \
            --name neo4jdb-movie-bk \
            -v /home/$USER/development/data/neo4jdb-movie-bk/data:/data \
            -v /home/$USER/development/data/neo4jdb-movie-bk/logs:/logs \
            -v /home/$USER/development/data/neo4jdb-movie-bk/import:/var/lib/neo4j/import \
            -v /home/$USER/development/data/neo4jdb-movie-bk/plugins:/plugins \
            -v /home/$USER/development/data/neo4jdb-movie-bk/backups:/backups \
            -p 7478:7474 -p 7678:7687 \
            --user=$(id -u):$(id -g) \
            --env NEO4J_AUTH=<xxxx/xxxxx> \
            neo4j:4.0.7
    

The log is shown as below:

>>.\bin\neo4j-admin load --from data\recommendations-40.dump --database "recommendations" --force --verbose
org.neo4j.cli.CommandFailedException: Not a valid Neo4j archive: data\recommendations-40.dump
        at org.neo4j.commandline.dbms.LoadCommand.load(LoadCommand.java:189)
        at org.neo4j.commandline.dbms.LoadCommand.loadDump(LoadCommand.java:119)
        at org.neo4j.commandline.dbms.LoadCommand.execute(LoadCommand.java:91)
        at org.neo4j.cli.AbstractCommand.call(AbstractCommand.java:59)
        at org.neo4j.cli.AbstractCommand.call(AbstractCommand.java:29)
        at picocli.CommandLine.executeUserObject(CommandLine.java:1743)
        at picocli.CommandLine.access$900(CommandLine.java:145)
        at picocli.CommandLine$RunLast.handle(CommandLine.java:2101)
        at picocli.CommandLine$RunLast.handle(CommandLine.java:2068)
        at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:1935)
        at picocli.CommandLine.execute(CommandLine.java:1864)
        at org.neo4j.cli.AdminTool.execute(AdminTool.java:77)
        at org.neo4j.cli.AdminTool.main(AdminTool.java:58)
Caused by: org.neo4j.dbms.archive.IncorrectFormat: data\recommendations-40.dump
        at org.neo4j.dbms.archive.Loader.openArchiveIn(Loader.java:191)
        at org.neo4j.dbms.archive.Loader.load(Loader.java:74)
        at org.neo4j.commandline.dbms.LoadCommand.load(LoadCommand.java:165)
        ... 12 more
Caused by: java.io.IOException: Decompression error: Unknown frame descriptor
        at com.github.luben.zstd.ZstdInputStream.readInternal(ZstdInputStream.java:147)
        at com.github.luben.zstd.ZstdInputStream.read(ZstdInputStream.java:107)
        at java.base/java.io.FilterInputStream.read(FilterInputStream.java:107)
        at org.neo4j.dbms.archive.CompressionFormat$2.decompress(CompressionFormat.java:79)
        at org.neo4j.dbms.archive.CompressionFormat.decompress(CompressionFormat.java:148)
        at org.neo4j.dbms.archive.CompressionFormat.decompress(CompressionFormat.java:125)
        at org.neo4j.dbms.archive.Loader.openArchiveIn(Loader.java:175)
        ... 14 more
        Suppressed: java.util.zip.ZipException: Not in GZIP format
                at java.base/java.util.zip.GZIPInputStream.readHeader(GZIPInputStream.java:166)
                at java.base/java.util.zip.GZIPInputStream.<init>(GZIPInputStream.java:80)
                at java.base/java.util.zip.GZIPInputStream.<init>(GZIPInputStream.java:92)
                at org.neo4j.dbms.archive.CompressionFormat$1.decompress(CompressionFormat.java:52)
                at org.neo4j.dbms.archive.CompressionFormat.decompress(CompressionFormat.java:148)
                at org.neo4j.dbms.archive.CompressionFormat.decompress(CompressionFormat.java:132)
                ... 15 more

Updates for GDS 2.x

About half of this browser guide relies on some similarity functions in GDS 1.x that have been updated for 2.x and will not work once 2.x rolls out onto Sandbox. So this browser guide needs some updating.

model and example image

model image

  • remove acted_in from director
  • remove directed from actor

possibly use apoc.meta.graph instead of db.schema

for the example image it would be nicer to have a movie with actors, genre, directors and a few (3-5) ratings, than just a ratings picture

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.