<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def r_squared(obs, pred, one_to_one=False, log_trans=False):
 """ R^2 value for a regression of observed and predicted data Parameters obs : iterable Observed data pred : iterable Predicted data one_to_one : bool If True, calculates the R^2 based on the one-to-one line (see [#]_), and if False, calculates the standard R^2 based on a linear regression. Default False. log_trans : bool If True, log transforms obs and pred before R^2 calculation. Returns ------- float R^2 value Notes ----- Using the traditional R^2 to compare the fit of observed and predicted values may be misleading as the relationship may not be one-to-one but the R^2 value may be quite high. The one-to-one option alleviates this problem. Note that with the one-to-one option R^2 can be negative. Examples -------- 0.99336568326291697 -6.8621799432144988 0.97651897660174425 0.97591430200514639 References .. [#] White, E., Thibault, K., & Xiao, X. (2012). Characterizing the species abundance distributions across taxa and ecosystems using a simple maximum entropy model. Ecology, 93(8), 1772-8 """


    if log_trans:
        obs = np.log(obs)
        pred = np.log(pred)

    if one_to_one:
        r_sq = 1 - (sum_of_squares(obs, pred) /
                    sum_of_squares(obs, np.mean(obs)))
    else:
        b0, b1, r, p_value, se = stats.linregress(obs, pred)
        r_sq = r ** 2

    return r_sq