This file contains hidden or 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
| import gradio as gr | |
| import pandas as pd | |
| import random | |
| def get_random_data(): | |
| return df.sample(10) | |
| def display_data(): |
This file contains hidden or 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
| import tensorflow_hub as hub | |
| TFHUB_URL = "https://tfhub.dev/google/universal-sentence-encoder/2" | |
| sentence_encoder = hub.Module(TFHUB_URL) |
This file contains hidden or 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
| val configJanus = new PropertiesConfiguration(configJanusPath) | |
| val graph = JanusGraphFactory.open(configJanus) | |
| // create schema | |
| val tx = graph.buildTransaction().enableBatchLoading().start() | |
| while (iter.hasNext) { | |
| val item = iter.next() | |
| val key = item.getString(0) | |
| val value = item.getString(1) | |
| val productVertex = tx.addVertex(T.label, NodeConstraint.PRODUCT_LABEL) |
This file contains hidden or 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
| graph = JanusGraphFactory.open("conf/gremlin-server/janusgraph-cql-es.properties") | |
| mgmt = graph.openManagement() | |
| mgmt.updateIndex(mgmt.getGraphIndex("ByShopIDAndRefID"), SchemaAction.REINDEX).get() | |
| mgmt.updateIndex(mgmt.getGraphIndex("ByShopID"), SchemaAction.REINDEX).get() |
This file contains hidden or 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
| graph = JanusGraphFactory.open("conf/gremlin-server/janusgraph-cql-es.properties") | |
| mgmt = graph.openManagement() | |
| mgmt.makePropertyKey("shop_id").dataType(Long.class).cardinality(Cardinality.SINGLE).make() | |
| mgmt.makePropertyKey("ref_id").dataType(Long.class).cardinality(Cardinality.SINGLE).make() | |
| mgmt.commit() | |
| mgmt = graph.openManagement() | |
| shopID = mgmt.getPropertyKey("shop_id") | |
| refId = mgmt.getPropertyKey("ref_id") |
This file contains hidden or 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
| map_col = lambda dat,col: col+"-"+dat.map(str) | |
| gen_hash_item = lambda field, feat: '{0}:{1}:1'.format(field,hashstr(feat)) | |
| def gen_hash_row(feats,label): | |
| result = [] | |
| for idx, item in enumerate(feats): | |
| val = item.split('-')[-1] | |
| if val != 'nan': | |
| result.append(gen_hash_item(idx,item)) | |
| lbl = 1 | |
| if label == 0: |
This file contains hidden or 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
| // Use Gists to store code you would like to remember later on | |
| console.log(window); // log the "window" object to the console |