public bool CategorizePayments(int customerID) { NaiveBayesModel <Operation> model = new NaiveBayesModel <Operation>(); var operations = _operationServices.GetOperationsByCustomerID(customerID); var notCategorized = operations.Where(x => x.Tag == null || x.Tag.Name == "NotSet"); var categorized = operations.Where(x => x.Tag != null && x.Tag.Name != "NotSet"); var predictor = model.Generate(categorized); foreach (var operation in notCategorized) { var newOperation = predictor.Predict(operation); Debug.Write(newOperation.Tag.Name); using (TransactionScope scope = new TransactionScope()) { _repository.Update <Operation>(newOperation); scope.Complete(); } } return(true); }
public bool CategorizePayments(int customerID) { NaiveBayesModel<Operation> model = new NaiveBayesModel<Operation>(); var operations = _operationServices.GetOperationsByCustomerID(customerID); var notCategorized = operations.Where(x => x.Tag == null || x.Tag.Name == "NotSet"); var categorized = operations.Where(x => x.Tag != null && x.Tag.Name!="NotSet"); var predictor = model.Generate(categorized); foreach (var operation in notCategorized) { var newOperation = predictor.Predict(operation); Debug.Write(newOperation.Tag.Name); using (TransactionScope scope = new TransactionScope()) { _repository.Update<Operation>(newOperation); scope.Complete(); } } return true; }
public void NaiveBayes_Main_Test() { var data = Payment.GetData(); NaiveBayesModel<Payment> model = new NaiveBayesModel<Payment>(); var predictor = model.Generate(data); var item = predictor.Predict(new Payment { Amount = 110, Description = "Monop try it" }); Assert.AreEqual(item.Category, "Household"); }
public static string FindSentimentType(int sentimentCount, bool isRetweet, string language, List <TweetClassification> tweetClassificationList) { var model = new NaiveBayesModel <TweetClassification>(); var predictor = model.Generate(tweetClassificationList); var result = predictor.Predict(new TweetClassification { SentimentCount = sentimentCount, Language = language, IsRetweet = isRetweet }); return(result.SentimentType); }
public void NaiveBayes_Main_Test() { var data = Payment.GetData(); NaiveBayesModel <Payment> model = new NaiveBayesModel <Payment>(); var predictor = model.Generate(data); var item = predictor.Predict(new Payment { Amount = 110, Description = "Monop try it" }); Assert.AreEqual(item.Category, "Household"); }
public void NaiveBayesPredictor_Serialization_Test() { var data = Payment.GetData(); NaiveBayesModel<Payment> model = new NaiveBayesModel<Payment>(); var predictor = model.Generate(data); XmlSerializer ser = new XmlSerializer(predictor.GetType()); using (var stream = new MemoryStream()) { ser.Serialize(stream, predictor); stream.Position = 0; var newPredictor = model.Load(stream); var item = newPredictor.Predict(new Payment { Amount = 110, Description = "Monop try it" }); Assert.AreEqual(item.Category, "Household"); } }
public void NaiveBayesPredictor_Serialization_Test() { var data = Payment.GetData(); NaiveBayesModel <Payment> model = new NaiveBayesModel <Payment>(); var predictor = model.Generate(data); XmlSerializer ser = new XmlSerializer(predictor.GetType()); using (var stream = new MemoryStream()) { ser.Serialize(stream, predictor); stream.Position = 0; var newPredictor = model.Load(stream); var item = newPredictor.Predict(new Payment { Amount = 110, Description = "Monop try it" }); Assert.AreEqual(item.Category, "Household"); } }