当前位置: 首页>>代码示例>>C#>>正文


C# Instance.setValue方法代码示例

本文整理汇总了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");
开发者ID:intille,项目名称:mitessoftware,代码行数:67,代码来源:MITesDataCollectionForm.cs

示例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;
 }
开发者ID:intille,项目名称:mitessoftware,代码行数:15,代码来源:DTClassifier.cs

示例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();
开发者ID:intille,项目名称:mitessoftware,代码行数:67,代码来源:MITesDataCollectionForm.cs


注:本文中的Instance.setValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。