.Call-interface functions need to return SEXP
This commit is contained in:
parent
2f2ad21de4
commit
b588479f66
@ -137,15 +137,16 @@ SEXP XGDMatrixSliceDMatrix_R(SEXP handle, SEXP idxset) {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void XGDMatrixSaveBinary_R(SEXP handle, SEXP fname, SEXP silent) {
|
SEXP XGDMatrixSaveBinary_R(SEXP handle, SEXP fname, SEXP silent) {
|
||||||
R_API_BEGIN();
|
R_API_BEGIN();
|
||||||
CHECK_CALL(XGDMatrixSaveBinary(R_ExternalPtrAddr(handle),
|
CHECK_CALL(XGDMatrixSaveBinary(R_ExternalPtrAddr(handle),
|
||||||
CHAR(asChar(fname)),
|
CHAR(asChar(fname)),
|
||||||
asInteger(silent)));
|
asInteger(silent)));
|
||||||
R_API_END();
|
R_API_END();
|
||||||
|
return R_NilValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
void XGDMatrixSetInfo_R(SEXP handle, SEXP field, SEXP array) {
|
SEXP XGDMatrixSetInfo_R(SEXP handle, SEXP field, SEXP array) {
|
||||||
R_API_BEGIN();
|
R_API_BEGIN();
|
||||||
int len = length(array);
|
int len = length(array);
|
||||||
const char *name = CHAR(asChar(field));
|
const char *name = CHAR(asChar(field));
|
||||||
@ -167,6 +168,7 @@ void XGDMatrixSetInfo_R(SEXP handle, SEXP field, SEXP array) {
|
|||||||
BeginPtr(vec), len));
|
BeginPtr(vec), len));
|
||||||
}
|
}
|
||||||
R_API_END();
|
R_API_END();
|
||||||
|
return R_NilValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
SEXP XGDMatrixGetInfo_R(SEXP handle, SEXP field) {
|
SEXP XGDMatrixGetInfo_R(SEXP handle, SEXP field) {
|
||||||
@ -227,23 +229,25 @@ SEXP XGBoosterCreate_R(SEXP dmats) {
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void XGBoosterSetParam_R(SEXP handle, SEXP name, SEXP val) {
|
SEXP XGBoosterSetParam_R(SEXP handle, SEXP name, SEXP val) {
|
||||||
R_API_BEGIN();
|
R_API_BEGIN();
|
||||||
CHECK_CALL(XGBoosterSetParam(R_ExternalPtrAddr(handle),
|
CHECK_CALL(XGBoosterSetParam(R_ExternalPtrAddr(handle),
|
||||||
CHAR(asChar(name)),
|
CHAR(asChar(name)),
|
||||||
CHAR(asChar(val))));
|
CHAR(asChar(val))));
|
||||||
R_API_END();
|
R_API_END();
|
||||||
|
return R_NilValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
void XGBoosterUpdateOneIter_R(SEXP handle, SEXP iter, SEXP dtrain) {
|
SEXP XGBoosterUpdateOneIter_R(SEXP handle, SEXP iter, SEXP dtrain) {
|
||||||
R_API_BEGIN();
|
R_API_BEGIN();
|
||||||
CHECK_CALL(XGBoosterUpdateOneIter(R_ExternalPtrAddr(handle),
|
CHECK_CALL(XGBoosterUpdateOneIter(R_ExternalPtrAddr(handle),
|
||||||
asInteger(iter),
|
asInteger(iter),
|
||||||
R_ExternalPtrAddr(dtrain)));
|
R_ExternalPtrAddr(dtrain)));
|
||||||
R_API_END();
|
R_API_END();
|
||||||
|
return R_NilValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
void XGBoosterBoostOneIter_R(SEXP handle, SEXP dtrain, SEXP grad, SEXP hess) {
|
SEXP XGBoosterBoostOneIter_R(SEXP handle, SEXP dtrain, SEXP grad, SEXP hess) {
|
||||||
R_API_BEGIN();
|
R_API_BEGIN();
|
||||||
CHECK_EQ(length(grad), length(hess))
|
CHECK_EQ(length(grad), length(hess))
|
||||||
<< "gradient and hess must have same length";
|
<< "gradient and hess must have same length";
|
||||||
@ -259,6 +263,7 @@ void XGBoosterBoostOneIter_R(SEXP handle, SEXP dtrain, SEXP grad, SEXP hess) {
|
|||||||
BeginPtr(tgrad), BeginPtr(thess),
|
BeginPtr(tgrad), BeginPtr(thess),
|
||||||
len));
|
len));
|
||||||
R_API_END();
|
R_API_END();
|
||||||
|
return R_NilValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
SEXP XGBoosterEvalOneIter_R(SEXP handle, SEXP iter, SEXP dmats, SEXP evnames) {
|
SEXP XGBoosterEvalOneIter_R(SEXP handle, SEXP iter, SEXP dmats, SEXP evnames) {
|
||||||
@ -305,24 +310,27 @@ SEXP XGBoosterPredict_R(SEXP handle, SEXP dmat, SEXP option_mask, SEXP ntree_lim
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void XGBoosterLoadModel_R(SEXP handle, SEXP fname) {
|
SEXP XGBoosterLoadModel_R(SEXP handle, SEXP fname) {
|
||||||
R_API_BEGIN();
|
R_API_BEGIN();
|
||||||
CHECK_CALL(XGBoosterLoadModel(R_ExternalPtrAddr(handle), CHAR(asChar(fname))));
|
CHECK_CALL(XGBoosterLoadModel(R_ExternalPtrAddr(handle), CHAR(asChar(fname))));
|
||||||
R_API_END();
|
R_API_END();
|
||||||
|
return R_NilValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
void XGBoosterSaveModel_R(SEXP handle, SEXP fname) {
|
SEXP XGBoosterSaveModel_R(SEXP handle, SEXP fname) {
|
||||||
R_API_BEGIN();
|
R_API_BEGIN();
|
||||||
CHECK_CALL(XGBoosterSaveModel(R_ExternalPtrAddr(handle), CHAR(asChar(fname))));
|
CHECK_CALL(XGBoosterSaveModel(R_ExternalPtrAddr(handle), CHAR(asChar(fname))));
|
||||||
R_API_END();
|
R_API_END();
|
||||||
|
return R_NilValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
void XGBoosterLoadModelFromRaw_R(SEXP handle, SEXP raw) {
|
SEXP XGBoosterLoadModelFromRaw_R(SEXP handle, SEXP raw) {
|
||||||
R_API_BEGIN();
|
R_API_BEGIN();
|
||||||
CHECK_CALL(XGBoosterLoadModelFromBuffer(R_ExternalPtrAddr(handle),
|
CHECK_CALL(XGBoosterLoadModelFromBuffer(R_ExternalPtrAddr(handle),
|
||||||
RAW(raw),
|
RAW(raw),
|
||||||
length(raw)));
|
length(raw)));
|
||||||
R_API_END();
|
R_API_END();
|
||||||
|
return R_NilValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
SEXP XGBoosterModelToRaw_R(SEXP handle) {
|
SEXP XGBoosterModelToRaw_R(SEXP handle) {
|
||||||
@ -359,4 +367,3 @@ SEXP XGBoosterDumpModel_R(SEXP handle, SEXP fmap, SEXP with_stats) {
|
|||||||
R_API_END();
|
R_API_END();
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -62,16 +62,18 @@ XGB_DLL SEXP XGDMatrixSliceDMatrix_R(SEXP handle, SEXP idxset);
|
|||||||
* \param handle a instance of data matrix
|
* \param handle a instance of data matrix
|
||||||
* \param fname file name
|
* \param fname file name
|
||||||
* \param silent print statistics when saving
|
* \param silent print statistics when saving
|
||||||
|
* \return R_NilValue
|
||||||
*/
|
*/
|
||||||
XGB_DLL void XGDMatrixSaveBinary_R(SEXP handle, SEXP fname, SEXP silent);
|
XGB_DLL SEXP XGDMatrixSaveBinary_R(SEXP handle, SEXP fname, SEXP silent);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief set information to dmatrix
|
* \brief set information to dmatrix
|
||||||
* \param handle a instance of data matrix
|
* \param handle a instance of data matrix
|
||||||
* \param field field name, can be label, weight
|
* \param field field name, can be label, weight
|
||||||
* \param array pointer to float vector
|
* \param array pointer to float vector
|
||||||
|
* \return R_NilValue
|
||||||
*/
|
*/
|
||||||
XGB_DLL void XGDMatrixSetInfo_R(SEXP handle, SEXP field, SEXP array);
|
XGB_DLL SEXP XGDMatrixSetInfo_R(SEXP handle, SEXP field, SEXP array);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief get info vector from matrix
|
* \brief get info vector from matrix
|
||||||
@ -104,16 +106,18 @@ XGB_DLL SEXP XGBoosterCreate_R(SEXP dmats);
|
|||||||
* \param handle handle
|
* \param handle handle
|
||||||
* \param name parameter name
|
* \param name parameter name
|
||||||
* \param val value of parameter
|
* \param val value of parameter
|
||||||
|
* \return R_NilValue
|
||||||
*/
|
*/
|
||||||
XGB_DLL void XGBoosterSetParam_R(SEXP handle, SEXP name, SEXP val);
|
XGB_DLL SEXP XGBoosterSetParam_R(SEXP handle, SEXP name, SEXP val);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief update the model in one round using dtrain
|
* \brief update the model in one round using dtrain
|
||||||
* \param handle handle
|
* \param handle handle
|
||||||
* \param iter current iteration rounds
|
* \param iter current iteration rounds
|
||||||
* \param dtrain training data
|
* \param dtrain training data
|
||||||
|
* \return R_NilValue
|
||||||
*/
|
*/
|
||||||
XGB_DLL void XGBoosterUpdateOneIter_R(SEXP ext, SEXP iter, SEXP dtrain);
|
XGB_DLL SEXP XGBoosterUpdateOneIter_R(SEXP ext, SEXP iter, SEXP dtrain);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief update the model, by directly specify gradient and second order gradient,
|
* \brief update the model, by directly specify gradient and second order gradient,
|
||||||
@ -122,8 +126,9 @@ XGB_DLL void XGBoosterUpdateOneIter_R(SEXP ext, SEXP iter, SEXP dtrain);
|
|||||||
* \param dtrain training data
|
* \param dtrain training data
|
||||||
* \param grad gradient statistics
|
* \param grad gradient statistics
|
||||||
* \param hess second order gradient statistics
|
* \param hess second order gradient statistics
|
||||||
|
* \return R_NilValue
|
||||||
*/
|
*/
|
||||||
XGB_DLL void XGBoosterBoostOneIter_R(SEXP handle, SEXP dtrain, SEXP grad, SEXP hess);
|
XGB_DLL SEXP XGBoosterBoostOneIter_R(SEXP handle, SEXP dtrain, SEXP grad, SEXP hess);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief get evaluation statistics for xgboost
|
* \brief get evaluation statistics for xgboost
|
||||||
@ -131,7 +136,7 @@ XGB_DLL void XGBoosterBoostOneIter_R(SEXP handle, SEXP dtrain, SEXP grad, SEXP h
|
|||||||
* \param iter current iteration rounds
|
* \param iter current iteration rounds
|
||||||
* \param dmats list of handles to dmatrices
|
* \param dmats list of handles to dmatrices
|
||||||
* \param evname name of evaluation
|
* \param evname name of evaluation
|
||||||
* \return the string containing evaluation stati
|
* \return the string containing evaluation stats
|
||||||
*/
|
*/
|
||||||
XGB_DLL SEXP XGBoosterEvalOneIter_R(SEXP handle, SEXP iter, SEXP dmats, SEXP evnames);
|
XGB_DLL SEXP XGBoosterEvalOneIter_R(SEXP handle, SEXP iter, SEXP dmats, SEXP evnames);
|
||||||
|
|
||||||
@ -147,21 +152,24 @@ XGB_DLL SEXP XGBoosterPredict_R(SEXP handle, SEXP dmat, SEXP option_mask, SEXP n
|
|||||||
* \brief load model from existing file
|
* \brief load model from existing file
|
||||||
* \param handle handle
|
* \param handle handle
|
||||||
* \param fname file name
|
* \param fname file name
|
||||||
|
* \return R_NilValue
|
||||||
*/
|
*/
|
||||||
XGB_DLL void XGBoosterLoadModel_R(SEXP handle, SEXP fname);
|
XGB_DLL SEXP XGBoosterLoadModel_R(SEXP handle, SEXP fname);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief save model into existing file
|
* \brief save model into existing file
|
||||||
* \param handle handle
|
* \param handle handle
|
||||||
* \param fname file name
|
* \param fname file name
|
||||||
|
* \return R_NilValue
|
||||||
*/
|
*/
|
||||||
XGB_DLL void XGBoosterSaveModel_R(SEXP handle, SEXP fname);
|
XGB_DLL SEXP XGBoosterSaveModel_R(SEXP handle, SEXP fname);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief load model from raw array
|
* \brief load model from raw array
|
||||||
* \param handle handle
|
* \param handle handle
|
||||||
|
* \return R_NilValue
|
||||||
*/
|
*/
|
||||||
XGB_DLL void XGBoosterLoadModelFromRaw_R(SEXP handle, SEXP raw);
|
XGB_DLL SEXP XGBoosterLoadModelFromRaw_R(SEXP handle, SEXP raw);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief save model into R's raw array
|
* \brief save model into R's raw array
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user