Reputation: 469
i have Feature 1 , Feature 2, Feature 3
How to add new "Feature 4" and "Feature 5 ", ?
Code below only return original Data Table (out_data = in_data)
what i want is **out_data = in_data + new feature "Feature 4" + new feature "Feature 5" **
Note: Feature 4 is continous and Feature 5 is discrete ("yes" or "no")
def add_new_column(data):
domain = Domain(data.domain.variables,data.domain.class_vars,data.domain.metas)
return Table(domain, data)
out_data = add_new_column(in_data)
Upvotes: 1
Views: 2300
Reputation: 1124
Try the code below:
from Orange.data import ContinuousVariable, DiscreteVariable, Domain
var1 = ContinuousVariable("Feature 4")
var2 = DiscreteVariable("Feature 5", values=["yes", "no"])
domain = in_data.domain
new_domain = Domain(attributes=domain.attributes + (var1, var2), metas=domain.metas, class_vars=domain.class_vars)
out_data = in_data.transform(new_domain)
Upvotes: 1