Comments (3)
Changing the training percentage from 0.80
to 0.75
resolved the discrepancy. I think this is probably the expected result of using the Naive Bayes model, and this issue can be closed. Thanks again!
from numl.
Awesome. I got worried!
from numl.
Update: created separate issue for this; please disregard this comment
I must be doing something horribly wrong. I'm trying to use naive bayes to categorize some data based on input via a spreadsheet. The code runs, but it seems to give me the same category regardless of my input. I've appended some sample code below (gloss over the helper call that reads Excel; that just takes the sheet & converts to a .net dataset). Also, I'm limiting the training data to the first 100 rows. Any more than that and the program gets an out of memory exception!
So I have two questions:
- how to get a meaningful prediction/classification?
- how to load much larger training dataset without memory overflow?
[Serializable]
public class PeerCategory
{
[Feature]
public string PeerCategoryDesc { get; set; }
[Label]
public string CAPeerCategory { get; set; }
}
[TestFixture]
//[Ignore]
public class BayesTest
{
[Test]
public void TestExcel()
{
string pathToFile = @"C:\data\Training Data.xlsx";
using (var reader = new FileReaderExcel(pathToFile))
{
int index = reader.GetSheetIndexByName("V6");
var dt = reader.GetDataTableFromExcelSheet(index, true);
var peerCatList = (
from DataRow row in dt.Rows
select new PeerCategory()
{
PeerCategoryDesc = row.Field<string>(0),
CAPeerCategory = row.Field<string>(1)
}).Take(100).ToList();
var width = peerCatList.Select(t => t.CAPeerCategory).Distinct().Count();
IGenerator generator = new NaiveBayesGenerator(width);
generator.Descriptor = Descriptor.Create<PeerCategory>();
LearningModel learned = Learner.Learn(peerCatList, 0.8, 1000, generator);
IModel model = learned.Model;
double accuracy = learned.Accuracy;
var value1 = model.Predict(GetItem("paint"));
var value2 = model.Predict(GetItem("flower"));
var value3 = model.Predict(GetItem("sofa"));
var value4 = model.Predict(GetItem("desk"));
var value5 = model.Predict(GetItem("bones"));
// value1 thru 5 will be the same category over and over again!!
}
}
public PeerCategory GetItem(string desc)
{
var item = new PeerCategory()
{
PeerCategoryDesc = desc,
CAPeerCategory = string.Empty
};
return item;
}
from numl.
Related Issues (20)
- Image Processing? HOT 3
- Docs link is broken. HOT 2
- Guid property HOT 6
- xproj can't load in my VS2015 HOT 6
- GRU example HOT 2
- LoadJson not implemented HOT 8
- Please port to .NET Standard HOT 2
- Error "Sequence contains no elements..." HOT 16
- Documentation HOT 3
- Datetime as label to learn - error "Dimensions do not match" HOT 5
- How To Make A Prediction HOT 2
- Difference with Label and StringLabel Attributes HOT 1
- Reccomendatin Problem HOT 1
- Text classification with numl HOT 2
- Predict method allows bonehead null-reference bug HOT 1
- How to load saved models? HOT 2
- Model load issue HOT 3
- [Question] Training on big data HOT 1
- KMeans Cluster Member Proximity to Center
- Linear Regression with NuML
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from numl.