support int type

This commit is contained in:
tqchen 2014-03-12 17:58:14 -07:00
parent 8f9efa2725
commit fcf06a7164
3 changed files with 23 additions and 5 deletions

View File

@ -346,16 +346,30 @@ namespace xgboost{
const unsigned split_index = nodes[ nid ].split_index();
if( split_index < fmap.size() ){
if( fmap.type(split_index) == utils::FeatMap::kIndicator ){
switch( fmap.type(split_index) ){
case utils::FeatMap::kIndicator:{
int nyes = nodes[ nid ].default_left()?nodes[nid].cright():nodes[nid].cleft();
fprintf( fo, "%d:[%s] yes=%d,no=%d",
nid, fmap.name( split_index ),
nyes, nodes[nid].cdefault() );
}else{
nyes, nodes[nid].cdefault() );
break;
}
case utils::FeatMap::kInteger:{
fprintf( fo, "%d:[%s<%d] yes=%d,no=%d,missing=%d",
nid, fmap.name(split_index), int( float(cond)+1.0f),
nodes[ nid ].cleft(), nodes[ nid ].cright(),
nodes[ nid ].cdefault() );
break;
}
case utils::FeatMap::kFloat:
case utils::FeatMap::kQuantitive:{
fprintf( fo, "%d:[%s<%f] yes=%d,no=%d,missing=%d",
nid, fmap.name(split_index), float(cond),
nodes[ nid ].cleft(), nodes[ nid ].cright(),
nodes[ nid ].cdefault() );
break;
}
default: utils::Error("unknown fmap type");
}
}else{
fprintf( fo, "%d:[f%u<%f] yes=%d,no=%d,missing=%d",

View File

@ -292,7 +292,7 @@ namespace xgboost{
* \brief adjust base_score
*/
inline void AdjustBase( void ){
if( loss_type == 1 ){
if( loss_type == 1 || loss_type == 2 ){
utils::Assert( base_score > 0.0f && base_score < 1.0f, "sigmoid range constrain" );
base_score = - logf( 1.0f / base_score - 1.0f );
}

View File

@ -17,7 +17,9 @@ namespace xgboost{
public:
enum Type{
kIndicator = 0,
kQuantitive = 1
kQuantitive = 1,
kInteger = 2,
kFloat = 3
};
public:
/*! \brief load feature map from text format */
@ -54,6 +56,8 @@ namespace xgboost{
inline static Type GetType( const char *tname ){
if( !strcmp( "i", tname ) ) return kIndicator;
if( !strcmp( "q", tname ) ) return kQuantitive;
if( !strcmp( "int", tname ) ) return kInteger;
if( !strcmp( "float", tname ) ) return kFloat;
utils::Error("unknown feature type, use i for indicator and q for quantity");
return kIndicator;
}