handspeaker / randomforests Goto Github PK
View Code? Open in Web Editor NEWa 1500 lines simple C++ implementation of RandomForests with detailed comments
a 1500 lines simple C++ implementation of RandomForests with detailed comments
我在win10设备上运行代码,用VS2019创建工程,使用的数据集是您推荐的数据集。但是把编译器配置成release-x64,debug-x64和debug-x86的时候都运行不了,弹出以下错误:
C:\Users\lenovo\Desktop\rf\rf\Debug\rf.exe (进程 20548)已退出,代码为 -1073741819。
debug发现在文件node.cpp-69行处发生内存冲突:
0x01314AD8 处(位于 rf.exe 中)引发的异常: 0xC0000005: 读取位置 0x993F48B0 时发生访问冲突。
只有配置成release-x86时可以跑通代码,给出正确结果。
Sample::Sample(Sample* samples)
{
_dataset=samples->_dataset;
_labels=samples->_labels;
_classNum=samples->getClassNum();
_featureNum=samples->getFeatureNum();
_sampleNum=samples->getSampleNum();
_selectedSampleNum=samples->getSelectedSampleNum();
_selectedFeatureNum=samples->getSelectedFeatureNum();
_sampleIndex=samples->getSampleIndex();
_featureIndex=samples->getFeatureIndex();
}
Sample::~Sample()
{
_sampleIndex=NULL;
_featureIndex=NULL;
}
Is it safe to write this way
Tree::~Tree()
{
if(_cartreeArray!=NULL)
{
for(int i=0;i<_nodeNum;++i)
{
if(_cartreeArray[i]!=NULL)
{
delete _cartreeArray[i];
_cartreeArray[i]=NULL;
}
}
delete[] _cartreeArray;
_cartreeArray=NULL;
}
}
error! about delete
因为我看了你的源码,你的预测也是将样本一条条输入,进行预测的。
void Sample::randomSelectFeature(int*featureIndex,int featureNum,int selectedFeatureNum)
{
// ......
for(i=0,j=featureNum-selectedFeatureNum;j<featureNum;++j,++i)
{
// if featureNum == selectedFeatureNum, then wrong
index = rand()%j;
// ......
}
so, may be like this:
if(j == 0)
index = 0;
else
index = rand()%j;
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.