T85_code/省际测试.ipynb

7.9 KiB
Raw Permalink Blame History

In [1]:
import pandas as pd
In [2]:
data = pd.read_csv('./供热测试结果.csv')
In [3]:
data
Out[3]:
0 1
0 0.072858 0.072700
1 0.073347 0.075045
2 0.082159 0.080671
3 0.084120 0.081944
4 0.065845 0.066739
... ... ...
408 0.066066 0.066927
409 0.084331 0.082709
410 0.069216 0.069256
411 0.065259 0.066203
412 0.069608 0.071754

413 rows × 2 columns

In [4]:
from sklearn.metrics import r2_score
In [7]:
r2_score(data.values[:,1], data.values[:,0])
Out[7]:
0.8483477508497194
In [8]:
help(r2_score)
Help on function r2_score in module sklearn.metrics._regression:

r2_score(y_true, y_pred, *, sample_weight=None, multioutput='uniform_average')
    :math:`R^2` (coefficient of determination) regression score function.
    
    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 :math:`R^2` score of 0.0.
    
    Read more in the :ref:`User Guide <r2_score>`.
    
    Parameters
    ----------
    y_true : array-like of shape (n_samples,) or (n_samples, n_outputs)
        Ground truth (correct) target values.
    
    y_pred : array-like of shape (n_samples,) or (n_samples, n_outputs)
        Estimated target values.
    
    sample_weight : array-like of shape (n_samples,), default=None
        Sample weights.
    
    multioutput : {'raw_values', 'uniform_average', 'variance_weighted'},             array-like of shape (n_outputs,) or None, default='uniform_average'
    
        Defines aggregating of multiple output scores.
        Array-like value defines weights used to average scores.
        Default is "uniform_average".
    
        'raw_values' :
            Returns a full set of scores in case of multioutput input.
    
        'uniform_average' :
            Scores of all outputs are averaged with uniform weight.
    
        'variance_weighted' :
            Scores of all outputs are averaged, weighted by the variances
            of each individual output.
    
        .. versionchanged:: 0.19
            Default value of multioutput is 'uniform_average'.
    
    Returns
    -------
    z : float or ndarray of floats
        The :math:`R^2` score or ndarray of scores if 'multioutput' is
        'raw_values'.
    
    Notes
    -----
    This is not a symmetric function.
    
    Unlike most other scores, :math:`R^2` score may be negative (it need not
    actually be the square of a quantity R).
    
    This metric is not well-defined for single samples and will return a NaN
    value if n_samples is less than two.
    
    References
    ----------
    .. [1] `Wikipedia entry on the Coefficient of determination
            <https://en.wikipedia.org/wiki/Coefficient_of_determination>`_
    
    Examples
    --------
    >>> 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)
    0.948...
    >>> 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')
    0.938...
    >>> y_true = [1, 2, 3]
    >>> y_pred = [1, 2, 3]
    >>> r2_score(y_true, y_pred)
    1.0
    >>> y_true = [1, 2, 3]
    >>> y_pred = [2, 2, 2]
    >>> r2_score(y_true, y_pred)
    0.0
    >>> y_true = [1, 2, 3]
    >>> y_pred = [3, 2, 1]
    >>> r2_score(y_true, y_pred)
    -3.0

In [ ]: