本文整理汇总了C#中Instance.setValue方法的典型用法代码示例。如果您正苦于以下问题:C# Instance.setValue方法的具体用法?C# Instance.setValue怎么用?C# Instance.setValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Instance
的用法示例。
在下文中一共展示了Instance.setValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: readDataTimer_Tick
//.........这里部分代码省略.........
if (Extractor.GenerateFeatureVector(lastTimeStamp))
{
Extractor.TrainingTime[current_activity] = (int)Extractor.TrainingTime[current_activity] + 200;//Extractor.Configuration.OverlapTime;// get it from configuration
string arffSample = Extractor.toString() + "," + current_activity.Replace(' ', '_');
this.tw.WriteLine(arffSample);
this.label8.Text = Extractor.DiscardedLossRateWindows.ToString();
//this.label10.Text = Extractor.DiscardedConsecutiveLossWindows.ToString();
}
}
else
{
// this.label5.Text = "TR in " + ((int)(this.startActivityTime - Environment.TickCount) / 1000) + " secs";
// this.label11.Text = "Training " + current_activity + " in " + ((int)(this.startActivityTime - Environment.TickCount) / 1000) + " secs";
}
}
else // Manual Training
{
}
}
//Classifying
if (isClassifying==true)
{
double lastTimeStamp = Extractor.StoreMITesWindow();
if (Extractor.GenerateFeatureVector(lastTimeStamp))
{
Instance newinstance = new Instance(instances.numAttributes());
newinstance.Dataset = instances;
for (int i = 0; (i < Extractor.Features.Length); i++)
newinstance.setValue(instances.attribute(i), Extractor.Features[i]);
double predicted = classifier.classifyInstance(newinstance);
string predicted_activity = newinstance.dataset().classAttribute().value_Renamed((int)predicted);
int currentIndex=(int)labelIndex[predicted_activity];
labelCounters[currentIndex] = (int)labelCounters[currentIndex] + 1;
classificationCounter++;
if (classificationCounter == Extractor.Configuration.SmoothWindows)
{
classificationCounter = 0;
int mostCount = 0;
string mostActivity = "";
for (int j=0;(j<labelCounters.Length);j++)
{
if (labelCounters[j] > mostCount)
mostActivity = activityLabels[j];
labelCounters[j] = 0;
}
this.label6.Text = mostActivity;
//this.label11.Text = "Fahd is "+mostActivity;
}
}
}
if (activityCountWindowSize > Extractor.Configuration.QualityWindowSize) //write a line to CSV and initialize
{
DateTime now= DateTime.Now;
DateTime origin = new DateTime(1970, 1, 1, 0, 0, 0, 0);
TimeSpan diff = now.Subtract(origin);
string timestamp = diff.TotalMilliseconds + "," + now.ToString("yyyy'-'MM'-'dd' 'HH':'mm':'ssK");
示例2: Classify
public string Classify(double lastTimestamp)
{
string predicted_class = null;
//attempt to generate a feature vector
if (Extractor.GenerateFeatureVector(lastTimestamp))
{
Instance newinstance = new Instance(instances.numAttributes());
newinstance.Dataset = instances;
for (int i = 0; (i < this.features.Count); i++)
newinstance.setValue(instances.attribute(i), Extractor.Features[this.featureIndex[i]]);
double predicted = classifier.classifyInstance(newinstance);
predicted_class = newinstance.dataset().classAttribute().value_Renamed((int)predicted);
}
return predicted_class;
}
示例3: readDataTimer_Tick
//.........这里部分代码省略.........
}
//if we are waiting for the activity to be trained
else
this.trainingLabel.Text = "Training " + current_activity + " in " + ((int)(this.startActivityTime - Environment.TickCount) / 1000) + " secs";
}
else // Manual Training
{
}
}
#endregion Train in realtime and generate ARFF File
#region Classifying activities
#if (PocketPC)
if (isClassifying == true)
{
double lastTimeStamp = Extractor.StoreMITesWindow();
if ((this.sensors.HasBuiltinSensors) && (polledData != null))
{
//aMITesLoggerPLFormat.SaveRawMITesBuiltinData(polledData);
//store it in Extractor Buffers as well
lastTimeStamp = Extractor.StoreBuiltinData(polledData);
}
if (Extractor.GenerateFeatureVector(lastTimeStamp))
{
Instance newinstance = new Instance(instances.numAttributes());
newinstance.Dataset = instances;
for (int i = 0; (i < Extractor.Features.Length); i++)
newinstance.setValue(instances.attribute(i), Extractor.Features[i]);
double predicted = classifier.classifyInstance(newinstance);
string predicted_activity = newinstance.dataset().classAttribute().value_Renamed((int)predicted);
int currentIndex = (int)labelIndex[predicted_activity];
labelCounters[currentIndex] = (int)labelCounters[currentIndex] + 1;
classificationCounter++;
if (classificationCounter == Extractor.Configuration.SmoothWindows)
{
classificationCounter = 0;
int mostCount = 0;
string mostActivity = "";
for (int j = 0; (j < labelCounters.Length); j++)
{
if (labelCounters[j] > mostCount)
{
mostActivity = activityLabels[j];
mostCount = labelCounters[j];
}
labelCounters[j] = 0;
}
pieChart.SetActivity(mostActivity);
if (this.aList.getEmptyPercent() == 1)
this.aList.reset();
else
this.aList.increment(mostActivity);
if (previousActivity != mostActivity)
{
this.activityTimer.stop();
this.activityTimer.reset();