This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
objective = objectiveSKLearn() | |
initial_params = { | |
'embeddingDimension': 64, | |
'thirdWeight': 0.5, | |
'fourthWeight': 1.0, | |
'normalizationStrength': -0.5 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def objectiveSKLearn(): | |
def objective(params): | |
dim = params['embeddingDimension'] | |
thirdWeight = params['thirdWeight'] | |
fourthWeight = params['fourthWeight'] | |
normalizationStrength = params['normalizationStrength'] | |
# Create embeddings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def optuna_objective(trial): | |
params = { | |
'embeddingDimension': trial.suggest_int('embeddingDimension', 32, 512, log=True), | |
'thirdWeight': trial.suggest_float('thirdWeight', 0.0, 1.0), | |
'fourthWeight': trial.suggest_float('fourthWeight', 0.0, 1.0), | |
'normalizationStrength': trial.suggest_float('normalizationStrength', -1.0, 1.0) | |
} | |
return objective(params) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def modeler(k_folds=5, model='linear', show_matrix=True): | |
acc_scores = [] | |
df = create_df() | |
X, y = create_X_y(df) | |
for i in range(0, k_folds): | |
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.25) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create in-memory graph of (Paper)-[:CITES]-(Paper) | |
CALL gds.graph.create( | |
'cora', | |
'Paper', | |
{CITES: | |
{ | |
orientation: 'UNDIRECTED' | |
} | |
} | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Load edge list | |
LOAD CSV WITH HEADERS FROM 'https://raw.githubusercontent.com/cj2001/pydata2021/main/notebooks/data/cora_edges.csv' AS line | |
WITH line | |
MATCH (source:Paper {id: line.source}) | |
MATCH (target:Paper {id: line.target}) | |
MERGE (source)-[:CITES]->(target) | |
RETURN COUNT(*) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Load node list | |
LOAD CSV WITH HEADERS FROM 'https://raw.githubusercontent.com/cj2001/pydata2021/main/notebooks/data/cora_nodes.csv' AS line | |
WITH line | |
MERGE (p:Paper {id: line.id}) | |
ON CREATE SET p.subject = line.subject, p.features = line.features | |
RETURN COUNT(*) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Create constraints | |
CREATE CONSTRAINT papers IF NOT EXISTS ON (p:Paper) ASSERT p.id IS UNIQUE; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
docker run -v $HOME/graph_data/data:/data -v $HOME/graph_data/gameofthrones:/var/lib/neo4j/import neo4j:latest bin/neo4j-admin import --nodes=import/got-s1-nodes.csv --relationships=import/got-s1-edges.csv | |
&& | |
docker run -p7474:7474 -p7687:7687 -v $HOME/graph_data/data:/data -v $HOME/graph_data/gameofthrones:/var/lib/neo4j/import --env NEO4J_AUTH=neo4j/test neo4j:latest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM python:3.9.5-slim-buster | |
EXPOSE 8501 | |
WORKDIR /app | |
COPY requirements.txt . | |
RUN pip install -U pip | |
RUN pip install --no-cache-dir -r requirements.txt |
NewerOlder