rf2score: Raw risk factors value to score.

Description Usage Arguments Details Value Author(s) Examples

Description

The input risk factors should be a data.frame or a tibble, which contains all raw risk factors value and should not contians user_id and others. The score_config_list should be a list, *_values should be in front of *_scores.

Usage

1
rf2score(rf_df, score_config_list)

Arguments

rf_df

Risk factors data frame(exclude user_id)

score_config_list

A List contains all riskFactors value and score index, read from .RDS file.

Details

You should carefull about the risk facotrs rf_df names and the score_config_list names. *_values/*_scores and the risk factors names should be the same.

Value

a tibble with every risk factor score

Author(s)

Wei Zhao

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
## Not run: 
require(dplyr)
score_config_list <- readRDS("result/score_config_list.RDS")
pj_rf <- readr::read_csv("data/pingjia/pingjia_result.csv",col_names = FALSE)
nameTmp <- c("acc_count_phk","act_radius","dec_count_phk","high_curv_tr","holiday_tr",
"interstate_r","lane_change_phk","late_night_tr","long_tr","main_act_prov"
, "mileage","speeding_lvl", "speeding_phk", "trip_dis_e", "turn_count_phk","user_id")
names(pj_rf) <- nameTmp

risk_factor_names <- setdiff(nameTmp, c("user_id","main_act_prov"))
pj_rf <- pj_rf %>% select(!!risk_factor_names)

rf2score(pj_rf, score_config_list)

## End(Not run)

BruceZhaoR/pjutils documentation built on May 20, 2019, 11:38 a.m.