本文整理了Java中weka.core.Instances.deleteAttributeAt()
方法的一些代码示例,展示了Instances.deleteAttributeAt()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Instances.deleteAttributeAt()
方法的具体详情如下:
包路径:weka.core.Instances
类名称:Instances
方法名:deleteAttributeAt
[英]Deletes an attribute at the given position (0 to numAttributes() - 1). Attribute objects after the deletion point are copied so that their indices can be decremented. Creates a fresh list to hold the old and new attribute objects.
[中]删除给定位置处的属性(0到numAttributes()-1)。复制删除点后的属性对象,以便减少其索引。创建新列表以保存旧属性对象和新属性对象。
代码示例来源:origin: com.googlecode.obvious/obviousx-weka
@Override
public void deleteAttributeAt(int arg0) {
super.deleteAttributeAt(arg0);
}
代码示例来源:origin: Waikato/meka
/**
* Delete attributes from a dataset 'D' indexed by 'indicesToRemove[]'.
* @param D dataset
* @param indicesToRemove array of attribute indices
* @return the modified dataset
*/
public static final Instances deleteAttributesAt(Instances D, int indicesToRemove[]) {//, boolean keep) {
Arrays.sort(indicesToRemove);
for(int j = indicesToRemove.length-1; j >= 0; j--) {
D.deleteAttributeAt(indicesToRemove[j]);
}
return D;
}
代码示例来源:origin: net.sf.meka/meka
/**
* Delete attributes from a dataset 'D' indexed by 'indicesToRemove[]'.
* @param D dataset
* @param indicesToRemove array of attribute indices
* @return the modified dataset
*/
public static final Instances deleteAttributesAt(Instances D, int indicesToRemove[]) {//, boolean keep) {
Arrays.sort(indicesToRemove);
for(int j = indicesToRemove.length-1; j >= 0; j--) {
D.deleteAttributeAt(indicesToRemove[j]);
}
return D;
}
代码示例来源:origin: nz.ac.waikato.cms.weka/meka
public static final Instances deleteAttributesAt(Instances D, int indicesToRemove[]) {//, boolean keep) {
Utils.sort(indicesToRemove);
for(int j = indicesToRemove.length-1; j >= 0; j--) {
D.deleteAttributeAt(indicesToRemove[j]);
}
return D;
}
代码示例来源:origin: Waikato/meka
@Override
public Instances determineOutputFormat(Instances D) throws Exception {
//System.out.println("DETERMINE OUTPUT FORMAT = "+D.numInstances());
Instances D_out = new Instances(D,0);
int L = D.classIndex();
for(int i = 0; i < L-indices.length; i++) {
D_out.deleteAttributeAt(0);
}
return D_out;
}
代码示例来源:origin: net.sf.meka/meka
@Override
public Instances determineOutputFormat(Instances D) throws Exception {
//System.out.println("DETERMINE OUTPUT FORMAT = "+D.numInstances());
Instances D_out = new Instances(D,0);
int L = D.classIndex();
for(int i = 0; i < L-indices.length; i++) {
D_out.deleteAttributeAt(0);
}
return D_out;
}
代码示例来源:origin: net.sf.meka/meka
/**
* ReplaceZasClasses - data Z[][] will be the new class labels in D.
* @param D dataset (of N instances)
* @param Z attribute space (of N rows, H columns)
* @param L column to add Z from in D
*/
public static Instances replaceZasClasses(Instances D, double Z[][], int L) {
D.setClassIndex(-1);
for(int j = 0; j < L; j++) {
D.deleteAttributeAt(0);
}
return insertZintoD(D, Z);
}
代码示例来源:origin: Waikato/meka
/**
* ReplaceZasClasses - data Z[][] will be the new class labels in D.
* @param D dataset (of N instances)
* @param Z attribute space (of N rows, H columns)
* @param L column to add Z from in D
*/
public static Instances replaceZasClasses(Instances D, double Z[][], int L) {
D.setClassIndex(-1);
for(int j = 0; j < L; j++) {
D.deleteAttributeAt(0);
}
return insertZintoD(D, Z);
}
代码示例来源:origin: net.sf.meka/meka
/**
* ReplaceZasAttributes - data Z[][] will be the new attributes in D.
* @param D dataset (of N instances)
* @param Z attribute space (of N rows, H columns)
* @param L number of classes / labels.
*/
public static Instances replaceZasAttributes(Instances D, double Z[][], int L) {
D.setClassIndex(0);
int m = D.numAttributes()-L;
for(int j = 0; j < m; j++) {
D.deleteAttributeAt(L);
}
return addZtoD(D, Z, L);
}
代码示例来源:origin: Waikato/meka
/**
* ReplaceZasAttributes - data Z[][] will be the new attributes in D.
* @param D dataset (of N instances)
* @param Z attribute space (of N rows, H columns)
* @param L number of classes / labels.
*/
public static Instances replaceZasAttributes(Instances D, double Z[][], int L) {
D.setClassIndex(0);
int m = D.numAttributes()-L;
for(int j = 0; j < m; j++) {
D.deleteAttributeAt(L);
}
return addZtoD(D, Z, L);
}
代码示例来源:origin: net.sf.meka/meka
protected Instances convert(Instances D, int j, int k) {
int L = D.classIndex();
D = new Instances(D);
D.insertAttributeAt(classAttribute,0);
D.setClassIndex(0);
for(int i = 0; i < D.numInstances(); i++) {
String c = (String)((int)Math.round(D.instance(i).value(j+1))+""+(int)Math.round(D.instance(i).value(k+1)));
D.instance(i).setClassValue(c);
}
for (int i = 0; i < L; i++)
D.deleteAttributeAt(1);
m_InstancesTemplate = new Instances(D,0);
return D;
}
代码示例来源:origin: nz.ac.waikato.cms.weka/meka
protected Instances convert(Instances D, int j, int k) {
int L = D.classIndex();
D = new Instances(D);
D.insertAttributeAt(classAttribute,0);
D.setClassIndex(0);
for(int i = 0; i < D.numInstances(); i++) {
String c = (String)((int)Math.round(D.instance(i).value(j+1))+""+(int)Math.round(D.instance(i).value(k+1)));
D.instance(i).setClassValue(c);
}
for (int i = 0; i < L; i++)
D.deleteAttributeAt(1);
m_InstancesTemplate = new Instances(D,0);
return D;
}
代码示例来源:origin: Waikato/meka
protected Instances convert(Instances D, int j, int k) {
int L = D.classIndex();
D = new Instances(D);
D.insertAttributeAt(classAttribute,0);
D.setClassIndex(0);
for(int i = 0; i < D.numInstances(); i++) {
String c = (String)((int)Math.round(D.instance(i).value(j+1))+""+(int)Math.round(D.instance(i).value(k+1)));
D.instance(i).setClassValue(c);
}
for (int i = 0; i < L; i++)
D.deleteAttributeAt(1);
m_InstancesTemplate = new Instances(D,0);
return D;
}
代码示例来源:origin: nz.ac.waikato.cms.weka/meka
/**
* SwitchAttributes - Move L label attributes from the beginning to end of attribute space of an Instances.
* Necessary because MULAN assumes label attributes are at the end, not the beginning.
* (the extra time for this process is not counted in the running-time analysis of published work).
*/
public static final Instances switchAttributes(Instances instances, int L) {
for(int j = 0; j < L; j++) {
//instances.insertAttributeAt(new Attribute(instances.attribute(0).name()+"-"),instances.numAttributes());
instances.insertAttributeAt(instances.attribute(0).copy(instances.attribute(0).name()+"-"),instances.numAttributes());
for(int i = 0; i < instances.numInstances(); i++) {
instances.instance(i).setValue(instances.numAttributes()-1,instances.instance(i).value(0));
}
instances.deleteAttributeAt(0);
}
return instances;
}
代码示例来源:origin: Waikato/meka
/**
* meka2mulan - Move L label attributes from the beginning to end of attribute space of an Instances.
* Necessary because MULAN assumes label attributes are at the end, not the beginning.
* (the extra time for this process is not counted in the running-time analysis of published work).
*/
public static final Instances meka2mulan(Instances D, int L) {
for(int j = 0; j < L; j++) {
//D.insertAttributeAt(new Attribute(D.attribute(0).name()+"-"),D.numAttributes());
D.insertAttributeAt(D.attribute(0).copy(D.attribute(0).name()+"-"),D.numAttributes());
for(int i = 0; i < D.numInstances(); i++) {
D.instance(i).setValue(D.numAttributes()-1,D.instance(i).value(0));
}
D.deleteAttributeAt(0);
}
return D;
}
代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable
/** Need to remove non-nominal attributes, set class index */
protected void setUp() throws Exception {
super.setUp();
// class index
m_Instances.setClassIndex(1);
// only nominal attributes
int i = 0;
while (i < m_Instances.numAttributes()) {
if (!m_Instances.attribute(i).isNominal())
m_Instances.deleteAttributeAt(i);
else
i++;
}
m_Comparator = new InstanceComparator(true);
}
代码示例来源:origin: Waikato/weka-trunk
/** Need to remove non-nominal attributes, set class index */
protected void setUp() throws Exception {
super.setUp();
// class index
m_Instances.setClassIndex(1);
// remove attributes that are not nominal/numeric
int i = 0;
while (i < m_Instances.numAttributes()) {
if ( !m_Instances.attribute(i).isNominal()
&& !m_Instances.attribute(i).isNumeric() )
m_Instances.deleteAttributeAt(i);
else
i++;
}
}
代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable
/** Need to remove non-nominal attributes, set class index */
protected void setUp() throws Exception {
super.setUp();
// class index
m_Instances.setClassIndex(1);
// remove attributes that are not nominal/numeric
int i = 0;
while (i < m_Instances.numAttributes()) {
if ( !m_Instances.attribute(i).isNominal()
&& !m_Instances.attribute(i).isNumeric() )
m_Instances.deleteAttributeAt(i);
else
i++;
}
}
代码示例来源:origin: Waikato/weka-trunk
/** Need to remove attributes that are not nominal/numeric */
protected void setUp() throws Exception {
super.setUp();
// remove attributes that are not nominal/numeric
int i = 0;
while (i < m_Instances.numAttributes()) {
if ( ( !m_Instances.attribute(i).isNominal()
&& !m_Instances.attribute(i).isNumeric() )
|| m_Instances.attribute(i).isDate() )
m_Instances.deleteAttributeAt(i);
else
i++;
}
}
代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable
/** Need to remove attributes that are not nominal/numeric */
protected void setUp() throws Exception {
super.setUp();
// remove attributes that are not nominal/numeric
int i = 0;
while (i < m_Instances.numAttributes()) {
if ( ( !m_Instances.attribute(i).isNominal()
&& !m_Instances.attribute(i).isNumeric() )
|| m_Instances.attribute(i).isDate() )
m_Instances.deleteAttributeAt(i);
else
i++;
}
}
内容来源于网络,如有侵权,请联系作者删除!