Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexisMignon committed Feb 17, 2016
2 parents 52e9085 + 2baea12 commit a46706c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
2 changes: 1 addition & 1 deletion R-package/DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>, Tong He <[email protected]>,
Michael Benesty <[email protected]>
Expand Down
4 changes: 2 additions & 2 deletions R-package/src/xgboost_R.h
Original file line number Diff line number Diff line change
Expand Up @@ -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>

/*!
Expand Down
18 changes: 18 additions & 0 deletions python-package/xgboost/sklearn.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,8 @@ def fit(self, X, y, sample_weight=None, eval_set=None, eval_metric=None,
else:
evals = ()

self._features_count = X.shape[1]

self._le = LabelEncoder().fit(y)
training_labels = self._le.transform(y)

Expand Down Expand Up @@ -477,6 +479,22 @@ def evals_result(self):

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.
Expand Down

0 comments on commit a46706c

Please sign in to comment.