1. <legend id='H3QAr'><style id='H3QAr'><dir id='H3QAr'><q id='H3QAr'></q></dir></style></legend>
    <tfoot id='H3QAr'></tfoot>
    <i id='H3QAr'><tr id='H3QAr'><dt id='H3QAr'><q id='H3QAr'><span id='H3QAr'><b id='H3QAr'><form id='H3QAr'><ins id='H3QAr'></ins><ul id='H3QAr'></ul><sub id='H3QAr'></sub></form><legend id='H3QAr'></legend><bdo id='H3QAr'><pre id='H3QAr'><center id='H3QAr'></center></pre></bdo></b><th id='H3QAr'></th></span></q></dt></tr></i><div id='H3QAr'><tfoot id='H3QAr'></tfoot><dl id='H3QAr'><fieldset id='H3QAr'></fieldset></dl></div>
    • <bdo id='H3QAr'></bdo><ul id='H3QAr'></ul>

    1. <small id='H3QAr'></small><noframes id='H3QAr'>

      ValueError:endog必须在单位间隔内

      ValueError: endog must be in the unit interval(ValueError:endog必须在单位间隔内)
    2. <small id='IniHG'></small><noframes id='IniHG'>

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

              <tbody id='IniHG'></tbody>

              <bdo id='IniHG'></bdo><ul id='IniHG'></ul>
                <tfoot id='IniHG'></tfoot>
              1. <legend id='IniHG'><style id='IniHG'><dir id='IniHG'><q id='IniHG'></q></dir></style></legend>
                本文介绍了ValueError:endog必须在单位间隔内的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                在使用statsmodel时,我收到了这个奇怪的错误:ValueError: endog must be in the unit interval.有人能给我提供有关此错误的更多信息吗?谷歌帮不上忙。

                产生错误的代码:

                """
                Multiple regression with dummy variables. 
                """
                
                import pandas as pd
                import statsmodels.api as sm
                import pylab as pl
                import numpy as np
                
                df = pd.read_csv('cost_data.csv')
                df.columns = ['Cost', 'R(t)', 'Day of Week']
                dummy_ranks = pd.get_dummies(df['Day of Week'], prefix='days')
                cols_to_keep = ['Cost', 'R(t)']
                data = df[cols_to_keep].join(dummy_ranks.ix[:,'days_2':])
                data['intercept'] = 1.0
                
                print(data)
                
                train_cols = data.columns[1:]
                logit = sm.Logit(data['Cost'], data[train_cols])
                
                result = logit.fit()
                
                print(result.summary())
                

                和回溯:

                Traceback (most recent call last):
                  File "multiple_regression_dummy.py", line 20, in <module>
                    logit = sm.Logit(data['Cost'], data[train_cols])
                  File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/site-packages/statsmodels/discrete/discrete_model.py", line 404, in __init__
                    raise ValueError("endog must be in the unit interval.")
                ValueError: endog must be in the unit interval.
                

                推荐答案

                当我的目标列的值大于1时,我收到此错误。 请确保您的目标列介于0和1之间(这是Logistic回归所必需的),然后重试。 例如,如果目标列的值为1-5,则将4和5设为正类别,将1,2,3设为负类别。希望这能有所帮助。

                这篇关于ValueError:endog必须在单位间隔内的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                相关文档推荐

                groupby multiple coords along a single dimension in xarray(在xarray中按单个维度的多个坐标分组)
                Group by and Sum in Pandas without losing columns(Pandas中的GROUP BY AND SUM不丢失列)
                Group by + New Column + Grab value former row based on conditionals(GROUP BY+新列+基于条件的前一行抓取值)
                Groupby and interpolate in Pandas(PANDA中的Groupby算法和插值算法)
                Pandas - Group Rows based on a column and replace NaN with non-null values(PANAS-基于列对行进行分组,并将NaN替换为非空值)
                Grouping pandas DataFrame by 10 minute intervals(按10分钟间隔对 pandas 数据帧进行分组)
                • <legend id='jwApe'><style id='jwApe'><dir id='jwApe'><q id='jwApe'></q></dir></style></legend>

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

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

                            <tbody id='jwApe'></tbody>