zoukankan      html  css  js  c++  java
  • 多输出回归问题

    Scikit-Learn also has a general class, MultiOutputRegressor, which can be used to use a single-output regression model and fit one regressor separately to each target.

    Your code would then look something like this (using k-NN as example):

    from sklearn.neighbors import KNeighborsRegressor
    from sklearn.multioutput import MultiOutputRegressor
    
    X = np.random.random((10,3))
    y = np.random.random((10,2))
    X2 = np.random.random((7,3))
    
    knn = KNeighborsRegressor()
    regr = MultiOutputRegressor(knn)
    
    regr.fit(X,y)
    regr.predict(X2)
    

      

    来自:

    https://stats.stackexchange.com/questions/153853/regression-with-scikit-learn-with-multiple-outputs-svr-or-gbm-possible

    我的建议是使用sklearn.multioutput.MultiOutputRegressor作为xgb.XGBRegressor的包装。 MultiOutputRegressor为每个目标培训一个回归者,只需要回归者实施fitpredict,这是xgboost恰好支持的。

    # get some noised linear data 
    X = np.random.random((1000, 10)) 
    a = np.random.random((10, 3)) 
    y = np.dot(X, a) + np.random.normal(0, 1e-3, (1000, 3)) 
    
    # fitting 
    multioutputregressor = MultiOutputRegressor(xgb.XGBRegressor(objective='reg:linear')).fit(X, y) 
    
    # predicting 
    print np.mean((multioutputregressor.predict(X) - y)**2, axis=0) # 0.004, 0.003, 0.005 

    这可能是使用xgboost因为你不会需要改变你的代码的任何其他部分(如果原先使用sklearn API)倒退多维目标的最简单的方法。

    来自:

    https://stackoverrun.com/cn/q/10892468

    1.12.5. 多输出回归

    多输出回归支持 MultiOutputRegressor 可以被添加到任何回归器中。这个策略包括对每个目标拟合一个回归器。因为每一个目标可以被一个回归器精确地表示,通过检查对应的回归器,可以获取关于目标的信息。 因为 MultiOutputRegressor 对于每一个目标可以训练出一个回归器,所以它无法利用目标之间的相关度信息。

    sklearn 中文文档 : http://sklearn.apachecn.org/cn/stable/modules/multiclass.html#id14

    sklearn.multioutput.MultiOutputRegressor

    官方文档:http://scikit-learn.org/stable/modules/generated/sklearn.multioutput.MultiOutputRegressor.html

    博客地址:https://blog.csdn.net/luanpeng825485697/article/details/79858186

  • 相关阅读:
    Qt 跟踪鼠标事件:setMouseTracking(true)
    Qt setMouseTracking使用
    Qt QGraphicsItem 鼠标点击事件编程方法
    Qt QGraphicsItem信号连接有关问题
    Qt 自定义QGraphicsItem
    Qt 视图框架QGraphicsItem
    Qt QGraphicsItem要点 积累
    Qt Q_UNUSED() 方法的使用
    Qt 绘图之QGraphicsScene QGraphicsView QGraphicsItem详解
    Qt 使用QGraphicsItem绘制复杂的图形
  • 原文地址:https://www.cnblogs.com/Allen-rg/p/9485840.html
Copyright © 2011-2022 走看看