mirror of
https://github.com/saymrwulf/prophet.git
synced 2026-11-18 08:53:42 +00:00
Verify that cap > floor (#807)
This commit is contained in:
parent
269133c133
commit
28cd55241f
2 changed files with 7 additions and 0 deletions
|
|
@ -393,6 +393,9 @@ setup_dataframe <- function(m, df, initialize_scales = FALSE) {
|
||||||
if (!(exists('cap', where=df))) {
|
if (!(exists('cap', where=df))) {
|
||||||
stop('Capacities must be supplied for logistic growth.')
|
stop('Capacities must be supplied for logistic growth.')
|
||||||
}
|
}
|
||||||
|
if (any(df$cap <= df$floor)) {
|
||||||
|
stop('cap must be greater than floor (which defaults to 0).')
|
||||||
|
}
|
||||||
df <- df %>%
|
df <- df %>%
|
||||||
dplyr::mutate(cap_scaled = (cap - floor) / m$y.scale)
|
dplyr::mutate(cap_scaled = (cap - floor) / m$y.scale)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -274,6 +274,10 @@ class Prophet(object):
|
||||||
"Capacities must be supplied for logistic growth in "
|
"Capacities must be supplied for logistic growth in "
|
||||||
"column 'cap'"
|
"column 'cap'"
|
||||||
)
|
)
|
||||||
|
if (df['cap'] <= df['floor']).any():
|
||||||
|
raise ValueError(
|
||||||
|
'cap must be greater than floor (which defaults to 0).'
|
||||||
|
)
|
||||||
df['cap_scaled'] = (df['cap'] - df['floor']) / self.y_scale
|
df['cap_scaled'] = (df['cap'] - df['floor']) / self.y_scale
|
||||||
|
|
||||||
df['t'] = (df['ds'] - self.start) / self.t_scale
|
df['t'] = (df['ds'] - self.start) / self.t_scale
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue