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必须在单位间隔内

      时间:2024-08-22
    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必须在单位间隔内的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:CatBoostRegressor在尝试预测时显示错误(TypeError:无法将&#39;b&#39; 下一篇:我可以在skLearning上进行对数回归吗?

                相关文章

              2. <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>