support int type
This commit is contained in:
parent
329cc61795
commit
8c8dd1a740
@ -346,16 +346,30 @@ namespace xgboost{
|
|||||||
const unsigned split_index = nodes[ nid ].split_index();
|
const unsigned split_index = nodes[ nid ].split_index();
|
||||||
|
|
||||||
if( split_index < fmap.size() ){
|
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();
|
int nyes = nodes[ nid ].default_left()?nodes[nid].cright():nodes[nid].cleft();
|
||||||
fprintf( fo, "%d:[%s] yes=%d,no=%d",
|
fprintf( fo, "%d:[%s] yes=%d,no=%d",
|
||||||
nid, fmap.name( split_index ),
|
nid, fmap.name( split_index ),
|
||||||
nyes, nodes[nid].cdefault() );
|
nyes, nodes[nid].cdefault() );
|
||||||
}else{
|
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",
|
fprintf( fo, "%d:[%s<%f] yes=%d,no=%d,missing=%d",
|
||||||
nid, fmap.name(split_index), float(cond),
|
nid, fmap.name(split_index), float(cond),
|
||||||
nodes[ nid ].cleft(), nodes[ nid ].cright(),
|
nodes[ nid ].cleft(), nodes[ nid ].cright(),
|
||||||
nodes[ nid ].cdefault() );
|
nodes[ nid ].cdefault() );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default: utils::Error("unknown fmap type");
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
fprintf( fo, "%d:[f%u<%f] yes=%d,no=%d,missing=%d",
|
fprintf( fo, "%d:[f%u<%f] yes=%d,no=%d,missing=%d",
|
||||||
|
|||||||
@ -292,7 +292,7 @@ namespace xgboost{
|
|||||||
* \brief adjust base_score
|
* \brief adjust base_score
|
||||||
*/
|
*/
|
||||||
inline void AdjustBase( void ){
|
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" );
|
utils::Assert( base_score > 0.0f && base_score < 1.0f, "sigmoid range constrain" );
|
||||||
base_score = - logf( 1.0f / base_score - 1.0f );
|
base_score = - logf( 1.0f / base_score - 1.0f );
|
||||||
}
|
}
|
||||||
|
|||||||
@ -17,7 +17,9 @@ namespace xgboost{
|
|||||||
public:
|
public:
|
||||||
enum Type{
|
enum Type{
|
||||||
kIndicator = 0,
|
kIndicator = 0,
|
||||||
kQuantitive = 1
|
kQuantitive = 1,
|
||||||
|
kInteger = 2,
|
||||||
|
kFloat = 3
|
||||||
};
|
};
|
||||||
public:
|
public:
|
||||||
/*! \brief load feature map from text format */
|
/*! \brief load feature map from text format */
|
||||||
@ -54,6 +56,8 @@ namespace xgboost{
|
|||||||
inline static Type GetType( const char *tname ){
|
inline static Type GetType( const char *tname ){
|
||||||
if( !strcmp( "i", tname ) ) return kIndicator;
|
if( !strcmp( "i", tname ) ) return kIndicator;
|
||||||
if( !strcmp( "q", tname ) ) return kQuantitive;
|
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");
|
utils::Error("unknown feature type, use i for indicator and q for quantity");
|
||||||
return kIndicator;
|
return kIndicator;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user