【Training versus Testing】Positive intervals

GPT的解释:

这段话解释了在一维中,针对 "Positive intervals"(正间隔)假设类别 H 的成长函数 mq(N) 的计算方式,以及如何得出这个成长函数。

1. "Positive intervals" 指的是一维情境中的假设,每个假设都由一个区间内的数据点返回 +1,而区间之外的点返回 -1。每个假设由该区间的两个端点来指定。

2. 当给定 N 个点时,这些点将一维空间分割成 N+1 个区域。每个区域由两个相邻的点之间的部分定义。

3. 对于每个区间的假设,我们需要考虑两个端点落入哪两个相邻的区域。这会导致 (N+1)/2 种不同的分割方式(dichotomies)。这是因为第一个端点有 N+1 种选择,但第二个端点必须与第一个端点所在的区域不同,所以有 (N+1)/2 种不同的组合

4. 如果两个端点都落在同一个区域,那么假设将始终是常数 -1,不管是哪个区域。

5. 将这些可能性相加,我们得到成长函数 m_H(N) 的表达式:

   m_H(N) = ((N+1)/2) * |interval ends in N+1 spots| + 1 * |all x|

   这里 |interval ends in N+1 spots| 表示端点落在不同区域的数量,|all x| 表示两个端点都在同一个区域的数量

6. 最后,计算这个表达式,得到 m_H(N) = (1/2) * N^2 + (1/2) * N + 1。这是在给定 N 个点时 "Positive intervals" 假设类别 H 的成长函数。

总结:这段话解释了如何计算在一维情境中 "Positive intervals" 假设类别 H 的成长函数 mq(N),并展示了成长函数的计算方式。其中,(N+1)/2 表达了端点落在不同区域的数量,它是根据给定的 N 点来计算的。最后,它提到 mq(N) 增长速度较快,与较简单的 "positive ray" 情况的线性 mq(N) 不同。

 第五步到第六步是如何推导出来的?

第五步到第六步是通过将第四步中的不同情况的数量代入第五步的表达式来推导出来的。我将详细解释这个推导过程:

在第四步中,我们得到了成长函数 m_H(N) 的表达式:

m_H(N) = ((N+1)/2) * |interval ends in N+1 spots| + 1 * |all x|

其中,|interval ends in N+1 spots| 表示端点落在不同区域的数量,|all x| 表示两个端点都在同一个区域的数量。

现在,我们将计算这两种情况的数量,并将它们代入表达式中:

1. **端点落在不同区域的数量**:根据前面的解释,在 N 个点的情况下,两个端点可以以 (N+1)/2 种不同的方式分布在不同的区域,因为第一个端点有 N+1 种选择,但第二个端点必须与第一个端点所在的区域不同。所以,|interval ends in N+1 spots| = (N+1)/2。

2. **两个端点都在同一个区域的数量**:这表示两个端点都在 N+1 个区域中的同一个区域内。由于有 N+1 个区域可供选择,所以 |all x| = N+1。

现在,我们将这两个数量代入成长函数的表达式:

m_H(N) = ((N+1)/2) * |interval ends in N+1 spots| + 1 * |all x|
m_H(N) = ((N+1)/2) * ((N+1)/2) + 1 * (N+1)

继续计算:

m_H(N) = ((N+1)^2)/4 + (N+1)

最后,将 ((N+1)^2)/4 展开并将其与 (N+1) 相加,得到最终的表达式:

m_H(N) = (1/2) * N^2 + (1/2) * N + 1

这就是从第五步到第六步的推导过程,其中我们计算了不同情况的数量并代入成长函数的表达式,以得到最终的成长函数表达式。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Table of Contents Preface 1 Chapter 1: Django Testing Overview 9 Getting started: Creating a new application 10 Understanding the sample unit test 10 Understanding the sample doctest 11 Running the sample tests 12 Breaking things on purpose 15 Test errors versus test failures 20 Command line options for running tests 23 Verbosity 24 Settings 27 Pythonpath 27 Traceback 27 Noinput 27 Version 28 Summary 28 Chapter 2: Does This Code Work? Doctests in Depth 29 The Survey application models 29 Testing the Survey model 31 Testing Survey model creation 31 Is that test useful? 34 Developing a custom Survey save method 35 Deciding what to test 39 Some pros and cons of doctests so far 40 Additional doctest caveats 44 Beware of environmental dependence 44 Beware of database dependence 47 Table of Contents [ ii ] Beware of test interdependence 52 Beware of Unicode 57 Summary 62 Chapter 3: Testing 1, 2, 3: Basic Unit Testing 63 Unit tests for the Survey save override method 63 Pros of the unit test version 65 Cons of the unit test version 69 Revisiting the doctest caveats 69 Environmental dependence 70 Database dependence 70 Test interdependence 75 Unicode 75 Providing data for unit tests 76 Providing data in test fixtures 76 Example test that needs test data 76 Using the admin application to create test data 78 Writing the function itself 83 Writing a test that uses the test data 85 Extracting the test data from the database 86 Getting the test data loaded during the test run 87 Creating data during test set up 92 Summary 96 Chapter 4: Getting Fancier: Django Unit Test Extensions 97 Organizing tests 98 Creating the survey application home page 101 Defining the survey application URLs 102 Developing views to serve pages 104 Creating templates for pages 106 Testing the survey home page 110 Creating the survey detail pages 117 Refining the survey detail view 117 Templates for the survey detail pages 118 Basic testing of the survey detail pages 119 Customizing the admin add and change survey pages 122 Developing a custom survey form 122 Configuring admin to use the custom form 123 Testing the admin customization 124 Additional test support 130 Supporting additional HTTP methods 130 Maintaining persistent state 130 E-mail services 130 Table of Contents [ iii ] Providing test-specific URL configuration 131 Response context and template information 131 Testing transactional behavior 132 Chapter 5: Filling in the Blanks: Integrating Django and Other Test Tools 135 Problems of integration 136 Specifying an alternative test runner 138 Creating a new management command 141 How much of the code are we testing? 144 Using coverage standalone 145 Integrating coverage into a Django project 149 The twill web browsing and testing tool 153 Using the twill command line program 155 Using twill in a TestCase 159 Summary 167 Chapter 6: Django Debugging Overview 169 Django debug settings 170 The DEBUG and TEMPLATE_DEBUG settings 170 The TEMPLATE_STRING_IF_INVALID setting 171 Debug error pages 172 Database query history 176 Debug support in the development server 179 Handling problems in production 182 Creating general error pages 183 Reporting production error information 183 Internal server error notifications 184 Page not found notifications 185 Summary 187 Chapter 7: When the Wheels Fall Off: Understanding a Django Debug Page 189 Starting the Survey voting implementation 190 Creating test data for voting 191 Defining a question form for voting 192 Debug page #1: TypeError at / 195 Elements of the debug page 196 Basic error information 197 Traceback 198 Request information 203 GET 203 POST 203 FILES 203 Table of Contents [ iv ] COOKIES 203 META 204 Settings 204 Understanding and fixing the TypeError 205 Handling multiple Survey questions 209 Creating the data for multiple questions 209 Coding support for multiple questions 210 Debug page #2: TemplateSyntaxError at /1/ 211 Understanding and fixing the TemplateSyntaxError 212 Recording Survey responses 213 Coding support for recording Survey responses 214 Debug page #3: NoReverseMatch at /1/ 218 Understanding and fixing the NoReverseMatch exception 219 Debug page #4: TemplateDoesNotExist at /thanks/1/ 221 Understanding and fixing TemplateDoesNotExist 223 Handling invalid Survey submissions 224 Coding custom error message and placement 226 Debug page #5: Another TemplateSyntaxError 229 Fixing the second TemplateSyntaxError 232 Summary 233 Chapter 8: When Problems Hide: Getting More Information 235 Tracking SQL queries for a request 236 Settings for accessing query history in templates 236 SQL queries for the home page 237 Packaging the template query display for reuse 243 Testing the repackaged template code 247 SQL queries for the active Survey form display page 252 SQL queries for posting survey answers 255 The Django Debug Toolbar 256 Installing the Django Debug Toolbar 257 Debug toolbar appearance 258 The SQL panel 260 The Time panel 263 The Settings panel 264 The HTTP Headers panel 264 The Request Vars panel 265 The Templates panel 266 The Signals panel 267 The Logging panel 268 Redirect handling by the debug toolbar 268 Table of Contents [ v ] Tracking internal code state 273 Resist the urge to sprinkle prints 273 Simple logging configuring for development 275 Deciding what to log 277 Decorators to log function entry and exit 277 Applying the decorators to the Survey code 280 Logging in the debug toolbar 282 Summary 284 Chapter 9: When You Don't Even Know What to Log: Using Debuggers 285 Implementing the Survey results display 285 Results display using pygooglechart 288 Getting started with the debugger 293 The list command 295 The where command 296 The args command 300 The whatis command 300 The print and pp commands 300 Debugging the pygooglechart results display 301 The step and next commands 301 The continue command 307 The jump command 307 The break command 309 The clear command 310 Fixing the pygooglechart results display 312 The up and down commands 312 The return command 316 Results display using matplotlib 319 Improving the matplotlib approach 324 Setting up static file serving 325 Dynamically generating image files 327 Dealing with race conditions 329 Using the debugger to force race situations 334 Notes on using graphical debuggers 344 Summary 345 Chapter 10: When All Else Fails: Getting Outside Help 347 Tracking down a problem in Django 348 Revisiting the Chapter 7 voting form 348 Is the right code actually running? 350 Is the code correct as per the documentation? 351 Table of Contents [ vi ] Searching for a matching problem report 354 Another way to search for a matching problem report 359 Determining the release that contains a fix 363 What if a fix hasn't been released yet? 365 What if a fix hasn't been committed yet? 366 What if a ticket has been closed without a fix? 367 Tracking down unreported problems 368 Where to ask questions 369 Tips on asking questions that will get good answers 370 Opening a new ticket to report a problem 372 Summary 374 Chapter 11: When it's Time to Go Live: Moving to Production 375 Developing an Apache/mod_wsgi configuration 376 Creating the WSGI script for the marketr project 378 Creating an Apache VirtualHost for the marketr project 379 Activating the new Apache configuration 380 Debugging the new Apache configuration 383 Configuring Apache to serve static files 391 Testing multithreaded behavior 396 Generating load with siege 397 Load testing the results recording code 399 Fixing the results recording code 404 Additional load testing notes 406 Using Apache/mod_wsgi during development 407 Summary 409 Index 411

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值