evaluate: evaluate

Description Usage Arguments Value Examples

View source: R/train_models.R

Description

This function evaluates the performance of a trained model.

Usage

1
evaluate(model_path, X_test, y_test)

Arguments

model_path

Path to HDF5 file containing model. Should be of the form "models/{model type}_{embedding type}_{embedding dimensionality}d.h5"

X_test

data.frame or matrix of vectorized Tweets

y_test

Labels for testing data. 0 for liberal, 1 for conservative.

Value

List of performance metrics. Currently, a confusion matrix, overall prediction accuracy, precision, recall, and F1 score are return.

Examples

1
2
3
4
5
6
7
8
9
data("ideo_tweets")
ideo_tokenizer <- text_tokenizer(num_words=20000)
ideo_tokenizer <- fit_text_tokenizer(ideo_tokenizer, ideo_tweets$text)
texts <- texts_to_vectors(ideo_tweets$text, ideo_tokenizer)
labels <- tweets$ideo_cat

train_test <- train_test_split(texts, labels)

evaluate("models/bi-lstm_w2v_25d.h5", train_test$X_test, train_test$y_test)

alex-gottlieb/deepIdeology documentation built on Nov. 1, 2019, 9:09 p.m.