predict_quality: Apply scoring models for predictions

View source: R/predict_values.R

predict_qualityR Documentation

Apply scoring models for predictions

Description

Apply scoring models to ReaderBench, CohMetrix, and/or GAMET files. Holistic writing quality can be generated from Readerbench (model = 'rb_mod2') or Coh-Metrix files (model = 'coh_mod2'). Also, Correct Word Sequences and Correct Minus Incorrect Word Sequences can be generated from a GAMET file (model = 'gamet_cws1').

Usage

predict_quality(model, data, store = FALSE, name = "filename.csv")

Arguments

model

A string telling which scoring model to use. Options are: 'rb_mod1', 'rb_mod2', 'rb_mod3narr', 'rb_mod3exp', 'rb_mod3per', 'rb_mod3all', 'rb_mod3narr_v2', 'rb_mod3exp_v2', 'rb_mod3per_v2', or 'rb_mod3all_v2' for ReaderBench files to generate holistic quality, 'coh_mod1', 'coh_mod2' 'coh_mod3narr', 'coh_mod3exp', 'coh_mod3per' or 'coh_mod3all' for Coh-Metrix files to generate holistic quality, and 'gamet_cws1' to generate Correct Word Sequences (CWS) and Correct Minus Incorrect Word Sequences (CIWS) scores from a GAMET file.

data

The name of the R object corresponding to the data file. The import_gametimport_gamet(), import_cohimport_coh(), or import_rbimport_rb() functions should be used before this function to generate these data objects.

store

When store = TRUE, this function will generate scores, merge the scores into the data file, and export the file as .csv in the working directory. When store = FALSE (the default) the predicted scores are returned to a user-specified object or the R console.

name

When store = TRUE, the name parameter gives the filename for the .csv file (for example, "filename.csv") that is generated to the working directory.

Value

Depending on the model parameter option selected, predicted quality (or CWS/CIWS scores) and the ID variable (parsed from the file names used when generating the ReaderBench, Coh-Metrix, and/or GAMET output files) are returned.

Author(s)

Sterett H. Mercer <sterett.mercer@ubc.ca>

See Also

import_rb import_coh import_gamet

Examples

###Examples using sample data included in writeAlizer package

##Example 1: ReaderBench output file
#load package
library(writeAlizer)

#get path of sample ReaderBench output file
file_path1 <- system.file("extdata", "sample_rb.csv", package = "writeAlizer")

#see path to sample file
file_path1

#import file and store as "rb_file"
rb_file <- import_rb(file_path1)

#Generate holistic quality from "rb_file"
#and return scores to an object called "rb_quality":
rb_quality <- predict_quality('rb_mod2', rb_file, store = FALSE)

#display quality scores
rb_quality

##Example 2: Coh-Metrix output file
#get path of sample Coh-Metrix output file
file_path2 <- system.file("extdata", "sample_coh.csv", package = "writeAlizer")

#see path to sample file
file_path2

#import file and store as "coh_file"
coh_file <- import_coh(file_path2)

#Generate holistic quality from a Coh-Metrix file (coh_file),
#return scores to an object called "coh_quality",
coh_quality <- predict_quality('coh_mod2', coh_file, store = FALSE)

#display quality scores
coh_quality

##Example 3: GAMET output file
#get path of sample GAMET output file
file_path3 <- system.file("extdata", "sample_gamet.csv", package = "writeAlizer")

#see path to sample GAMET file
file_path3

#import files, merge, and store as "gam_file"
gam_file <- import_gamet(file_path3)

#Generate CWS and CIWS scores from a GAMET file
#(gam_file) and return scores to an object called "gamet_CWS_CIWS"
gamet_CWS_CIWS <- predict_quality('gamet_cws1', gam_file, store = FALSE)

#display quality scores
gamet_CWS_CIWS

shmercer/writeAlizer documentation built on Feb. 13, 2024, 8:58 a.m.