zoukankan      html  css  js  c++  java
  • sklearn 中的 r2_score

    R 2 R^2 R2不止一种定义方式,这里是scikit-learn中所使用的定义。

    As such variance is dataset dependent, R² may not be meaningfully comparable across different datasets. Best possible score is 1.0 and it can be negative (because the model can be arbitrarily worse). A constant model that always predicts the expected value of y, disregarding the input features, would get a R² score of 0.0.

    As such variance is dataset dependent, R² may not be meaningfully comparable across different datasets. Best possible score is 1.0 and it can be negative (because the model can be arbitrarily worse). A constant model that always predicts the expected value of y, disregarding the input features, would get a R² score of 0.0.

    R 2 ( y , y ^ ) = 1 − ∑ i = 1 n ( y i − y ^ i ) 2 ∑ i = 1 n ( y i − y ˉ ) 2 R^2(y, hat{y}) = 1 - frac{sum_{i=1}^{n} (y_i - hat{y}_i)^2}{sum_{i=1}^{n} (y_i - ar{y})^2} R2(y,y^)=1i=1n(yiyˉ)2i=1n(yiy^i)2

    y ˉ = 1 n ∑ i = 1 n y i ar{y} = frac{1}{n} sum_{i=1}^{n} y_i yˉ=n1i=1nyi

    ∑ i = 1 n ( y i − y ^ i ) 2 = ∑ i = 1 n ϵ i 2 sum_{i=1}^{n} (y_i - hat{y}_i)^2 = sum_{i=1}^{n} epsilon_i^2 i=1n(yiy^i)2=i=1nϵi2

    from sklearn.metrics import r2_score
    y_true = [3, -0.5, 2, 7]
    y_pred = [2.5, 0.0, 2, 8]
    r2_score(y_true, y_pred)
    
    y_true = [[0.5, 1], [-1, 1], [7, -6]]
    y_pred = [[0, 2], [-1, 2], [8, -5]]
    r2_score(y_true, y_pred, multioutput='variance_weighted')
    
    y_true = [[0.5, 1], [-1, 1], [7, -6]]
    y_pred = [[0, 2], [-1, 2], [8, -5]]
    r2_score(y_true, y_pred, multioutput='uniform_average')
    
    r2_score(y_true, y_pred, multioutput='raw_values')
    
    r2_score(y_true, y_pred, multioutput=[0.3, 0.7])
    
  • 相关阅读:
    [转]JIRA 7.2.6与Confluence 6.0.3的安装与配置之MS SQL Server版
    Vue中computed和watch使用场景和方法
    vue插槽 slot 插槽之间的父子传参
    VUE 父子组件的传递 props、$ref 、 $emit、$parent、$children、$root
    div水平居中 垂直居中
    三次握手 四次挥手
    TCP/IP各层网络协议的通俗理解
    学习 cookie session 正向代理和反向代理的区别
    学习vuex心得体会
    登陆界面 跟后台对接口
  • 原文地址:https://www.cnblogs.com/yaos/p/14014125.html
Copyright © 2011-2022 走看看