UAT 306 Artificial Intelligence for UAS

Worksheet 2 Training by hand and comparing with a library

Analysis activity 3 hAssesses CLO1, CLO3

Objective

Understand gradient-descent training against a library and use cross-validation to detect underfitting and overfitting, and build a regression model from flight data

Equipment and materials

  • Computer with Python, numpy, scikit-learn and matplotlib
  • Module 2 example code
  • Flight logs with battery current (from the lecturer, or your own if available)

Safety

  • Desk work only; no flying

Steps

  1. In class: run Example 1 with learning rates 0.01, 0.5 and 100; observe the loss
  2. Self-study: plot the three loss curves and explain the differences
  3. In class: train the same data with scikit-learn LogisticRegression; compare accuracy and the direction of the weights
  4. In class: run Example 2 for degrees 1 to 12; plot both error curves
  5. In class: reduce the data to 15 points; see whether the best degree changes
  6. Self-study: replace the data in Example 3 with hover current from flight logs; fit the line and report the leave-one-flight-out RMSE and the mass range
  7. Self-study: summarise how to tell whether a model underfits or overfits

Record of results

Table 1 Effect of learning rate and comparison with scikit-learn
SettingLoss at iteration 10Loss at iteration 500AccuracyWeights (bias, elongation, edge)
Table 2 Error by polynomial degree (5-fold)
DegreeTrain RMSE (30 points)Validation RMSE (30 points)Train RMSE (15 points)Validation RMSE (15 points)
Table 3 Hover-current model from takeoff mass
ItemValueUnitSource or note

Questions

  1. From Table 1 and the three loss curves, which learning rate suits this data best, and what does the loss curve look like when the learning rate is too high?

  2. From Table 2, which degree gives the lowest validation RMSE with 30 points and with 15 points? Why does the best degree not increase when there is less data?

  3. Over what mass range is the current model in Table 3 valid? If the team fits a new camera that takes the mass outside that range, what should it do before planning flight times?

  4. Using your own results, explain how to tell whether a model underfits or overfits, quoting training and validation RMSE.

Check before you hand in

What to hand in

  • Loss curves by learning rate
  • Comparison with scikit-learn
  • Error-by-degree plots for both cases
  • Conclusion on underfitting and overfitting
  • Hover-current model with its RMSE and valid mass range

CLO1 Explain machine learning and deep learning principles. CLO3 Train, evaluate and deploy models. (CLOs are a web-team draft; the course owner sets the final ones.)

Instructors: answers and teaching notes for this worksheet are in the teaching pack