{ "cells": [ { "cell_type": "code", "execution_count": 1, "outputs": [], "source": [ "import pandas as pd" ], "metadata": { "collapsed": false, "pycharm": { "name": "#%%\n" } } }, { "cell_type": "code", "execution_count": 2, "outputs": [], "source": [ "data = pd.read_csv('./供热测试结果.csv')" ], "metadata": { "collapsed": false, "pycharm": { "name": "#%%\n" } } }, { "cell_type": "code", "execution_count": 3, "outputs": [ { "data": { "text/plain": " 0 1\n0 0.072858 0.072700\n1 0.073347 0.075045\n2 0.082159 0.080671\n3 0.084120 0.081944\n4 0.065845 0.066739\n.. ... ...\n408 0.066066 0.066927\n409 0.084331 0.082709\n410 0.069216 0.069256\n411 0.065259 0.066203\n412 0.069608 0.071754\n\n[413 rows x 2 columns]", "text/html": "
\n\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n
01
00.0728580.072700
10.0733470.075045
20.0821590.080671
30.0841200.081944
40.0658450.066739
.........
4080.0660660.066927
4090.0843310.082709
4100.0692160.069256
4110.0652590.066203
4120.0696080.071754
\n

413 rows × 2 columns

\n
" }, "execution_count": 3, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data" ], "metadata": { "collapsed": false, "pycharm": { "name": "#%%\n" } } }, { "cell_type": "code", "execution_count": 4, "outputs": [], "source": [ "from sklearn.metrics import r2_score" ], "metadata": { "collapsed": false, "pycharm": { "name": "#%%\n" } } }, { "cell_type": "code", "execution_count": 7, "outputs": [ { "data": { "text/plain": "0.8483477508497194" }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "r2_score(data.values[:,1], data.values[:,0])" ], "metadata": { "collapsed": false, "pycharm": { "name": "#%%\n" } } }, { "cell_type": "code", "execution_count": 8, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Help on function r2_score in module sklearn.metrics._regression:\n", "\n", "r2_score(y_true, y_pred, *, sample_weight=None, multioutput='uniform_average')\n", " :math:`R^2` (coefficient of determination) regression score function.\n", " \n", " Best possible score is 1.0 and it can be negative (because the\n", " model can be arbitrarily worse). A constant model that always\n", " predicts the expected value of y, disregarding the input features,\n", " would get a :math:`R^2` score of 0.0.\n", " \n", " Read more in the :ref:`User Guide `.\n", " \n", " Parameters\n", " ----------\n", " y_true : array-like of shape (n_samples,) or (n_samples, n_outputs)\n", " Ground truth (correct) target values.\n", " \n", " y_pred : array-like of shape (n_samples,) or (n_samples, n_outputs)\n", " Estimated target values.\n", " \n", " sample_weight : array-like of shape (n_samples,), default=None\n", " Sample weights.\n", " \n", " multioutput : {'raw_values', 'uniform_average', 'variance_weighted'}, array-like of shape (n_outputs,) or None, default='uniform_average'\n", " \n", " Defines aggregating of multiple output scores.\n", " Array-like value defines weights used to average scores.\n", " Default is \"uniform_average\".\n", " \n", " 'raw_values' :\n", " Returns a full set of scores in case of multioutput input.\n", " \n", " 'uniform_average' :\n", " Scores of all outputs are averaged with uniform weight.\n", " \n", " 'variance_weighted' :\n", " Scores of all outputs are averaged, weighted by the variances\n", " of each individual output.\n", " \n", " .. versionchanged:: 0.19\n", " Default value of multioutput is 'uniform_average'.\n", " \n", " Returns\n", " -------\n", " z : float or ndarray of floats\n", " The :math:`R^2` score or ndarray of scores if 'multioutput' is\n", " 'raw_values'.\n", " \n", " Notes\n", " -----\n", " This is not a symmetric function.\n", " \n", " Unlike most other scores, :math:`R^2` score may be negative (it need not\n", " actually be the square of a quantity R).\n", " \n", " This metric is not well-defined for single samples and will return a NaN\n", " value if n_samples is less than two.\n", " \n", " References\n", " ----------\n", " .. [1] `Wikipedia entry on the Coefficient of determination\n", " `_\n", " \n", " Examples\n", " --------\n", " >>> from sklearn.metrics import r2_score\n", " >>> y_true = [3, -0.5, 2, 7]\n", " >>> y_pred = [2.5, 0.0, 2, 8]\n", " >>> r2_score(y_true, y_pred)\n", " 0.948...\n", " >>> y_true = [[0.5, 1], [-1, 1], [7, -6]]\n", " >>> y_pred = [[0, 2], [-1, 2], [8, -5]]\n", " >>> r2_score(y_true, y_pred,\n", " ... multioutput='variance_weighted')\n", " 0.938...\n", " >>> y_true = [1, 2, 3]\n", " >>> y_pred = [1, 2, 3]\n", " >>> r2_score(y_true, y_pred)\n", " 1.0\n", " >>> y_true = [1, 2, 3]\n", " >>> y_pred = [2, 2, 2]\n", " >>> r2_score(y_true, y_pred)\n", " 0.0\n", " >>> y_true = [1, 2, 3]\n", " >>> y_pred = [3, 2, 1]\n", " >>> r2_score(y_true, y_pred)\n", " -3.0\n", "\n" ] } ], "source": [ "help(r2_score)" ], "metadata": { "collapsed": false, "pycharm": { "name": "#%%\n" } } }, { "cell_type": "code", "execution_count": null, "outputs": [], "source": [], "metadata": { "collapsed": false, "pycharm": { "name": "#%%\n" } } } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 2 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython2", "version": "2.7.6" } }, "nbformat": 4, "nbformat_minor": 0 }