Problem using dataset.h in SMILELearn

The engine.
Post Reply
shenxu
Posts: 11
Joined: Wed Sep 08, 2010 6:51 pm

Problem using dataset.h in SMILELearn

Post by shenxu »

Hi,

I am using the VS 2008 version downloaded from website. Everything is OK when I tried the SMILE tutorial. However, in the SMILElearn, I met problems when Parse a vector into DSL_dataset object.
I did realized that you changed several functions in "dataset.h" compared with SMILElearn tutorial. When I was attending to add variable into the DSL_dataset, it occurs a real-time error in "AddIntVar" function. Here is the piece of code:

#include <iostream>
#include <string>
#include "smilearn.h"

using namespace std;
void CreateDataset(void);

int main()
{
CreateDataset();
}

void CreateDataset()
{
vector<int> aData;
vector<float> bData;
aData.push_back(1); bData.push_back(11.1f);
aData.push_back(2); bData.push_back(22.2f);
aData.push_back(3); bData.push_back(33.3f);
aData.push_back(4); bData.push_back(44.4f);
aData.push_back(5); bData.push_back(55.5f);

DSL_dataset ds;

vector <int>::iterator iter_int;
vector <float>::iterator iter_float;
iter_int = aData.begin();
iter_float = bData.begin();

int rec = 0;
string aName = "aaa";
int aVar = ds.AddIntVar(aName);
while (iter_int != aData.end() ) {
int data = *iter_int;
cout<<data<<endl;
ds.SetInt(aVar,rec,data);
rec ++;
iter_int ++;
}
}

Pls help me out. Thank you very much.
shooltz[BayesFusion]
Site Admin
Posts: 1417
Joined: Mon Nov 26, 2007 5:51 pm

Re: Problem using dataset.h in SMILELearn

Post by shooltz[BayesFusion] »

You need to call DSL_dataset::AddEmptyRecord in the loop or DSL_datset::SetNumberOfRecords(int) before entering the loop.
shenxu
Posts: 11
Joined: Wed Sep 08, 2010 6:51 pm

Re: Problem using dataset.h in SMILELearn

Post by shenxu »

Thank you for your quick reply!
However, I got the runtime error even if I comment from the line after

Code: Select all

int aVar = ds.AddIntVar(aName);
So, is it possible I should do something before this line?

Thanks again!
shenxu
Posts: 11
Joined: Wed Sep 08, 2010 6:51 pm

Re: Problem using dataset.h in SMILELearn

Post by shenxu »

Let me clarify my problem:

if I change my code like this, I still get a runtime error in the last line in CreateDataset function:

Code: Select all

#include <iostream>
#include <string>
#include "smilearn.h"

using namespace std;
void CreateDataset(void);

int main()
{
CreateDataset();
}

void CreateDataset()
{
vector<int> aData;
vector<float> bData;
aData.push_back(1); bData.push_back(11.1f);
aData.push_back(2); bData.push_back(22.2f);
aData.push_back(3); bData.push_back(33.3f);
aData.push_back(4); bData.push_back(44.4f);
aData.push_back(5); bData.push_back(55.5f);

DSL_dataset ds;

vector <int>::iterator iter_int;
vector <float>::iterator iter_float;
iter_int = aData.begin();
iter_float = bData.begin();

int rec = 0;
string aName = "aaa";
int aVar = ds.AddIntVar(aName);

}
shooltz[BayesFusion]
Site Admin
Posts: 1417
Joined: Mon Nov 26, 2007 5:51 pm

Re: Problem using dataset.h in SMILELearn

Post by shooltz[BayesFusion] »

ds.AddIntVar should work. Are you using any manually-specified library settings in your project, or just let smile.h and smilearn.h pick the right SMILE build?
shenxu
Posts: 11
Joined: Wed Sep 08, 2010 6:51 pm

Re: Problem using dataset.h in SMILELearn

Post by shenxu »

Yes, I did manually include the lib file in the VS setting. Problem solved after I delete them!

Thanks a lot !!!
Post Reply