本文整理匯總了Java中weka.core.Instance.stringValue方法的典型用法代碼示例。如果您正苦於以下問題:Java Instance.stringValue方法的具體用法?Java Instance.stringValue怎麽用?Java Instance.stringValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類weka.core.Instance
的用法示例。
在下文中一共展示了Instance.stringValue方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testTransactionLookup
import weka.core.Instance; //導入方法依賴的package包/類
/**
* testTransactionLookup
*/
@Test
public void testTransactionLookup() throws Exception {
int txn_id_idx = FeatureExtractor.TXNID_ATTRIBUTE_IDX;
assertEquals(workload.getTransactionCount(), data.numInstances());
List<TransactionTrace> txns = new ArrayList<TransactionTrace>(workload.getTransactions());
// System.err.println(StringUtil.join("\n", txns));
// System.err.println();
for (int i = 0, cnt = data.numInstances(); i < cnt; i++) {
Instance inst = data.instance(i);
assertNotNull(inst);
String value = inst.stringValue(txn_id_idx);
// System.err.println("VALUE: " + value);
Long txn_id = Long.valueOf(value);
assertNotNull(txn_id);
TransactionTrace txn_trace = workload.getTransaction(txn_id);
TransactionTrace expected = txns.get(i);
// System.err.println("EXPECTED: " + expected.getTransactionId());
// System.err.println("FOUND: " + txn_id);
assertNotNull(String.format("[%05d] Failed to txn #%d", i, txn_id), txn_trace);
assertEquals(expected.getTransactionId(), txn_trace.getTransactionId());
} // FOR
}
示例2: buildClassifier
import weka.core.Instance; //導入方法依賴的package包/類
@Override
public void buildClassifier(Instances data) throws Exception {
// Initialise training dataset
Attribute classAttribute = data.classAttribute();
classedData = new HashMap<>();
classedDataIndices = new HashMap<>();
for (int c = 0; c < data.numClasses(); c++) {
classedData.put(data.classAttribute().value(c), new ArrayList<SymbolicSequence>());
classedDataIndices.put(data.classAttribute().value(c), new ArrayList<Integer>());
}
train = new SymbolicSequence[data.numInstances()];
classMap = new String[train.length];
maxLength = 0;
for (int i = 0; i < train.length; i++) {
Instance sample = data.instance(i);
MonoDoubleItemSet[] sequence = new MonoDoubleItemSet[sample.numAttributes() - 1];
maxLength = Math.max(maxLength, sequence.length);
int shift = (sample.classIndex() == 0) ? 1 : 0;
for (int t = 0; t < sequence.length; t++) {
sequence[t] = new MonoDoubleItemSet(sample.value(t + shift));
}
train[i] = new SymbolicSequence(sequence);
String clas = sample.stringValue(classAttribute);
classMap[i] = clas;
classedData.get(clas).add(train[i]);
classedDataIndices.get(clas).add(i);
}
warpingMatrix = new double[maxLength][maxLength];
U = new double[maxLength];
L = new double[maxLength];
maxWindow = Math.round(1 * maxLength);
searchResults = new String[maxWindow+1];
nns = new int[maxWindow+1][train.length];
dist = new double[train.length][train.length];
// Start searching for the best window
searchBestWarpingWindow();
// Saving best windows found
System.out.println("Windows found=" + bestWarpingWindow + " Best Acc=" + (1-bestScore));
}
示例3: buildClassifier
import weka.core.Instance; //導入方法依賴的package包/類
@Override
public void buildClassifier(Instances data) throws Exception {
// Initialise training dataset
Attribute classAttribute = data.classAttribute();
classedData = new HashMap<>();
classedDataIndices = new HashMap<>();
for (int c = 0; c < data.numClasses(); c++) {
classedData.put(data.classAttribute().value(c), new ArrayList<SymbolicSequence>());
classedDataIndices.put(data.classAttribute().value(c), new ArrayList<Integer>());
}
train = new SymbolicSequence[data.numInstances()];
classMap = new String[train.length];
maxLength = 0;
for (int i = 0; i < train.length; i++) {
Instance sample = data.instance(i);
MonoDoubleItemSet[] sequence = new MonoDoubleItemSet[sample.numAttributes() - 1];
maxLength = Math.max(maxLength, sequence.length);
int shift = (sample.classIndex() == 0) ? 1 : 0;
for (int t = 0; t < sequence.length; t++) {
sequence[t] = new MonoDoubleItemSet(sample.value(t + shift));
}
train[i] = new SymbolicSequence(sequence);
String clas = sample.stringValue(classAttribute);
classMap[i] = clas;
classedData.get(clas).add(train[i]);
classedDataIndices.get(clas).add(i);
}
warpingMatrix = new double[maxLength][maxLength];
U = new double[maxLength];
L = new double[maxLength];
U1 = new double[maxLength];
L1 = new double[maxLength];
maxWindow = Math.round(1 * maxLength);
searchResults = new String[maxWindow+1];
nns = new int[maxWindow+1][train.length];
dist = new double[maxWindow+1][train.length];
cache = new SequenceStatsCache(train, maxWindow);
lazyUCR = new LazyAssessNNEarlyAbandon[train.length][train.length];
for (int i = 0; i < train.length; i++) {
for (int j = 0; j < train.length; j++) {
lazyUCR[i][j] = new LazyAssessNNEarlyAbandon(cache);
}
}
// Start searching for the best window
searchBestWarpingWindow();
// Saving best windows found
System.out.println("Windows found=" + bestWarpingWindow + " Best Acc=" + (1-bestScore));
}
示例4: buildClassifier
import weka.core.Instance; //導入方法依賴的package包/類
@Override
public void buildClassifier(Instances data) throws Exception {
// Initialise training dataset
Attribute classAttribute = data.classAttribute();
classedData = new HashMap<>();
classedDataIndices = new HashMap<>();
for (int c = 0; c < data.numClasses(); c++) {
classedData.put(data.classAttribute().value(c), new ArrayList<SymbolicSequence>());
classedDataIndices.put(data.classAttribute().value(c), new ArrayList<Integer>());
}
train = new SymbolicSequence[data.numInstances()];
classMap = new String[train.length];
maxLength = 0;
for (int i = 0; i < train.length; i++) {
Instance sample = data.instance(i);
MonoDoubleItemSet[] sequence = new MonoDoubleItemSet[sample.numAttributes() - 1];
maxLength = Math.max(maxLength, sequence.length);
int shift = (sample.classIndex() == 0) ? 1 : 0;
for (int t = 0; t < sequence.length; t++) {
sequence[t] = new MonoDoubleItemSet(sample.value(t + shift));
}
train[i] = new SymbolicSequence(sequence);
String clas = sample.stringValue(classAttribute);
classMap[i] = clas;
classedData.get(clas).add(train[i]);
classedDataIndices.get(clas).add(i);
}
warpingMatrix = new double[maxLength][maxLength];
U = new double[maxLength];
L = new double[maxLength];
U1 = new double[maxLength];
L1 = new double[maxLength];
maxWindow = Math.round(1 * maxLength);
searchResults = new String[maxWindow+1];
nns = new int[maxWindow+1][train.length];
dist = new double[train.length][train.length];
cache = new SequenceStatsCache(train, maxWindow);
lazyUCR = new LazyAssessNNEarlyAbandon[train.length][train.length];
for (int i = 0; i < train.length; i++) {
for (int j = 0; j < train.length; j++) {
lazyUCR[i][j] = new LazyAssessNNEarlyAbandon(cache);
}
}
// Start searching for the best window
searchBestWarpingWindow();
// Saving best windows found
System.out.println("Windows found=" + bestWarpingWindow + " Best Acc=" + (1-bestScore));
}
示例5: buildClassifier
import weka.core.Instance; //導入方法依賴的package包/類
@Override
public void buildClassifier(Instances data) throws Exception {
// Initialise training dataset
Attribute classAttribute = data.classAttribute();
classedData = new HashMap<>();
classedDataIndices = new HashMap<>();
for (int c = 0; c < data.numClasses(); c++) {
classedData.put(data.classAttribute().value(c), new ArrayList<SymbolicSequence>());
classedDataIndices.put(data.classAttribute().value(c), new ArrayList<Integer>());
}
train = new SymbolicSequence[data.numInstances()];
classMap = new String[train.length];
maxLength = 0;
for (int i = 0; i < train.length; i++) {
Instance sample = data.instance(i);
MonoDoubleItemSet[] sequence = new MonoDoubleItemSet[sample.numAttributes() - 1];
maxLength = Math.max(maxLength, sequence.length);
int shift = (sample.classIndex() == 0) ? 1 : 0;
for (int t = 0; t < sequence.length; t++) {
sequence[t] = new MonoDoubleItemSet(sample.value(t + shift));
}
train[i] = new SymbolicSequence(sequence);
String clas = sample.stringValue(classAttribute);
classMap[i] = clas;
classedData.get(clas).add(train[i]);
classedDataIndices.get(clas).add(i);
}
warpingMatrix = new double[maxLength][maxLength];
U = new double[maxLength];
L = new double[maxLength];
maxWindow = Math.round(1 * maxLength);
searchResults = new String[maxWindow+1];
nns = new int[maxWindow+1][train.length];
dist = new double[maxWindow+1][train.length];
// Start searching for the best window
searchBestWarpingWindow();
// Saving best windows found
System.out.println("Windows found=" + bestWarpingWindow + " Best Acc=" + (1-bestScore));
}