<tfoot id='TOgji'></tfoot>
    • <bdo id='TOgji'></bdo><ul id='TOgji'></ul>

    <small id='TOgji'></small><noframes id='TOgji'>

    <i id='TOgji'><tr id='TOgji'><dt id='TOgji'><q id='TOgji'><span id='TOgji'><b id='TOgji'><form id='TOgji'><ins id='TOgji'></ins><ul id='TOgji'></ul><sub id='TOgji'></sub></form><legend id='TOgji'></legend><bdo id='TOgji'><pre id='TOgji'><center id='TOgji'></center></pre></bdo></b><th id='TOgji'></th></span></q></dt></tr></i><div id='TOgji'><tfoot id='TOgji'></tfoot><dl id='TOgji'><fieldset id='TOgji'></fieldset></dl></div>

    1. <legend id='TOgji'><style id='TOgji'><dir id='TOgji'><q id='TOgji'></q></dir></style></legend>

      Plotly:如何在 plotly express 中找到趋势线的系数?

      Plotly: How to find coefficient of trendline in plotly express?(Plotly:如何在 plotly express 中找到趋势线的系数?)
        <bdo id='xnY6b'></bdo><ul id='xnY6b'></ul>
      • <tfoot id='xnY6b'></tfoot>

            <small id='xnY6b'></small><noframes id='xnY6b'>

              <tbody id='xnY6b'></tbody>

          • <legend id='xnY6b'><style id='xnY6b'><dir id='xnY6b'><q id='xnY6b'></q></dir></style></legend>

              1. <i id='xnY6b'><tr id='xnY6b'><dt id='xnY6b'><q id='xnY6b'><span id='xnY6b'><b id='xnY6b'><form id='xnY6b'><ins id='xnY6b'></ins><ul id='xnY6b'></ul><sub id='xnY6b'></sub></form><legend id='xnY6b'></legend><bdo id='xnY6b'><pre id='xnY6b'><center id='xnY6b'></center></pre></bdo></b><th id='xnY6b'></th></span></q></dt></tr></i><div id='xnY6b'><tfoot id='xnY6b'></tfoot><dl id='xnY6b'><fieldset id='xnY6b'></fieldset></dl></div>
              2. 本文介绍了Plotly:如何在 plotly express 中找到趋势线的系数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                How do you find the coefficient of the trend line in plotly express?

                For example I used the code below to chart the trend line but now I want to know the coefficient.

                import plotly.express as px
                
                px.scatter(df, x='x_data', y='y_data', trendline="ols")
                

                解决方案

                Here you need to have a look at plotly doc in plotly and statsmodels one. I think the example in the plotly example should be fixed. Anyway

                import plotly.express as px
                
                df = px.data.tips()
                fig = px.scatter(df, x="total_bill", y="tip", trendline="ols")
                fig.show()
                

                For the results you should run

                results = px.get_trendline_results(fig)
                results = results.iloc[0]["px_fit_results"].summary()
                print(results)
                

                                            OLS Regression Results                            
                ==============================================================================
                Dep. Variable:                      y   R-squared:                       0.457
                Model:                            OLS   Adj. R-squared:                  0.454
                Method:                 Least Squares   F-statistic:                     203.4
                Date:                Mon, 10 Aug 2020   Prob (F-statistic):           6.69e-34
                Time:                        12:28:52   Log-Likelihood:                -350.54
                No. Observations:                 244   AIC:                             705.1
                Df Residuals:                     242   BIC:                             712.1
                Df Model:                           1                                         
                Covariance Type:            nonrobust                                         
                ==============================================================================
                                 coef    std err          t      P>|t|      [0.025      0.975]
                ------------------------------------------------------------------------------
                const          0.9203      0.160      5.761      0.000       0.606       1.235
                x1             0.1050      0.007     14.260      0.000       0.091       0.120
                ==============================================================================
                Omnibus:                       20.185   Durbin-Watson:                   1.811
                Prob(Omnibus):                  0.000   Jarque-Bera (JB):               37.750
                Skew:                           0.443   Prob(JB):                     6.35e-09
                Kurtosis:                       4.711   Cond. No.                         53.0
                ==============================================================================
                

                While for the coefficients

                results.iloc[0]["px_fit_results"].params
                

                array([0.92026961, 0.10502452])
                

                Where the fist one is the constant while the second is the slope.

                这篇关于Plotly:如何在 plotly express 中找到趋势线的系数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                Adding config modes to Plotly.Py offline - modebar(将配置模式添加到 Plotly.Py 离线 - 模式栏)
                Plotly: How to style a plotly figure so that it doesn#39;t display gaps for missing dates?(Plotly:如何设置绘图图形的样式,使其不显示缺失日期的间隙?)
                python save plotly plot to local file and insert into html(python将绘图保存到本地文件并插入到html中)
                Plotly: What color cycle does plotly express follow?(情节:情节表达遵循什么颜色循环?)
                How to save plotly express plot into a html or static image file?(如何将情节表达图保存到 html 或静态图像文件中?)
                Plotly: How to make a line plot from a pandas dataframe with a long or wide format?(Plotly:如何使用长格式或宽格式的 pandas 数据框制作线图?)
                    1. <small id='0thXG'></small><noframes id='0thXG'>

                        <bdo id='0thXG'></bdo><ul id='0thXG'></ul>

                      • <legend id='0thXG'><style id='0thXG'><dir id='0thXG'><q id='0thXG'></q></dir></style></legend>

                        <tfoot id='0thXG'></tfoot>
                          <i id='0thXG'><tr id='0thXG'><dt id='0thXG'><q id='0thXG'><span id='0thXG'><b id='0thXG'><form id='0thXG'><ins id='0thXG'></ins><ul id='0thXG'></ul><sub id='0thXG'></sub></form><legend id='0thXG'></legend><bdo id='0thXG'><pre id='0thXG'><center id='0thXG'></center></pre></bdo></b><th id='0thXG'></th></span></q></dt></tr></i><div id='0thXG'><tfoot id='0thXG'></tfoot><dl id='0thXG'><fieldset id='0thXG'></fieldset></dl></div>

                            <tbody id='0thXG'></tbody>