weight_target: Weight target variable

View source: R/tools.R

weight_targetR Documentation

Weight target variable

Description

Create weights for the target variable in your dataset so that are equal weights for target = 0 and target = 1. Target must be 0/1, FALSE/TRUE ore no/yes

Usage

weight_target(data, target)

Arguments

data

A dataset

target

Target variable (0/1, TRUE/FALSE, yes/no)

Value

Weights for each observation (as a vector)

Examples

iris$is_versicolor <- ifelse(iris$Species == "versicolor", 1, 0)
weights <- weight_target(iris, target = is_versicolor)
versicolor <- iris$is_versicolor
table(versicolor, weights)

explore documentation built on Sept. 11, 2024, 7:40 p.m.