# R/feature_ela_meta_model.R In flacco: Feature-Based Landscape Analysis of Continuous and Constrained Optimization Problems

```calculateMetaModelFeatures = function(feat.object) {
assertClass(feat.object, "FeatureObject")
measureTime(expression({
X = extractFeatures(feat.object)
y = extractObjective(feat.object)
df = as.data.frame(X)

## Simple linear model:
lin.model = lm(y ~ ., data = df)
model.coeff = coef(lin.model)
ela_meta.lin_simple.intercept = as.numeric(model.coeff[1L]),
ela_meta.lin_simple.coef.min = min(abs(model.coeff[-1L])),
ela_meta.lin_simple.coef.max = max(abs(model.coeff[-1L])),
ela_meta.lin_simple.coef.max_by_min = max(abs(model.coeff[-1L])) / min(abs(model.coeff[-1L]))
)

## Linear interactions:
lin.model = lm(y ~ .^2, data = df) ## Include interactions

cns = names(df)
df = cbind(df, df^2)
cns.squared = sprintf("%s_squared", cns)
names(df) = c(cns, cns.squared)
quad.model = lm(y ~ ., data = df)

quad.model_matrix = model.matrix(~ .^2, data = df)
res
}), "ela_meta")
}

pred = fitted(mod)
resi = residuals(mod)
SS_reg = crossprod(pred - mean(pred))
SS_res = crossprod(resi)
SS_total = SS_reg + SS_res
n = mod\$df.residual
p = mod\$rank
drop(1 - (SS_res / SS_total) / ((n - p - 1) / (n - 1)))
}
```

## Try the flacco package in your browser

Any scripts or data that you put into this service are public.

flacco documentation built on June 20, 2017, 9:06 a.m.