47 Commits

Author SHA1 Message Date
Zhongxiao Ma
55bfc29942 keep builtin evaluations while using customized evaluation function (#1624)
* keep builtin evaluations while using customized evaluation function

* fix concat bytes to str
2016-11-10 12:40:48 -08:00
AbdealiJK
b94fcab4dc Add dump_format=json option (#1726)
* Add format to the params accepted by DumpModel

Currently, only the test format is supported when trying to dump
a model. The plan is to add more such formats like JSON which are
easy to read and/or parse by machines. And to make the interface
for this even more generic to allow other formats to be added.

Hence, we make some modifications to make these function generic
and accept a new parameter "format" which signifies the format of
the dump to be created.

* Fix typos and errors in docs

* plugin: Mention all the register macros available

Document the register macros currently available to the plugin
writers so they know what exactly can be extended using hooks.

* sparce_page_source: Use same arg name in .h and .cc

* gbm: Add JSON dump

The dump_format argument can be used to specify what type
of dump file should be created. Add functionality to dump
gblinear and gbtree into a JSON file.

The JSON file has an array, each item is a JSON object for the tree.
For gblinear:
 - The item is the bias and weights vectors
For gbtree:
 - The item is the root node. The root node has a attribute "children"
   which holds the children nodes. This happens recursively.

* core.py: Add arg dump_format for get_dump()
2016-11-04 09:55:25 -07:00
Eric Liu
9b2e41340b make DMatrix._init_from_npy2d only copy data when necessary (#1637)
* make DMatrix._init_from_npy2d only copy data when necessary

When creating DMatrix from a 2d ndarray, it can unnecessarily copy the input data. This can be problematic when the data is already very large--running out of memory. The copy is temporary (going out of scope at the end of this function) but it still adds to peak memory usage.

``numpy.array`` copies its input no matter what by default. By adding ``copy=False``, it will only do so when necessary. Since XGDMatrixCreateFromMat is readonly on the input buffer, this copy is not needed.

Also added comments explaining when a copy can happen (if data ordering/layout is wrong or if type is not 32-bit float).

* remove whitespace
2016-10-20 09:30:52 -07:00
Vadim Khotilovich
693ddb860e More robust DMatrix creation from a sparse matrix (#1606)
* [CORE] DMatrix from sparse w/ explicit #col #row; safer arg types

* [python-package] c-api change for _init_from_csr _init_from_csc

* fix spaces

* [R-package] adopt the new XGDMatrixCreateFromCSCEx interface

* [CORE] redirect old sparse creators to new ones
2016-09-25 10:01:22 -07:00
tqchen
149589c583 [PYTHON] Refactor trainnig API to use callback 2016-05-19 21:31:23 -07:00
Vadim Khotilovich
ffed95eec0 py: replace attr_names() with attributes() 2016-05-15 22:04:38 -05:00
Vadim Khotilovich
a13a3a4d76 attr_names for python interface; attribute deletion via set_attr 2016-05-15 02:05:10 -05:00
Shayne Kang
bf24d6ae98 fix VisibleDeprecationWarning 2016-05-08 01:44:04 +09:00
Alistair Johnson
6750c8b743 Added other feature importances in python package (#1135)
* added new function to calculate other feature importances

* added capability to plot other feature importance measures

* changed plotting default to fscore

* added info on importance_type to boilerplate comment

* updated text of error statement

* added self module name to fix call

* added unit test for feature importances

* style fixes
2016-05-02 12:25:24 -05:00
sinhrks
6bab164d80 Bug mixing DMatrix's with and without feature names 2016-04-30 14:42:57 +09:00
Faron
cf607e2448 [py] split value histograms 2016-04-28 20:26:21 +02:00
sinhrks
8fc2456c87 Enable flake8 2016-04-24 17:32:31 +09:00
Julian Quick
bbb9ce1641 Verbose message: which fields have impropper data types
A more verbose error message letting the user know which fields have impropper data types
2016-03-22 14:13:29 -06:00
Julian Quick
2cd109fb98 a more verbose field mismatch error message
This error message can be hard to understand when there are several fields, as shown in the example below. This improves the error message, letting the user know which fields were unexpected or missing.

    import xgboost as xgb
    import pandas as pd
    train = pd.DataFrame({'a':[1], 'b':[2], 'c':[3], 'd':[4], 'f':[2], 'g':2, 'etc etc etc':[11]})
    dtrain = xgb.DMatrix(train.drop('d', axis=1), train.d)
    test = pd.DataFrame({'a':[1], 'b':[2], 'c':[1], 'd':[4], 'e':[2], 'f':[2], 'g':2, 'etc etc etc':[11]})
    dtest = xgb.DMatrix(test)
    modl = xgb.train({}, dtrain)
    modl.predict(dtest)
    
    
    # ValueError: feature_names mismatch: [u'a', u'b', u'c', u'etc etc etc', u'f', u'g'] [u'a', u'b', u'c', u'd', u'e', u'etc etc etc', u'f', u'g']
2016-03-17 18:13:30 -06:00
tqchen
ecb3a271be [PYTHON-DIST] Distributed xgboost python training API. 2016-02-29 16:54:13 -08:00
tqchen
a71ba04109 [DIST] Add Distributed XGBoost on AWS Tutorial 2016-02-25 21:51:37 -08:00
Maxim Grechkin
f5e96eba72 Make missing handling consistent with sklearn's portion of the python package 2016-01-28 14:16:11 -08:00
Kai Luo
d9e50fd7f3 __copy__ calls __deepcopy__ with an argument 2016-01-20 19:57:20 +08:00
Kai Luo
5cd765e935 fix signature of __deepcopy__ method 2016-01-20 17:18:11 +08:00
terrytangyuan
0eb6240fd0 Fixed all lint errors 2015-12-11 18:46:15 -06:00
terrytangyuan
a7e79e089b fix lint errors in core 2015-12-11 18:37:13 -06:00
sinhrks
25c4fbd0cb Cleanup pandas support 2015-11-13 06:55:04 +09:00
antonymayi
8c7b18daed python 2.6 compatibility tweak
replacing set literal {} with set() for python 2.6 compatibility (plus reformatting the line)
2015-11-10 14:50:54 +01:00
Yuan (Terry) Tang
1dd96b6cdc Merge pull request #597 from JohanManders/python-pandas-dtypes
Python pandas dtypes
2015-11-09 18:08:41 -06:00
FrozenFingerz
b59018aa05 python: multiple eval_metrics changes
- allows feval to return a list of tuples (name, error/score value)
- changed behavior for multiple eval_metrics in conjunction with
early_stopping: Instead of raising an error, the last passed evel_metric
(or last entry in return value of feval) is used for early stopping
- allows list of eval_metrics in dict-typed params
- unittest for new features / behavior

documentation updated

- example for assigning a list to 'eval_metric'
- note about early stopping on last passed eval metric

- info msg for used eval metric added
2015-11-08 11:23:54 +01:00
Johan Manders
5f0f8749d9 Cleaned up some code 2015-11-04 18:05:47 +01:00
Johan Manders
f9e1b2b7b7 Added back feature names 2015-11-03 21:26:11 +01:00
Johan Manders
96f221e0d0 Merge pull request #5 from dmlc/master
Update to latest version
2015-11-03 20:37:20 +01:00
Preston Parry
b3bb54da73 fixes typo in error message 2015-10-27 23:34:50 -07:00
Johan Manders
7c79c9ac3a Bool gets mapped to i instead of int 2015-10-19 17:36:57 +02:00
Johan Manders
9bbc3901ee More Pandas dtypes and more flexible variable naming
- Pandas DataFrame supports more dtypes than 'int64', 'float64' and 'bool', therefor added a bunch of extra dtypes for the data variable.
- From now on the label variable can be a Pandas DataFrame with the same dtypes as the data variable.
- If label is a Pandas DataFrame will be converted to float.
- If no feature_types is set, the data dtypes will be converted to 'int' or 'float'.
- The feature_names may contain every character except [, ] or <
2015-10-17 15:13:42 +02:00
sinhrks
dbcb4c8729 Support non-str column names 2015-10-04 13:30:01 +09:00
sinhrks
b943becc61 python DMatrix now accepts pandas DataFrame 2015-10-01 22:52:32 +09:00
sinhrks
f6f3473d17 Change to properties 2015-09-28 22:36:39 +09:00
sinhrks
db692a30e5 Add feature_types 2015-09-28 22:25:35 +09:00
Tianqi Chen
a92d21ce24 Merge pull request #502 from irachex/fix_setup
Fix python setup: avoid import numpy in setup.py
2015-09-17 09:35:46 -07:00
sinhrks
f7d434aec2 Fix numpy array check logic 2015-09-17 22:51:44 +09:00
Huayi Zhang
6af98bec16 Fix python setup: avoid import numpy in setup.py
Currently `pip install xgboost` will raise traceback like this

```
Traceback (most recent call last):
  File "<string>", line 20, in <module>
  File "/tmp/pip-build-IAdqYE/xgboost/setup.py", line 20, in <module>
    import xgboost
  File "./xgboost/__init__.py", line 8, in <module>
    from .core import DMatrix, Booster
  File "./xgboost/core.py", line 12, in <module>
    import numpy as np
ImportError: No module named numpy
```

We should avoid importing numpy in setup.py and let pip install numpy and scipy automatically.
That's what `install_requires` for.
2015-09-17 14:49:19 +08:00
sinhrks
bb6b7ded55 Cleanup str roundtrip using ctypes 2015-09-17 04:10:19 +09:00
sinhrks
db0c9e1c2d BUG: incorrect model_file results in segfault 2015-09-16 22:02:30 +09:00
sinhrks
48ac946d9f Use ctypes 2015-09-14 22:12:19 +09:00
sinhrks
6506a1c490 ENH: allow python to handle feature names 2015-09-12 12:37:33 +09:00
phunterlau
f258a68029 add platform if statement in setup.py for pip for pull #450 issuecomment-133795287 2015-08-23 20:38:26 -07:00
phunterlau
db444c4a08 update with comments on PR #450, fixed styles and updated CHANGES and CONTRIBUTORS 2015-08-20 10:10:34 -07:00
phunterlau
70e230815b add necessary configrations for pip installation 2015-08-20 01:26:17 -07:00
tqchen
c43fee541d enable basic sphinx doc 2015-08-01 11:27:13 -07:00
tqchen
c2fec29bfa python package refactor into python-package 2015-07-30 22:04:45 -07:00