Skip to content

Instantly share code, notes, and snippets.

hamletbatista

Block or report user

Report or block hamletbatista

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View atis_test_predictions.py
test_df = pd.read_csv("atis.test.csv", index_col=0)
model = LudwigModel.load("results/experiment_run_6/model")
predictions = model.predict(test_df)
test_df.reset_index().join(predictions)[["tokens", "intent_predictions", "slots_predictions"]]
View atis_model_definition.yaml
input_features:
-
name: tokens
type: text
level: word
encoder: rnn
cell_type: lstm
bidirectional: true
num_layers: 2
reduce_output: null
View load_atis_dataset.py
#From https://www.kaggle.com/siddhadev/atis-dataset-clean/home
#unzip atis-dataset-clean.zip
df = pd.read_csv("atis.train.csv", index_col=0)
df.groupby("intent").count()
View spacy_hotel_word_vector.py
#hotel word vector representation
print(tokens[0]) #output -> hotel
print(tokens[0].vector)
#output
array([ 4.2714e-01, 1.2711e-01, 3.3711e-01, -1.0423e+00, 6.4144e-01,
-1.2071e-01, 5.0131e-02, -4.7584e-01, -1.0312e-01, 2.9255e+00,
-5.8213e-01, -3.2514e-01, -3.5034e-01, 2.1803e-01, 1.0048e-03,
-8.2658e-01, -1.0869e-01, 1.4241e+00, 6.1642e-01, -4.4746e-02,
-4.5506e-01, 4.3144e-01, -5.7901e-02, -1.7059e-02, 6.4482e-02,
View spacy_word_similarity.py
#python -m spacy download en_core_web_lg
import spacy
nlp = spacy.load('en_core_web_lg')
tokens = nlp(u'hotel resort car bike')
#comparing 3 words
for token1 in tokens:
View ludwig_get_questions_predictions.py
model = LudwigModel.load("results/experiment_run_3/model")
test_df = pd.read_csv("Question Report_Page 1_Table.csv")
#we rename Query to Questions to match what the model expects
predictions = model.predict(test_df.rename(columns={'Query': 'Questions'} ))
test_df.join(predictions)[["Query", "Category0_predictions"]]
View ludwig_parallel_cnn_questions.yaml
input_features:
-
name: Questions
type: text
level: word
encoder: parallel_cnn
output_features:
-
name: Category0
View load_questions_dataset_colab.py
#https://colab.research.google.com/notebooks/io.ipynb
from google.colab import files
uploaded = files.upload()
for fn in uploaded.keys():
print('User uploaded file "{name}" with length {length} bytes'.format(
name=fn, length=len(uploaded[fn])))
df = pd.read_csv("Question_Classification_Dataset.csv", index_col=0)
View ludwig_get_predictions.py
from ludwig.api import LudwigModel
model = LudwigModel.load("results/experiment_run_0/model")
predictions = model.predict(test_df)
test_df.join(predictions)[["text", "category_predictions"]]
View ludwig_google_trends_dataset.py
You can’t perform that action at this time.