Numpy实现XGBoost,Python中为什么需要Handler

import progressbar

from mlfromscratch.utils import train_test_split, standardize, to_categorical, normalize

from mlfromscratch.utils import mean_squared_error, accuracy_score

from mlfromscratch.supervised_learning import XGBoostRegressionTree

from mlfromscratch.deep_learning.activation_functions import Sigmoid

from mlfromscratch.utils.misc import bar_widgets

from mlfromscratch.utils import Plot

class LogisticLoss():

def init(self):

sigmoid = Sigmoid()

self.log_func = sigmoid

self.log_grad = sigmoid.gradient

def loss(self, y, y_pred):

y_pred = np.clip(y_pred, 1e-15, 1 - 1e-15)

p = self.log_func(y_pred)

return y * np.log§ + (1 - y) * np.log(1 - p)

gradient w.r.t y_pred

def gradient(self, y, y_pred):

p = self.log_func(y_pred)

return -(y - p)

w.r.t y_pred

def hess(self, y, y_pred):

p = self.log_func(y_pred)

return p * (1 - p)

class XGBoost(object):

“”"The XGBoost classifier.

Reference: http://xgboost.readthedocs.io/en/latest/model.html

Parameters:


n_estimators: int

The number of classification trees that are used.

learning_rate: float

The step length that will be taken when following the negative gradient during

training.

min_samples_split: int

The minimum number of samples needed to make a split when building a tree.

min_impurity: float

The minimum impurity required to split the tree further.

max_depth: int

The maximum depth of a tree.

“”"

def init(self, n_estimators=200, learning_rate=0.001, min_samples_split=2,

min_impurity=1e-7, max_depth=2):

self.n_estimators = n_estimators # Number of trees

最后

不知道你们用的什么环境,我一般都是用的Python3.6环境和pycharm解释器,没有软件,或者没有资料,没人解答问题,都可以免费领取(包括今天的代码),过几天我还会做个视频教程出来,有需要也可以领取~

给大家准备的学习资料包括但不限于:

Python 环境、pycharm编辑器/永久激活/翻译插件

python 零基础视频教程

Python 界面开发实战教程

Python 爬虫实战教程

Python 数据分析实战教程

python 游戏开发实战教程

Python 电子书100本

Python 学习路线规划

小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。

深知大多数初中级Python工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!

因此收集整理了一份《2024年Python爬虫全套学习资料》送给大家,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。

由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频

如果你觉得这些内容对你有帮助,可以添加下面V无偿领取!(备注:python)
img

文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频**

如果你觉得这些内容对你有帮助,可以添加下面V无偿领取!(备注:python)
[外链图片转存中…(img-qdjiyZwb-1711190915929)]

  • 13
    点赞
  • 17
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值