ML之catboost:catboost的CatBoostRegressor函数源代码简
介。。。
ML之catboost:catboost的CatBoostRegressor函数源代码简介、解读之详细攻略
⽬录
catboost的CatBoostRegressor函数源代码简介、解读
u_best_model=None,
best_model_min_trees=None,
verbo=None,
silent=None,
logging_level=None,
metric_period=None,
ctr_leaf_count_limit=None,
store_all_simple_ctr=None,
max_ctr_complexity=None,
has_time=None,
allow_const_label=None,
target_border=None,
one_hot_max_size=None,
random_strength=None,
name=None,
ignored_features=None,
train_dir=None,
custom_metric=None,
eval_metric=None,
bagging_temperature=None,
save_snapshot=None,
snapshot_file=None,
snapshot_interval=None,
fold_len_multiplier=None,员工价值
冰箱怎么消毒ud_ram_limit=None,
gpu_ram_part=None,
pinned_memory_size=None,
平衡木教案
allow_writing_files=None,
final_ctr_computation_mode=None,
approx_on_full_history=None,
boosting_type=None,
simple_ctr=None,
combinations_ctr=None,
per_feature_ctr=None,
ctr_description=None,
ctr_target_border_count=None,
task_type=None,
device_config=None,
devices=None,
bootstrap_type=None,
subsample=None,
mvs_reg=None,
sampling_frequency=None,
sampling_unit=None,
dev_score_calc_obj_block_size=None,
dev_efb_max_buckets=None,
spar_features_conflict_fraction=None, max_depth=None,
n_estimators=None,
num_boost_round=None,
num_trees=None,
colsample_bylevel=None,
random_state=None,
reg_lambda=None,
objective=None,
eta=None,
eta=None,
max_bin=None,
gpu_cat_features_storage=None,
data_partition=None,
metadata=None,
early_stopping_rounds=None,
cat_features=None,
grow_policy=None,
min_data_in_leaf=None,
min_child_samples=None,
max_leaves=None,
num_leaves=None,
score_function=None,
leaf_estimation_backtracking=None,
ctr_history_unit=None,
monotone_constraints=None,
feature_weights=None,
penalties_coefficient=None,
first_feature_u_penalties=None,
per_object_feature_penalties=None,
model_shrink_rate=None,
model_shrink_mode=None,
langevin=None,
diffusion_temperature=None,
posterior_sampling=None,
boost_from_average=None):
params = {}
not_params = ["not_params", "lf", "params", "__class__"] for key, value in iteritems(locals().copy()):
if key not in not_params and value is not None:
params[key] = value
super(CatBoostRegressor, lf).__init__(params)
def fit(lf, X, y=None, cat_features=None,
sample_weight=None, baline=None,
u_best_model=None,
eval_t=None, verbo=None, logging_level=None,
plot=Fal,
column_description=None,
verbo_eval=None, metric_period=None, silent=None, early_stopping_rounds=None,
save_snapshot=None, snapshot_file=None,
snapshot_interval=None, init_model=None):
"""
Fit the CatBoost model.
Parameters
----------
X : catboost.Pool or list or numpy.ndarray or
pandas.DataFrame or pandas.Series. If not catboost.Pool, 2 dimensional Feature matrix or string - file with datat.
y : list or numpy.ndarray or pandas.DataFrame or pandas.Series, optional (default=None). Labels, 1 dimensional array like. U only if X is not catboost.Pool.
cat_features : list or numpy.ndarray, optional X: catboost。pool或list或numpy。ndarray或
pandas.DataFrame或pandas.Series。如果不是catboost。Pool,⼆维特征矩阵或字符串⽂件与数据集。y: list或numpy。ndarray或pandas.DataFrame或pandas.Series。可选(默认= None)。标签,类似于⼀维数组。仅当X不是catboost.Pool时使⽤。
cat_features: list或numpy.ndarray,可选(默认= None)。如果不是None,则给出类别列索引的列表。仅当X不是catboost.Pool时使⽤。
china音标sample_weight:列表或numpy。ndarray或
pandas.DataFrame或pandas.Series,可选(默认= None)。实例权重,类似于⼀维数组。
baline:列表或numpy。ndarray,可选(默认= None)。如果不是None,则给出像data这样的⼆维数组。仅当X不是catboost.Pool时使⽤。
u_best_model: bool,可选(默认为None)。标记使⽤最佳模型
eval_t: catboost。Pool或列表,可选(默认为None)。(X, y)元组对的列表,⽤作早期停⽌的验证集。
metric_period: int。评估指标的频率。
verbo: bool或int。如果verbo是bool,那么如果设置
cat_features : list or numpy.ndarray, optional
(default=None). If not None, giving the list of Categ columns indices.U only if X is not catboost.Pool.
sample_weight : list or numpy.ndarray or pandas.DataFrame or pandas.Series, optional (default=None). Instance weights, 1 dimensional array like.
baline : list or numpy.ndarray, optional (default=None). If not None, giving 2 dimensional array like data. U only if X is not catboost.Pool.
u_best_model : bool, optional (default=None). Flag to u best model
eval_t : catboost.Pool or list, optional (default=None). A
list of (X, y) tuple pairs to u as a validation t for early-stopping
metric_period : int. Frequency of evaluating metrics.
verbo : bool or int. If verbo is bool, then if t to True, logging_level is t to Verbo, if t to Fal, logging_level is t to Silent. If verbo is int, it determines the frequency of writing metrics to output and logging_level is t to Verbo.
silent : bool. If silent is True, logging_level is t to Silent. If silent is Fal, logging_level is t to Verbo.
logging_level : string, optional (default=None). Possible values:
- 'Silent'
- 'Verbo'
-
'Info'
- 'Debug'
初中必读书
plot : bool, optional (default=Fal). If True, draw train and eval error in Jupyter notebook
verbo_eval : bool or int. Synonym for verbo. Only one
of the parameters should be t.
early_stopping_rounds : int. Activates Iter overfitting
detector with od_wait t to early_stopping_rounds.
save_snapshot : bool, [default=None]. Enable progress snapshotting for restoring progress after crashes or
interruptions
snapshot_file : string, [default=None]. Learn progress snapshot file path, if None will u default
filename snapshot_interval: int, [default=600]. Interval between saving snapshots (conds)
init_model : CatBoost class or string, [default=None]. Continue training starting from the existing model. If this parameter is a string, load initial model from the path specified by this string.
Returns
-------
model : CatBoost
"""
params = deepcopy(lf._init_params)
_process_synonyms(params)
if 'loss_function' in params: verbo: bool或int。如果verbo是bool,那么如果设置为True, logging_level将设置为verbo,如果设置为Fal, logging_level将设置为Silent。如果verbo为int,则它确定向输出写⼊指标的频率,并将logging_level设置为verbo。
silent : bool。如果silent为True, loging_level设置为silent。如果silent为Fal, loging_level设置为Verbo。logging_level:字符串,可选(默认为None)。可能的值:——“沉默”
——“详细”
——“信息”
——“调试”
plot: bool,可选(默认=Fal)。如果为真,在Jupyter中绘制训练集和测试集的error
verbo_eval: bool或int。详细的同义词。应该只设置这些参数中的⼀个。
early_stopping_rounds: int。激活Iter过拟合检测
四维彩超图
器,od_wait设置为early_stopping_rounds。
save_snapshot: bool, [default=None]。启⽤进度快照,以便在崩溃或中断后恢复进度
snapshot_file: string, [default=None]。学习进度快照⽂件路径,如果没有将使⽤默认⽂件名snapshot_interval: int,[默认=600]。保存快照的时间间隔(秒)孙卫卫
init_model: CatBoost类或字符串,[default=None]。从现有的模式开始继续培训。如果该参数为字符串,则从该字符串指定的路径加载初始模型。
lf._check_is_regressor_loss(params['loss_function'])
return lf._fit(X, y, cat_features, None, None, None, sample_weight, None, None, None,参数
---------
data : catboost。池或特性列表或列表的列表或numpy。
sample_weight, None, None, None,
None, baline,
u_best_model, eval_t, verbo, logging_level, plot, column_description,
verbo_eval, metric_period, silent,
early_stopping_rounds,
save_snapshot, snapshot_file, snapshot_interval,
init_model)
def predict(lf, data, prediction_type=None, ntree_start=0, ntree_end=0, thread_count=-
1, verbo=None):
"""
Predict with data.
Parameters
----------
data : catboost.Pool or list of features or list of lists or numpy.ndarray or pandas. DataFrame or pandas.Series or catboost.FeaturesData. Data to apply model on. If data is a simple list (not list of lists) or a one-dimensional numpy.ndarray it is interpreted as a list of features for a single object.
prediction_type : string, optional (default='RawFormulaVal'). Can be:
- 'RawFormulaVal' : return raw formula value.
- 'Exponent' : return Exponent of raw formula value.
ntree_start: int, optional (default=0)
Model is applied on the interval [ntree_start, ntree_end) (zero-bad indexing).
ntree_end: int, optional (default=0)
Model is applied on the interval [ntree_start, ntree_end) (zero-bad indexing). If value equals to 0 this parameter is ignored and ntree_end equal to tree_count_.
thread_count : int (default=-1). The number of threads to u when applying the model. Allows you to optimize the speed of execution. This parameter doesn't affect results. If -1, then the number of threads is t to the number of CPU cores.
verbo : bool. If True, writes the evaluation metric measured t to stderr.
Returns
-------
prediction : If data is for a single object, the return value is single float formula return value otherwi one-dimensional numpy.ndarray of formula return values for each object.
"""
if prediction_type is None:
prediction_type = lf._get_default_prediction_type()
return lf._predict(data, prediction_type, ntree_start,
ntree_end, thread_count, verbo,
'predict')data : catboost。池或特性列表或列表的列表或numpy。ndarray或熊猫。DataFrame或熊猫。系列或
catboost.FeaturesData。应⽤模型的数据。如果data是⼀个简单的列表(不是列表的列表)或⼀维numpy。ndarray它被解释为⼀个对象的特性列表。
prediction_type :字符串,可选(默认
为'RawFormulaVal')。可以是:
久咳不止- 'RawFormulaVal':返回原始公式值。
- 'Exponent':返回原始公式值的指数。
ntree_start: int,可选(默认为0)
模型应⽤于区间[ntree_start, ntree_end)(从零开始索引)。ntree_end: int,可选(默认为0)
模型应⽤于区间[ntree_start, ntree_end)(从零开始索引)。如果value等于0,则忽略该参数,ntree_end等于
tree_count_。
thread_count :int(默认=-1)。应⽤模型时要使⽤的线程数。允许您优化执⾏速度。此参数不影响结果。如果-1,则线程数设置为CPU核数。
verbo :bool。如果为真,则将评估度量值写⼊stderr。返回
-------
prediction:如果数据是针对单个对象的,则返回值为单个float公式返回值,否则为⼀维numpy。ndarray的公式返回每个对象的值。
def staged_predict(lf, data, prediction_type='RawFormulaVal', ntree_start=0, data : catboost。池或特性列表或列表的列表或numpy。ndarray或DataFrame 或pandas.Series or