本文整理了Java中weka.core.Instances.delete()
方法的一些代码示例,展示了Instances.delete()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Instances.delete()
方法的具体详情如下:
包路径:weka.core.Instances
类名称:Instances
方法名:delete
[英]Removes all instances from the set.
[中]从集合中删除所有实例。
代码示例来源:origin: com.googlecode.obvious/obviousx-weka
@Override
public void removeAllRows() {
instances.delete();
}
代码示例来源:origin: stackoverflow.com
Instances data;
...
// it's important to iterate from last to first, because when we remove
// an instance, the rest shifts by one position.
for (int i = data.numInstances - 1; i >= 0; i--) {
Instance inst = data.getInstance(i);
if (condition(inst)) {
data.delete(i);
}
}
代码示例来源:origin: com.googlecode.obvious/obviousx-weka
@Override
public void delete() {
table.removeAllRows();
super.delete();
}
代码示例来源:origin: com.googlecode.obvious/obviousx-weka
@Override
public void delete(int index) {
table.removeRow(index);
super.delete(index);
}
代码示例来源:origin: com.googlecode.obvious/obviousx-weka
@Override
public boolean removeRow(int row) {
if (instances.instance(row) == null) {
return false;
}
instances.delete(row);
return true;
}
代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable
/**
* Deletes all training instances from our dataset.
*/
public void removeAllInstances() {
if (m_trainingData != null) {
m_trainingData.delete();
try {
initialize();
} catch (Exception e) {
}
;
}
}
代码示例来源:origin: Waikato/weka-trunk
/**
* Deletes all training instances from our dataset.
*/
public void removeAllInstances() {
if (m_trainingData != null) {
m_trainingData.delete();
try {
initialize();
} catch (Exception e) {
}
;
}
}
代码示例来源:origin: net.sf.meka.thirdparty/mulan
/**
* Deletes the unnecessary instances, the instances that have value 0 on
* given attribute.
*
* @param trainSet the trainSet on which the deletion will be applied
* @param attrIndex the index of the attribute that the deletion is based
*/
protected void deleteInstances(Instances trainSet, int attrIndex) {
for (int i = 0; i < trainSet.numInstances(); i++) {
if (trainSet.instance(i).stringValue(attrIndex).equals("0")) {
trainSet.delete(i);
// While deleting an instance from the trainSet, i must reduced too
i--;
}
}
}
//spark temporary edit
代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable
/**
* deletes the instance at the given index
*
* @param rowIndex the index of the row
* @param notify whether to notify the listeners
*/
public void deleteInstanceAt(int rowIndex, boolean notify) {
if ((rowIndex >= 0) && (rowIndex < getRowCount())) {
if (!m_IgnoreChanges) {
addUndoPoint();
}
m_Data.delete(rowIndex);
if (notify) {
notifyListener(new TableModelEvent(this, rowIndex, rowIndex,
TableModelEvent.ALL_COLUMNS, TableModelEvent.DELETE));
}
}
}
代码示例来源:origin: Waikato/meka
/**
* deletes the instance at the given index
*
* @param rowIndex the index of the row
* @param notify whether to notify the listeners
*/
public void deleteInstanceAt(int rowIndex, boolean notify) {
if ((rowIndex >= 0) && (rowIndex < getRowCount())) {
if (!m_IgnoreChanges) {
addUndoPoint();
}
m_Data.delete(rowIndex);
if (notify) {
notifyListener(new TableModelEvent(this, rowIndex, rowIndex,
TableModelEvent.ALL_COLUMNS, TableModelEvent.DELETE));
}
}
}
代码示例来源:origin: Waikato/weka-trunk
/**
* deletes the instance at the given index
*
* @param rowIndex the index of the row
* @param notify whether to notify the listeners
*/
public void deleteInstanceAt(int rowIndex, boolean notify) {
if ((rowIndex >= 0) && (rowIndex < getRowCount())) {
if (!m_IgnoreChanges) {
addUndoPoint();
}
m_Data.delete(rowIndex);
if (notify) {
notifyListener(new TableModelEvent(this, rowIndex, rowIndex,
TableModelEvent.ALL_COLUMNS, TableModelEvent.DELETE));
}
}
}
代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable
/**
* Resets the class values of all instances using voting. For each instance
* the class value that satisfies the most rules is choosen as new class
* value.
*
* @param dataset the dataset to work on
* @return the changed instances
* @throws Exception if something goes wrong
*/
private Instances voteDataset(Instances dataset) throws Exception {
for (int i = 0; i < dataset.numInstances(); i++) {
Instance inst = dataset.firstInstance();
inst = votedReclassifyExample(inst);
dataset.add(inst);
dataset.delete(0);
}
return dataset;
}
代码示例来源:origin: net.sf.meka.thirdparty/mulan
@Override
public void buildInternal(MultiLabelInstances mlData) throws Exception {
//Do the transformation
//and generate the classifier
pt6Trans = new IncludeLabelsTransformation();
debug("Transforming the dataset");
transformed = pt6Trans.transformInstances(mlData);
debug("Building the base-level classifier");
baseClassifier.buildClassifier(transformed);
transformed.delete();
}
代码示例来源:origin: net.sf.meka/meka
/**
* deletes the instance at the given index
*
* @param rowIndex the index of the row
* @param notify whether to notify the listeners
*/
public void deleteInstanceAt(int rowIndex, boolean notify) {
if ((rowIndex >= 0) && (rowIndex < getRowCount())) {
if (!m_IgnoreChanges) {
addUndoPoint();
}
m_Data.delete(rowIndex);
if (notify) {
notifyListener(new TableModelEvent(this, rowIndex, rowIndex,
TableModelEvent.ALL_COLUMNS, TableModelEvent.DELETE));
}
}
}
代码示例来源:origin: Waikato/meka
@Override
public Instance transformInstance(Instance x) throws Exception{
Instances tmpInst = new Instances(x.dataset());
tmpInst.delete();
tmpInst.add(x);
Instances features = this.extractPart(tmpInst, false);
Instances pseudoLabels = new Instances(this.compressedMatrix);
Instance tmpin = pseudoLabels.instance(0);
pseudoLabels.delete();
pseudoLabels.add(tmpin);
for ( int i = 0; i< pseudoLabels.classIndex(); i++) {
pseudoLabels.instance(0).setMissing(i);
}
Instances newDataSet = Instances.mergeInstances(pseudoLabels, features);
newDataSet.setClassIndex(this.size);
return newDataSet.instance(0);
}
代码示例来源:origin: net.sf.meka/meka
@Override
public Instance transformInstance(Instance x) throws Exception{
Instances tmpInst = new Instances(x.dataset());
tmpInst.delete();
tmpInst.add(x);
Instances features = this.extractPart(tmpInst, false);
Instances pseudoLabels = new Instances(this.compressedMatrix);
Instance tmpin = pseudoLabels.instance(0);
pseudoLabels.delete();
pseudoLabels.add(tmpin);
for ( int i = 0; i< pseudoLabels.classIndex(); i++) {
pseudoLabels.instance(0).setMissing(i);
}
Instances newDataSet = Instances.mergeInstances(pseudoLabels, features);
newDataSet.setClassIndex(this.size);
return newDataSet.instance(0);
}
代码示例来源:origin: nz.ac.waikato.cms.weka/weka-stable
/**
* This will remove all buffered instances from the inputformat dataset. Use
* this method rather than getInputFormat().delete();
*/
protected void flushInput() {
if ((m_InputStringAtts.getAttributeIndices().length > 0)
|| (m_InputRelAtts.getAttributeIndices().length > 0)) {
m_InputFormat = m_InputFormat.stringFreeStructure();
m_InputStringAtts =
new StringLocator(m_InputFormat, m_InputStringAtts.getAllowedIndices());
m_InputRelAtts = new RelationalLocator(m_InputFormat,
m_InputRelAtts.getAllowedIndices());
} else {
// This more efficient than new Instances(m_InputFormat, 0);
m_InputFormat.delete();
}
}
代码示例来源:origin: net.sf.meka/meka
@Override
public Instance transformInstance(Instance x) throws Exception{
Instances tmpInst = new Instances(x.dataset());
tmpInst.delete();
tmpInst.add(x);
Instances features = this.extractPart(tmpInst, false);
Instances pseudoLabels = new Instances(this.compressedTemplateInst);
Instance tmpin = pseudoLabels.instance(0);
pseudoLabels.delete();
pseudoLabels.add(tmpin);
for ( int i = 0; i< pseudoLabels.classIndex(); i++) {
pseudoLabels.instance(0).setMissing(i);
}
Instances newDataSet = Instances.mergeInstances(pseudoLabels, features);
newDataSet.setClassIndex(pseudoLabels.numAttributes());
return newDataSet.instance(0);
}
代码示例来源:origin: Waikato/meka
@Override
public Instance transformInstance(Instance x) throws Exception{
Instances tmpInst = new Instances(x.dataset());
tmpInst.delete();
tmpInst.add(x);
Instances features = this.extractPart(tmpInst, false);
Instances pseudoLabels = new Instances(this.compressedTemplateInst);
Instance tmpin = pseudoLabels.instance(0);
pseudoLabels.delete();
pseudoLabels.add(tmpin);
for ( int i = 0; i< pseudoLabels.classIndex(); i++) {
pseudoLabels.instance(0).setMissing(i);
}
Instances newDataSet = Instances.mergeInstances(pseudoLabels, features);
newDataSet.setClassIndex(pseudoLabels.numAttributes());
return newDataSet.instance(0);
}
代码示例来源:origin: Waikato/weka-trunk
/**
* This will remove all buffered instances from the inputformat dataset. Use
* this method rather than getInputFormat().delete();
*/
protected void flushInput() {
if ((m_InputStringAtts.getAttributeIndices().length > 0)
|| (m_InputRelAtts.getAttributeIndices().length > 0)) {
m_InputFormat = m_InputFormat.stringFreeStructure();
m_InputStringAtts =
new StringLocator(m_InputFormat, m_InputStringAtts.getAllowedIndices());
m_InputRelAtts = new RelationalLocator(m_InputFormat,
m_InputRelAtts.getAllowedIndices());
} else {
// This more efficient than new Instances(m_InputFormat, 0);
m_InputFormat.delete();
}
}
内容来源于网络,如有侵权,请联系作者删除!