-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Adding Attributes
Richard Townsend edited this page Aug 10, 2014
·
3 revisions
// Create a new, empty DenseInstances
newInst := base.NewDenseInstances()
// Create some Attributes
attrs := make([]base.Attribute, 2)
attrs[0] = base.NewFloatAttribute("Arbitrary Float Quantity")
attrs[1] = new(base.CategoricalAttribute)
attrs[1].SetName("Class")
// Add the attributes
newSpecs := make([]base.AttributeSpec, len(attrs))
for i, a := range attrs {
newSpecs[i] = newInst.AddAttribute(a)
}
Code excerpt: Adding two new Attributes to a blank UpdatableDataGrid
- Attributes can only be added to empty
UpdatableDataGrids
(i.e. before callingExtend
to allocate memory). -
AddAttribute
returns an [AttributeSpec
](Attribute Specifications) describing where theAttribute
was inserted.