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


Python data.handle_data函数代码示例

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


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

示例1: setupClass

 def setupClass(cls):
     cls.endog = endog = pandas.DataFrame(np.random.random((10,4)),
                                  columns=['y_1', 'y_2', 'y_3', 'y_4'])
     exog =  pandas.DataFrame(np.random.random((10,2)),
                              columns=['x_1','x_2'])
     exog.insert(0, 'const', 1)
     cls.exog = exog
     cls.data = sm_data.handle_data(cls.endog, cls.exog)
     nrows = 10
     nvars = 3
     neqs = 4
     cls.col_input = np.random.random(nvars)
     cls.col_result = pandas.Series(cls.col_input,
                                       index=exog.columns)
     cls.row_input = np.random.random(nrows)
     cls.row_result = pandas.Series(cls.row_input,
                                       index=exog.index)
     cls.cov_input = np.random.random((nvars, nvars))
     cls.cov_result = pandas.DataFrame(cls.cov_input,
                                        index = exog.columns,
                                        columns = exog.columns)
     cls.cov_eq_input = np.random.random((neqs, neqs))
     cls.cov_eq_result = pandas.DataFrame(cls.cov_eq_input,
                                           index=endog.columns,
                                           columns=endog.columns)
     cls.col_eq_input = np.random.random((nvars, neqs))
     cls.col_eq_result = pandas.DataFrame(cls.col_eq_input,
                                           index=exog.columns,
                                           columns=endog.columns)
     cls.xnames = ['const', 'x_1', 'x_2']
     cls.ynames = ['y_1', 'y_2', 'y_3', 'y_4']
     cls.row_labels = cls.exog.index
开发者ID:dengemann,项目名称:statsmodels,代码行数:32,代码来源:test_data.py

示例2: test_extra_kwargs_2d

 def test_extra_kwargs_2d(self):
     sigma = np.random.random((25, 25))
     sigma = sigma + sigma.T - np.diag(np.diag(sigma))
     data = sm_data.handle_data(self.y, self.X, 'drop', sigma=sigma)
     idx = ~np.isnan(np.c_[self.y, self.X]).any(axis=1)
     sigma = sigma[idx][:,idx]
     np.testing.assert_array_equal(data.sigma, sigma)
开发者ID:dengemann,项目名称:statsmodels,代码行数:7,代码来源:test_data.py

示例3: setupClass

 def setupClass(cls):
     super(TestStructarrays, cls).setupClass()
     cls.endog = np.random.random(9).view([("y_1", "f8")]).view(np.recarray)
     exog = np.random.random(9 * 3).view([("const", "f8"), ("x_1", "f8"), ("x_2", "f8")]).view(np.recarray)
     exog["const"] = 1
     cls.exog = exog
     cls.data = sm_data.handle_data(cls.endog, cls.exog)
     cls.xnames = ["const", "x_1", "x_2"]
     cls.ynames = "y_1"
开发者ID:ymarfoq,项目名称:outilACVDesagregation,代码行数:9,代码来源:test_data.py

示例4: test_drop

 def test_drop(self):
     y = self.y
     X = self.X
     combined = np.c_[y, X]
     idx = ~np.isnan(combined).any(axis=1)
     y = y[idx]
     X = X[idx]
     data = sm_data.handle_data(self.y, self.X, 'drop')
     np.testing.assert_array_equal(data.endog, y)
     np.testing.assert_array_equal(data.exog, X)
开发者ID:dengemann,项目名称:statsmodels,代码行数:10,代码来源:test_data.py

示例5: setup_class

 def setup_class(cls):
     cls.endog = pandas.DataFrame(np.random.random(10), columns=['y_1'])
     mi = pandas.MultiIndex.from_product([['x'], ['1', '2']])
     exog = pandas.DataFrame(np.random.random((10, 2)), columns=mi)
     exog_flattened_idx = pandas.Index(['const', 'x_1', 'x_2'])
     exog.insert(0, 'const', 1)
     cls.exog = exog
     cls.data = sm_data.handle_data(cls.endog, cls.exog)
     nrows = 10
     nvars = 3
     cls.col_input = np.random.random(nvars)
     cls.col_result = pandas.Series(cls.col_input, index=exog_flattened_idx)
     cls.row_input = np.random.random(nrows)
     cls.row_result = pandas.Series(cls.row_input, index=exog.index)
     cls.cov_input = np.random.random((nvars, nvars))
     cls.cov_result = pandas.DataFrame(cls.cov_input,
                                       index=exog_flattened_idx,
                                       columns=exog_flattened_idx)
     cls.xnames = ['const', 'x_1', 'x_2']
     cls.ynames = 'y_1'
     cls.row_labels = cls.exog.index
开发者ID:bashtage,项目名称:statsmodels,代码行数:21,代码来源:test_data.py

示例6: setup_class

    def setup_class(cls):
        cls.endog = np.random.random(10).tolist()

        exog =  pandas.DataFrame(np.random.random((10,2)),
                                 columns=['x_1','x_2'])
        exog.insert(0, 'const', 1)
        cls.exog = exog
        cls.data = sm_data.handle_data(cls.endog, cls.exog)
        nrows = 10
        nvars = 3
        cls.col_input = np.random.random(nvars)
        cls.col_result = pandas.Series(cls.col_input,
                                          index=exog.columns)
        cls.row_input = np.random.random(nrows)
        cls.row_result = pandas.Series(cls.row_input,
                                          index=exog.index)
        cls.cov_input = np.random.random((nvars, nvars))
        cls.cov_result = pandas.DataFrame(cls.cov_input,
                                           index = exog.columns,
                                           columns = exog.columns)
        cls.xnames = ['const', 'x_1', 'x_2']
        cls.ynames = 'y'
        cls.row_labels = cls.exog.index
开发者ID:lbybee,项目名称:statsmodels,代码行数:23,代码来源:test_data.py

示例7: test_labels

 def test_labels(self):
     2, 10, 14
     labels = pandas.Index([0, 1, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13, 15,
                            16, 17, 18, 19, 20, 21, 22, 23, 24])
     data = sm_data.handle_data(self.y, self.X, 'drop')
     np.testing.assert_(data.row_labels.equals(labels))
开发者ID:dengemann,项目名称:statsmodels,代码行数:6,代码来源:test_data.py

示例8: test_mv_endog

 def test_mv_endog(self):
     y = self.X
     y = y.ix[~np.isnan(y.values).any(axis=1)]
     data = sm_data.handle_data(self.X, None, 'drop')
     np.testing.assert_array_equal(data.endog, y.values)
开发者ID:dengemann,项目名称:statsmodels,代码行数:5,代码来源:test_data.py

示例9: test_endog_only_drop

 def test_endog_only_drop(self):
     y = self.y
     y = y.dropna()
     data = sm_data.handle_data(self.y, None, 'drop')
     np.testing.assert_array_equal(data.endog, y.values)
开发者ID:dengemann,项目名称:statsmodels,代码行数:5,代码来源:test_data.py

示例10: test_none

 def test_none(self):
     data = sm_data.handle_data(self.y, self.X, 'none')
     np.testing.assert_array_equal(data.endog, self.y.values)
     np.testing.assert_array_equal(data.exog, self.X.values)
开发者ID:dengemann,项目名称:statsmodels,代码行数:4,代码来源:test_data.py

示例11: test_raise_no_missing

 def test_raise_no_missing(self):
     # smoke test for #1700
     sm_data.handle_data(pandas.Series(np.random.random(20)),
                         pandas.DataFrame(np.random.random((20, 2))),
                         'raise')
开发者ID:philippmuller,项目名称:statsmodels,代码行数:5,代码来源:test_data.py

示例12: test_extra_kwargs_1d

 def test_extra_kwargs_1d(self):
     weights = np.random.random(25)
     data = sm_data.handle_data(self.y, self.X, 'drop', weights=weights)
     idx = ~np.isnan(np.c_[self.y, self.X]).any(axis=1)
     weights = weights[idx]
     np.testing.assert_array_equal(data.weights, weights)
开发者ID:dengemann,项目名称:statsmodels,代码行数:6,代码来源:test_data.py

示例13: test_none

 def test_none(self):
     data = sm_data.handle_data(self.y, self.X, 'none', hasconst=False)
     np.testing.assert_array_equal(data.endog, self.y)
     np.testing.assert_array_equal(data.exog, self.X)
开发者ID:lbybee,项目名称:statsmodels,代码行数:4,代码来源:test_data.py

示例14: test_pandas_noconstant

 def test_pandas_noconstant(self):
     exog = self.data.exog.copy()
     data = sm_data.handle_data(self.data.endog, exog)
     np.testing.assert_equal(data.k_constant, 0)
     np.testing.assert_equal(data.const_idx, None)
开发者ID:philippmuller,项目名称:statsmodels,代码行数:5,代码来源:test_data.py

示例15: test_array_noconstant

 def test_array_noconstant(self):
     exog = self.data.exog.copy()
     data = sm_data.handle_data(self.data.endog.values, exog.values)
     np.testing.assert_equal(data.k_constant, 0)
     np.testing.assert_equal(data.const_idx, None)
开发者ID:philippmuller,项目名称:statsmodels,代码行数:5,代码来源:test_data.py


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