1
0
mirror of https://github.com/sjwhitworth/golearn.git synced 2025-04-26 13:49:14 +08:00

feature: adding attributes

This commit is contained in:
Guilherme Reis 2023-03-03 16:07:32 -03:00
parent 81edd9b55b
commit b4ebccc0e1

View File

@ -0,0 +1,20 @@
```go
// 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)
}
```
**Trecho de código: Adicionando dois novos atributos a um `UpdatableDataGrid` em branco**
* Os atributos só podem ser adicionados a `UpdatableDataGrids` vazios (ou seja, antes de chamar `Extend` para alocar memória)..