当前位置: 首页>>代码示例>>Python>>正文


Python tools.categorical函数代码示例

本文整理汇总了Python中scikits.statsmodels.tools.tools.categorical函数的典型用法代码示例。如果您正苦于以下问题:Python categorical函数的具体用法?Python categorical怎么用?Python categorical使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了categorical函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: initialize

    def initialize(self):
        """
        Preprocesses the data for MNLogit.

        Turns the endogenous variable into an array of dummies and assigns
        J and K.
        """
        super(MNLogit, self).initialize()
        #This is also a "whiten" method as used in other models (eg regression)
        wendog, self.names = tools.categorical(self.endog, drop=True,
                dictnames=True)
        self.wendog = wendog    # don't drop first category
        self.J = float(wendog.shape[1])
        self.K = float(self.exog.shape[1])
        self.df_model *= (self.J-1) # for each J - 1 equation.
        self.df_resid = self.exog.shape[0] - self.df_model - (self.J-1)
开发者ID:pombredanne,项目名称:statsmodels,代码行数:16,代码来源:discrete_model.py

示例2: test_structarray1d_drop

 def test_structarray1d_drop(self):
     instr = self.structdes['str_instr'].view(dtype=[('var1', 'a10')])
     dum = tools.categorical(instr, drop=True)
     test_dum = np.column_stack(([dum[_] for _ in dum.dtype.names]))
     assert_array_equal(test_dum, self.dummy)
     assert_equal(len(dum.dtype.names), 5)
开发者ID:pombredanne,项目名称:statsmodels,代码行数:6,代码来源:test_tools.py

示例3: test_structarray2dint

 def test_structarray2dint(self):
     des = tools.categorical(self.structdes, col=3)
     test_des = np.column_stack(([des[_] for _ in des.dtype.names[-5:]]))
     assert_array_equal(test_des, self.dummy)
     assert_equal(len(des.dtype.names), 9)
开发者ID:pombredanne,项目名称:statsmodels,代码行数:5,代码来源:test_tools.py

示例4: test_structarray2d_drop

 def test_structarray2d_drop(self):
     des = tools.categorical(self.structdes, col='str_instr', drop=True)
     test_des = np.column_stack(([des[_] for _ in des.dtype.names[-5:]]))
     assert_array_equal(test_des, self.dummy)
     assert_equal(len(des.dtype.names), 8)
开发者ID:pombredanne,项目名称:statsmodels,代码行数:5,代码来源:test_tools.py

示例5: test_recarray2d

 def test_recarray2d(self):
     des = tools.categorical(self.recdes, col='str_instr')
     # better way to do this?
     test_des = np.column_stack(([des[_] for _ in des.dtype.names[-5:]]))
     assert_array_equal(test_des, self.dummy)
     assert_equal(len(des.dtype.names), 9)
开发者ID:pombredanne,项目名称:statsmodels,代码行数:6,代码来源:test_tools.py

示例6: test_recarray1d

 def test_recarray1d(self):
     instr = self.structdes['str_instr'].view(np.recarray)
     dum = tools.categorical(instr)
     test_dum = np.column_stack(([dum[_] for _ in dum.dtype.names[-5:]]))
     assert_array_equal(test_dum, self.dummy)
     assert_equal(len(dum.dtype.names), 6)
开发者ID:pombredanne,项目名称:statsmodels,代码行数:6,代码来源:test_tools.py

示例7: test_array1d_drop

 def test_array1d_drop(self):
     des = tools.categorical(self.string_var, drop=True)
     assert_array_equal(des, self.dummy)
     assert_equal(des.shape[1],5)
开发者ID:pombredanne,项目名称:statsmodels,代码行数:4,代码来源:test_tools.py

示例8: test_structarray1d

 def test_structarray1d(self):
     instr = self.structdes['instrument'].view(dtype=[('var1', 'f4')])
     dum = tools.categorical(instr)
     test_dum = np.column_stack(([dum[_] for _ in dum.dtype.names[-5:]]))
     assert_array_equal(test_dum, self.dummy)
     assert_equal(len(dum.dtype.names), 6)
开发者ID:pombredanne,项目名称:statsmodels,代码行数:6,代码来源:test_tools.py

示例9: test_recarray1d_drop

 def test_recarray1d_drop(self):
     instr = self.structdes['instrument'].view(np.recarray)
     dum = tools.categorical(instr, drop=True)
     test_dum = np.column_stack(([dum[_] for _ in dum.dtype.names]))
     assert_array_equal(test_dum, self.dummy)
     assert_equal(len(dum.dtype.names), 5)
开发者ID:pombredanne,项目名称:statsmodels,代码行数:6,代码来源:test_tools.py

示例10: test_array2d_drop

 def test_array2d_drop(self):
     des = np.column_stack((self.des, self.instr, self.des))
     des = tools.categorical(des, col=2, drop=True)
     assert_array_equal(des[:,-5:], self.dummy)
     assert_equal(des.shape[1],9)
开发者ID:pombredanne,项目名称:statsmodels,代码行数:5,代码来源:test_tools.py

示例11: test_array1d

 def test_array1d(self):
     des = tools.categorical(self.instr)
     assert_array_equal(des[:,-5:], self.dummy)
     assert_equal(des.shape[1],6)
开发者ID:pombredanne,项目名称:statsmodels,代码行数:4,代码来源:test_tools.py


注:本文中的scikits.statsmodels.tools.tools.categorical函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。