Merge branch 'master' into master

This commit is contained in:
Alexis Mignon 2016-02-17 09:35:30 +01:00
commit a46706c82e
3 changed files with 21 additions and 3 deletions

View File

@ -1,7 +1,7 @@
Package: xgboost
Type: Package
Title: Extreme Gradient Boosting
Version: 0.4-2
Version: 0.4-3
Date: 2015-08-01
Author: Tianqi Chen <tianqi.tchen@gmail.com>, Tong He <hetong007@gmail.com>,
Michael Benesty <michael@benesty.fr>

View File

@ -7,11 +7,11 @@
#ifndef XGBOOST_R_H_ // NOLINT(*)
#define XGBOOST_R_H_ // NOLINT(*)
extern "C" {
#include <Rinternals.h>
#include <R_ext/Random.h>
#include <Rmath.h>
}
#include <xgboost/c_api.h>
/*!

View File

@ -389,6 +389,8 @@ class XGBClassifier(XGBModel, XGBClassifierBase):
else:
evals = ()
self._features_count = X.shape[1]
self._le = LabelEncoder().fit(y)
training_labels = self._le.transform(y)
@ -477,6 +479,22 @@ class XGBClassifier(XGBModel, XGBClassifierBase):
return evals_result
@property
def feature_importances_(self):
"""
Returns
-------
feature_importances_ : array of shape = [n_features]
"""
fs = self.booster().get_fscore()
keys = [int(k.replace('f', '')) for k in fs.keys()]
fs_dict = dict(zip(keys, fs.values()))
all_features_dict = dict.fromkeys(range(0, self._features_count), 0)
all_features_dict.update(fs_dict)
return np.array(all_features_dict.values())
class XGBRegressor(XGBModel, XGBRegressorBase):
# pylint: disable=missing-docstring
__doc__ = """Implementation of the scikit-learn API for XGBoost regression.