Fast Fourier Transform. More...
Functions | |
| AFAPI array | fftNorm (const array &in, const double norm_factor, const dim_t odim0=0) |
| C++ Interface for fast fourier transform on one dimensional signals. | |
| AFAPI void | fftInPlace (array &in, const double norm_factor=1.0) |
| C++ Interface for fast fourier transform on one dimensional signals. | |
| AFAPI array | fft (const array &in, const dim_t odim0=0) |
| C++ Interface for fast fourier transform on one dimensional signals. | |
| AFAPI array | dft (const array &in, const double norm_factor, const dim4 outDims) |
| C++ Interface for fast fourier transform on any(1d, 2d, 3d) dimensional signals. | |
| AFAPI array | dft (const array &in, const dim4 outDims) |
| C++ Interface for fast fourier transform on any(1d, 2d, 3d) dimensional signals. | |
| AFAPI array | dft (const array &in) |
| C++ Interface for fast fourier transform on any(1d, 2d, 3d) dimensional signals. | |
| AFAPI array | idft (const array &in, const double norm_factor, const dim4 outDims) |
| C++ Interface for inverse fast fourier transform on any(1d, 2d, 3d) dimensional signals. | |
| AFAPI array | idft (const array &in, const dim4 outDims) |
| C++ Interface for inverse fast fourier transform on any(1d, 2d, 3d) dimensional signals. | |
| AFAPI array | idft (const array &in) |
| C++ Interface for inverse fast fourier transform on any(1d, 2d, 3d) dimensional signals. | |
| AFAPI af_err | af_fft (af_array *out, const af_array in, const double norm_factor, const dim_t odim0) |
| C Interface for fast fourier transform on one dimensional signals. | |
| AFAPI af_err | af_fft_inplace (af_array in, const double norm_factor) |
| C Interface for fast fourier transform on one dimensional signals. | |
| AFAPI af_err | af_set_fft_plan_cache_size (size_t cache_size) |
| C Interface for setting plan cache size. | |
Fast Fourier Transform.
The Fast Fourier Transform (FFT) is an efficient algorithm to compute the discrete Fourier transform (DFT) of a signal or array. This is most commonly used to convert data in the time (or space) domain to the frequency domain, Then, the inverse FFT (iFFT) is used to return the data to the original domain.
There are numerous algorithms to compute the FFT of an array, and the specifics of the algorithm depend on the target hardware. Most algorithms, however, use a Cooley-Tukey scheme in a divide-and-conquer approach.
| AFAPI af_err af_fft | ( | af_array * | out, |
| const af_array | in, | ||
| const double | norm_factor, | ||
| const dim_t | odim0 | ||
| ) |
C Interface for fast fourier transform on one dimensional signals.
| [out] | out | is the transformed array |
| [in] | in | is the input array |
| [in] | norm_factor | is the normalization factor with which the input is scaled after the transformation is applied |
| [in] | odim0 | is the length of output signals - used to either truncate or pad the input signals |
C Interface for fast fourier transform on one dimensional signals.
| [in,out] | in | is the input array on entry and the output of 1D forward fourier transform at exit |
| [in] | norm_factor | is the normalization factor with which the input is scaled after the transformation is applied |
in
must be a complex array C Interface for setting plan cache size.
This function doesn't do anything if called when CPU backend is active. The plans associated with the most recently used array sizes are cached.
| [in] | cache_size | is the number of plans that shall be cached |
C++ Interface for fast fourier transform on any(1d, 2d, 3d) dimensional signals.
This version of fft function uses a default norm_factor parameter that is calculated internally based on the input signals.
| [in] | in | is the input array |
C++ Interface for fast fourier transform on any(1d, 2d, 3d) dimensional signals.
This version of fft function uses a default norm_factor parameter that is calculated internally based on the input signals.
| [in] | in | is the input array |
| [in] | outDims | is an object of dim4 that has the output array dimensions - used to either truncate or pad the input signals |
C++ Interface for fast fourier transform on any(1d, 2d, 3d) dimensional signals.
| [in] | in | is the input array |
| [in] | norm_factor | is the normalization factor with which the input is scaled after the transformation is applied |
| [in] | outDims | is an object of dim4 that has the output array dimensions - used to either truncate or pad the input signals |
C++ Interface for fast fourier transform on one dimensional signals.
This version of fft function uses a default norm_factor parameter that is calculated internally based on the input signals.
| [in] | in | is the input array |
| [in] | odim0 | is the length of output signals - used to either truncate or pad the input signals |
C++ Interface for fast fourier transform on one dimensional signals.
| [in,out] | in | is the input array on entry and the output of 1D forward fourier transform on exit |
| [in] | norm_factor | is the normalization factor with which the input is scaled after the transformation is applied |
in
must be complex C++ Interface for fast fourier transform on one dimensional signals.
| [in] | in | is the input array |
| [in] | norm_factor | is the normalization factor with which the input is scaled after the transformation is applied |
| [in] | odim0 | is the length of output signals - used to either truncate or pad the input signals |
C++ Interface for inverse fast fourier transform on any(1d, 2d, 3d) dimensional signals.
This version of fft function uses a default norm_factor parameter that is calculated internally based on the input signals.
| [in] | in | is the input array |
C++ Interface for inverse fast fourier transform on any(1d, 2d, 3d) dimensional signals.
This version of fft function uses a default norm_factor parameter that is calculated internally based on the input signals.
| [in] | in | is the input array |
| [in] | outDims | is an object of dim4 that has the output array dimensions - used to either truncate or pad the input signals |
C++ Interface for inverse fast fourier transform on any(1d, 2d, 3d) dimensional signals.
| [in] | in | is the input array |
| [in] | norm_factor | is the normalization factor with which the input is scaled after the transformation is applied |
| [in] | outDims | is an object of dim4 that has the output array dimensions - used to either truncate or pad the input signals |


t
Search By
By Movie Names
By Actor
By Production Company
By Director
{{data['name']}}
Directed by : {{data['dob']}}
Popularity : {{data['popularity']}}
{{data['bio']}}
Gender : {{data['gender']}}
Movies By {{data['name']}}
{% for j in range(1) %}
{% for i in range(4) %}
Explore
{{data['reco_movie'][i]}}
{% endfor %}
{% endfor %}


sessions this day
inquiry rate
failed requests
Throughput Status
Pages that people have visited frequently
{{item.name}}


pnmcolormap(1) pnmcolormap(1) NAME pnmcolormap - create quantization color map for a portable anymap SYNOPSIS pnmcolormap [-center|-meancolor|-meanpixel] [-spreadbrightness|-spreadlu‐ minosity] [-sort] [-square] ncolors|all [pnmfile] All options can be abbreviated to their shortest unique prefix. You may use two hyphens instead of one to designate an option. You may use either white space or an equals sign between an option name and its value. DESCRIPTION Reads a PNM image as input. Chooses ncolors colors to best represent the image, maps the existing colors to the new ones, and writes a PNM color map defining them as output. You can use this map as input to pnmremap on the same input image to quantize the colors in that image, I.e. produce a similar image with fewer colors. pnmquant does both the pnmcolormap and pnmremap steps for you. A PNM colormap is a PNM image of any dimensions that contains at least one pixel of each color in the set of colors it represents. The quantization method is Heckbert's "median cut". See the section QUANTIZATION METHOD. If the input image is a PPM, the output image is a PPM. If the input image is a PBM or PGM, the output colormap is a PGM. Note that a col‐ ormap of a PBM image is not very interesting. The colormap generally has the same maxval as the input image, but pnm‐ colormap may reduce it if there are too many colors in the input, as part of its quantization algorithm. If you want to create a colormap without basing it on the colors in an input image, see ppmcolors. PARAMETERS The single parameter, which is required, is the number of colors you want in the output colormap. pnmcolormap may produce a color map with slightly fewer colors than that. You may specify all to get a colormap of every color in the input image (no quantization). OPTIONS -sort This option causes the output colormap to be sorted by the red component intensity, then the green, then the blue in ascending order. This is an insertion sort, so it is not very fast on large colormaps. Sorting is useful because it allows you to compare two sets of colors. -square By default, pnmcolormap produces as the color map a PPM image with one row and one column for each color in the colormap. This option causes pnmcolormap instead to produce a PPM image that is within one row or column of being square, with multiple pixels of the same color as necessary to create a number of pixels which is a perfect square. -verbose This option causes pnmcolormap to display messages to Standard Error about the quantization. -center -meancolor -meanpixel -spreadbrightness -spreadluminosity These options control the quantization algorithm. See QUANTIZA‐ TION METHOD below. QUANTIZATION METHOD A quantization method is a way to choose which colors, being fewer in number than in the input, you want in the output. pnmcolormap uses Heck‐ bert's "median cut" quantization method. This method involves separating all the colors into "boxes," each holding colors that represent about the same number of pixels. You start with one box and split boxes in two until the number of boxes is the same as the number of colors you want in the output, and choose one color to rep‐ resent each box. When you split a box, you do it so that all the colors in one sub-box are "greater" than all the colors in the other. "Greater," for a particular box, means it is brighter in the color component (red, green, blue) which has the largest spread in that box. pnmcolormap gives you two ways to define "largest spread.": 1) largest spread of brightness; 2) largest spread of contribution to the luminosity of the color. E.g. red is weighted much more than blue. Select among these with the -spreadbright‐ ness and -spreadluminosity options. The default is -spreadbrightness. pnmcut provides three ways of choosing a color to represent a box: 1) the center color - the color halfway between the greatest and least colors in the box, using the above definition of "greater"; 2) the mean of the col‐ ors (each component averaged separately by brightness) in the box; 3) the mean weighted by the number of pixels of a color in the image. Note that in all three methods, there may be colors in the output which do not appear in the input at all. Select among these with the -center, -meancolor, and -meanpixel options. The default is -center. REFERENCES "Color Image Quantization for Frame Buffer Display" by Paul Heckbert, SIGGRAPH '82 Proceedings, page 297. SEE ALSO pnmremap(1), pnmquant(1), ppmquantall(1), pnmdepth(1), ppmdither(1), ppmquant(1), ppm(5) AUTHOR Copyright (C) 1989, 1991 by Jef Poskanzer. Copyright (C) 2001 by Bryan Henderson. 12 December 2001 pnmcolormap(1)


0" class="col-xs-12 section section-heading">
Test Name
Latest Observations
Last Conducted Date
No test reports available under this category for this patient.
{{ testReport.testname }}
{{ testReport.result }}
{{ testReport.conducteddate | date: 'dd/MM/yyyy' }}


We drove a $44,000 Nissan Leaf Plus to figure out if this 2019 Car of the Year runner-up is ready to take on Tesla, Business Insider - Business Insider Singapore
by Matthew DeBord, Business Insider US- The 2019 Nissan Leaf SL Plus is the fanciest version of the vehicle that first appeared in 2010.
- Although over 300,000 Leafs have been sold worldwide, the electric car has always been held back by its range.
- The Leaf Plus, however, serves up 214 miles on a single charge and has a more powerful motor.
- At $44,000, the Leaf SL Plus is a bit pricey, but you can opt for a cheaper trim level.
- Overall, the Leaf SL Plus is a dandy EV; it’s well worth a look if you’re shopping for a new car.
- Visit Business Insider’s homepage for more stories.
Editor’s note: Business Insider will name its 2019 Car of the Year on November 23. Each day this week, we’re taking another look at the five vehicles that were runners-up selected from a pool of 16 finalists. The second vehicle is the 2019 Nissan Leaf SL Plus.
The Nissan Leaf was basically the first modern, mass-market, all-electric vehicle, beating the Tesla Model S to market by a few years.
When it launched, the Leaf had limited range and was sort of unimpressively designed, but there was a lot of buzz around EVs then. The Leaf was the cornerstone of a Nissan “Zero Emission” strategy.
Market reality hasn’t quite lived up to expectations, but Nissan has continued to improve the Leaf. The second-generation arrived for the 2018 model year, with an updated design. For 2019, Nissan rolled out the Leaf Plus, a version of the EV that could achieve up to 226 miles on a single charge.
Generally, a baseline 200-mile number is magical; it eliminates much of the “range anxiety” that consumers suffer from because it adds a decent buffer and reduces the need to frequently recharge the Leaf.
I tested the Leaf Plus for a week in the New Jersey suburbs and even took a ride to Brooklyn. I concluded that the Leaf Plus was very good, and thus we have named it a 2019 Car of the Year runner-up.
Here’s now my test went:
Photos by Crystal Cox unless otherwise indicated.
Good day, 2019 Nissan Leaf SL Plus! Looking sharp in “Deep Pearl Blue.”
Pretty much the same Deep Pearl Blue as the Leaf that was a Business Insider Car of the Year finalist in 2018. That car had a single electric motor, producing 147 horsepower, a 40-kWh battery pack, and delivered 151 miles of range on a full charge.
The Leaf is the top-selling EV globally, which makes sense as the car has been around since 2010. Over 300,000 have been sold.
Our SL Plus trim level has a 62 kilowatt-hour battery. The larger pack adds roughly 70 miles of range compared to the standard Leaf’s 151-mile battery.
The 2019 Leaf, like the second-generation 2018 car, is much sleeker than the original. However, we’re talking about a practical hatchback here, so let’s not get too excited. Aerodynamics play a role in increasing EV range, so while the hatch design favors utility, the Leaf’s front end has been engineered for airflow: the car has a 0.28 drag coefficient
The goal when the Leaf was launched was for the Japanese automaker to embrace a “zero emission” future. It hasn’t quite worked out that way, but the company is making progress, and the Leaf is still with us.
Hatchback silhouettes aren’t typically associated with automotive aggression, and EVs tend to project a mostly virtuous vibe. But the Leaf’s fascia is rather bold. The LED headlights are a standout feature.
Overall, the Leaf projects a fairly European identity.
The Leaf’s cargo area is an excellent 24 cubic feet, expandable to 30 with the rear seats dropped. The hatch’s opening is a tad awkward, with a sort of oval shape.
Charging is unchanged from the Leaf we tested in 2018, at least as far as the ports go. There are two, one for 240V “Level 2” charging and one for fast DC charging. Our Leaf SL Plus had a 160 kWh electric motor, making a juicy 214 horsepower with 250 pound-feet of torque.
There’s also an onboard charge cable for “trickle” top-offs using a regular wall outlet for 120V power. Using 240V, the Leaf Plus is back to 100% in 11.5 hours. Fast DC charging, however, can achieve 80% in 45 minutes.
The Leaf has regenerative braking. And when the e-Pedal feature is engaged, it’s possible to drive the car using motor braking almost alone, putting power back into the battery.
We used the ChargePoint network and did fine with two rounds of 240V charging over the course of a week. It’s also possible to install your own 240V ChargePoint unit at home; one can be purchased for about $500, with installation handled by a qualified electrician.
We also used the Nissan Connect iPhone app to monitor charging and to manage climate control and vehicle diagnostics.
The Leaf’s “Light Gray” interior was pleasant.
It was a bit shy of premium, but the seats were comfy, and there was a reasonable amount of space to stow small items.
The back seat was about average, space-wise, for the segment.
The Leaf has always received criticism for its “tweener” nature. It’s not a luxury car, but it’s also not barebones. I’ve always thought it hits a sweet-spot for customers who aren’t wealthy but who have the means to invest in an EV.
The Leaf’s eight-inch color infotainment display looks good, but we aren’t the biggest fans of the system’s layout. It is easy to use, and Bluetooth device-pairing is a snap. You also have available Apple CarPlay and Android Auto.
So what’s the verdict on this 2019 Car of the Year runner-up?
If you can afford the payments – which come in at about $670 a month, on a 72-month loan – you’ll spend around $54 a month on electricity, according to Nissan and the US Department of Transportation and the EPA (the cost is based on 15,000 miles of annual driving). Gas could cost you more than twice as much, for a comparable petrol-burning machine.
The Leaf Plus is also still eligible for the $7,500 federal tax credit, as well as various state incentives.
AND you don’t have to buy the top-spec SL trim, like our tester – you could opt for the $36,550 plain-old Plus and still get a 62-kilowatt-hour battery pack.
OK, you won’t feel compelled to buy the Leaf Plus if your budget is more Nissan Versa Note, a $15,650 hatchback that runs on gas (but not much of it) and could be had for less than $250 a month. The 2020 Versa sedan starts even cheaper: less than $15,000.
Electric cars, of course, aren’t cheap (although you can pick up a used Leaf from the previous generation for around $10,000). But if you have the means and are serious about making the transition from fossil fuels to EEE-lec-tricity for propulsion, the Leaf Plus’s 226-miles range could flip your switch.
The 6.5-second 0-60 mph should also flip your switch. That’s darn quick, for a car that outwardly resembles something you’d find parked on the streets of Paris and used mainly for baguette runs. My beef with the Leaf, compared to other EVs (Tesla’s Model 3, the Chevy Bolt, and now a new generation of luxury vehicles, such as the Jaguar I-Pace) is that it felt solid yet sluggish. Against the Bolt, the shorter-range Leaf seemed to lack snap.
Not so anymore. The larger battery and more peppy motors have made the Leaf Plus feel downright sporty. My test car also included a suite of driver-assist and semi-self-driving features (Nissan’s ProPilot, for example, which can handle steering assist), so the Leaf has become a rather complete package that, for $44,000 as tested, was genuinely packed with content.
So, the Big Question: Why aren’t Leafs more popular? The answer is, to a degree, segmentation: Americans don’t want small hatchbacks. Price is also an issue, as is charging infrastructure. And Leafs aren’t exactly unpopular – Nissan has sold a very respectable number.
But the Plus-range trim does bring the mystery back into view. True, it can be a hassle to deal with “range anxiety” in sub-200-mile-range EVs. But the Leaf Plus provides a nice buffer, of around 50 miles. I figured that I’d charge a Leaf Plus, if I owned one, about once a week, maybe twice. With some planning, I could take it on a longer journey.
The Leaf Plus makes perfect sense for suburbanites who commute to big cities using public transportation, but who need a vehicle for around-town business and weekend duty. That’s millions and millions and millions of people – an enticing addressable market. Yes, a lot of those suburbanites want a large SUV or minivan to haul around families. But they could get by with a Leaf. And besides, in this demographic, two cars in the driveway isn’t uncommon.
This always happens when I test a capable, modern electric vehicle. I scratch my head. Oh well, it’s better now than it was a decade ago. But I still don’t get it.
In the meantime, if you need a new car, you owe it to yourself to check out the Leaf Plus. It’s still among the best choices for EV buyers, even with a slew of new vehicles hitting the market. That’s why it was a Car or the Year finalist in 2018 – and why it’s advanced to runner-up status for 2019!


Aviation
HOME
ABOUT
ALL POSTS
All Posts
Home
All Posts
All Posts
Wet runway? Obstacles in the Departure Path? You need Runway Analysis
International Operations - What You Need to Know
Weight & Balance - Using Standard Units
Hot? High? Heavy? - What You Need To Know About Takeoff Performance
Home


Sample 1
This UL is converted automatically when you resize the browser's window below 768px width (and back when you resize to desktop), using MQBE (Media Query Breakpoint Events)
Sample 2
Complex nested UL list with custom "on change" event that ouputs a console.log
Sample 3
With custom wrapper and custom "active" class
Sample 4
Simple SELECT without wrapper


Employer account
You can register for an account if you are an employer that wishes to:
- Save and review provider details
- Enquire about courses that a provider offers
If you are a levy paying employer you will be able to:
- Review the amount you have to spend in your levy account
- Spend your levy on new apprenticeships


If I had to put together a study plan for a beginner, I would probably start with an easy-going intro course such as
Next, I would recommend a good intro book on ‘Data Mining’ (data mining is essentially about extracting knowledge from data, mainly using machine learning algorithms). I can highly recommend the following book written by one of my former professors:
This book will provide you with a great overview of what’s currently out there; you will not only learn about different machine learning techniques, but also learn how to “understand” and “handle” and interpret data – remember; without “good,” informative data, a machine learning algorithm is practically worthless. Additionally, you will learn about alternative techniques since machine learning is not always the only and best solution to a problem
if all you have is a hammer, everything looks like a nail …
Now, After completing the Coursera course, you will have a basic understanding of ML and broadened your understanding via the Data Mining book. I don’t want to self-advertise here, but I think my book would be a good follow-up to learn ML in more depth, understand the algorithms, learn about different data processing pipelines and evaluation techniques, best practices, and learn how to put in into action using Python, NumPy, scikit-learn, and Theano so that you can start working on your personal projects.
While you work on your individual projects, I would maybe deepen your (statistical learning) knowledge via one of the three below:
When you are through all of that and still hungry to learn more, I recommend
The Deep Learning book by Yoshua Bengio, Ian Goodfellow, and Aaron Courville. The release date is set around 2016, but the 613-page manuscript is already available as as of today (online and for free).
And in-between, if you are looking for a less technical yet very inspirational free-time read, I highly recommend Pedro Domingo’s The Master Algorithm: How the Quest for the Ultimate Learning Machine Will Remake Our World


w3
Client Support IT
Web App
Link
Funnel
Japan Squads
2018 Released
Link
TSS Japan Home
TSOL Home
Directory Japan
ISAT
BMS 掲示板


new filterChart(filterMeasures) → {filterChart}
Constructs the page.
Parameters:
| Name | Type | Description |
|---|---|---|
filterMeasures |
filterMeasures | Not sure if this is still needed. |
- Source:
Returns:
A filterChart object that can be cuddled and fondled.
- Type
- filterChart


Your Name
Movie
Date
Start time
14:00
15:30
17:00
20:15
Amount
Email
Phone
Terms of Service
I accept the terms of service.
Submit


#include <Timer.h>
Public Member Functions | |
| double | GetTotalTime () const |
| Total time since timer was created or Reset was called. | |
| double | GetLastFrameTime () const |
| Time between last 2 calls to Update. | |
| void | Reset (void) |
| Reset the total time back to 0. | |
| void | Update (void) |
| Next Frame. Update the LastFrameTime. |
Uses high resolution performance counter to implement a timer. High precesion. All returned values are in seconds. You should only call Update once per frame. The LastFrameTime is always the amount of time between the last 2 calls to update.
Generally use GetTotalTime and Reset to keep track of the amount of time of a single event. Use Update only when creating a frame rate type counter.
| double Syntax::Utility::Timer::GetTotalTime | ( | ) | const [inline] |
Total time since timer was created or Reset was called.
This will be set back to 0 every time Reset is called.
| double Syntax::Utility::Timer::GetLastFrameTime | ( | ) | const [inline] |
Time between last 2 calls to Update.
Don't use Reset if using this call and Update. Reset will set this back to 0, and it won't change from that until after the next Update call.
| void Timer::Reset | ( | void | ) |
Reset the total time back to 0.
Reset the total time back to 0. Also resets the last frame time back to 0. Generally only used when total time is needed.
| void Syntax::Utility::Timer::Update | ( | void | ) |
Next Frame. Update the LastFrameTime.
Updates the last frame time, and the total time.


6 Linear Models
6.1 Introduction
The number of observations will be denoted by \(n\). When we refer to the size of a data set, we are referring to \(n\). We use \(p\) to refer the number of input variables used. The word “variables” is synonymous with “features”. For example, in the health_insurance
data, the variables are age
, sex
, bmi
, children
, smoker
and region
. These 7 variables mean that \(p = 7\). The data is collected from 1,338 patients, which means that \(n = 1,338\).
Scalar numbers are denoted by ordinary variables (i.e., \(x = 2\), \(z = 4\)), and vectors are denoted by bold-faced letters
\[\mathbf{a} = \begin{pmatrix} a_1 \\ a_2 \\ a_3 \end{pmatrix}\]
We use \(\mathbf{y}\) to denote the target variable. This is the variable which we are trying to predict. This can be either a whole number, in which case we are performing regression, or a category, in which case we are performing classification. In the health insurance example, y = charges
, which are the annual health care costs for a patient.
Both \(n\) and \(p\) are important because they tell us what types of models are likely to work well, and which methods are likely to fail. For the PA exam, we will be dealing with small \(n\) (<100,000) due to the limitations of the Prometric computers. We will use a small \(p\) (< 20) in order to make the data sets easier to interpret.
We organize these variables into matrices. Take an example with \(p\) = 2 columns and 3 observations. The matrix is said to be \(3 \times 2\) (read as “2-by-3”) matrix.
\[ \mathbf{X} = \begin{pmatrix}x_{11} & x_{21}\\ x_{21} & x_{22}\\ x_{31} & x_{32} \end{pmatrix} \]
The target is
\[\mathbf{y} = \begin{pmatrix} y_1 \\ y_2 \\ y_3 \end{pmatrix}\] This represents the unknown quantity that we want to be able to predict. In the health care costs example, \(y_1\) would be the costs of the first patient, \(y_2\) the costs of the second patient, and so forth. The variables \(x_{11}\) and \(x_{12}\) might represent the first patient’s age and sex respectively, where \(x_{i1}\) is the patient’s age, and \(x_{i2} = 1\) if the ith patient is male and 0 if female.
Machine learning is about using \(\mathbf{X}\) to predict \(\mathbf{y}\). We call this “y-hat”, or simply the prediction. This is based on a function of the data \(X\).
\[\mathbf{\hat{y}} = f(\mathbf{X}) = \begin{pmatrix} \hat{y_1} \\ \hat{y_2} \\ \hat{y_3} \end{pmatrix}\]
This is almost never going to happen perfectly, and so there is always an error term, \(\mathbf{\epsilon}\). This can be made smaller, but is never exactly zero.
\[ \mathbf{\hat{y}} + \mathbf{\epsilon} = f(\mathbf{X}) + \mathbf{\epsilon} \]
In other words, \(\epsilon = y - \hat{y}\). We call this the residual. When we predict a person’s health care costs, this is the difference between the predicted costs (which we had created the year before) and the actual costs that the patient experienced (of that current year).
6.2 Ordinary least squares (OLS)
The type of model used refers to the class of function of \(f\). If \(f\) is linear, then we are using a linear model. If \(f\) is non-parametric (does not have input parameters), then it is non-parametric modeling. Linear models are the simplest type of model.
We have the data \(\mathbf{X}\) and the target \(\mathbf{y}\), where all of the y’s are real numbers, or \(y_i \in \mathbb{R}\).
We want to find a \(\mathbf{\beta}\) so that
\[ \mathbf{\hat{y}} = \mathbf{X} \mathbf{\beta} \]
Which means that each \(y_i\) is a linear combination of the variables \(x_1, ..., x_p\), plus a constant \(\beta_0\) which is called the intercept term.
\[ \begin{equation} y_i = \beta_0 + \beta_1 x_1 + ... + \beta_p x_p \end{equation} \]
In the one-dimensional case, this creates a line connecting the points. In higher dimensions, this creates a hyperplane.
The question then is how can we choose the best values of \(\beta?\) First of all, we need to define what we mean by “best”. Ideally, we will choose these values which will create close predictions of \(\mathbf{y}\) on new, unseen data.
To solve for \(\mathbf{\beta}\), we first need to define a loss function. This allows us to compare how well a model is fitting the data. The most commonly used loss function is the residual sum of squares (RSS), also called the squared error loss or the L2 norm. When RSS is small, then the predictions are close to the actual values and the model is a good fit. When RSS is large, the model is a poor fit.
\[ \text{RSS} = \sum_i(y_i - \hat{y})^2 \]
When you replace \(\hat{y_i}\) in the above equation with \(\beta_0 + \beta_1 x_1 + ... + \beta_p x_p\), take the derivative with respect to \(\beta\), set equal to zero, and solve, we can find the optimal values. This turns the problem of statistics into a problem of numeric optimization, which computers can do quickly.
You might be asking: why does this need to be the squared error? Why not the absolute error, or the cubed error? Technically, these could be used as well. In fact, the absolute error (L1 norm) is useful in other models. Taking the square has a number of advantages.
- It provides the same solution if we assume that the distribution of \(\mathbf{Y}|\mathbf{X}\) is guassian and maximize the likelihood function. This method is used for GLMs, in the next chapter.
- Empirically it has been shown to be less likely to overfit as compared to other loss functions
6.2.1 Example
In our health, we can create a linear model using bmi
, age
, and sex
as an inputs.
The formula
controls which variables are included. There are a few shortcuts for using R formulas.
| Formula | Meaning |
|---|---|
charges ~ bmi + age |
Use age and bmi to predict charges |
charges ~ bmi + age + bmi *age |
Use age ,bmi as well as an interaction to predict charges |
charges ~ (bmi > 20 ) + age |
Use an indicator variable for bmi > 20 age to predict charges |
log(charges ) ~ log(bmi ) + log(age ) |
Use the logs of age and bmi to predict log(charges ) |
charges ~ . |
Use all variables to predict charges |
You can use formulas to create new variables (aka feature engineering). This can save you from needing to re-run code to create data.
Below we fit a simple linear model to predict charges.
library(ExamPAData)
library(tidyverse)
model <- lm(data = health_insurance, formula = charges ~ bmi + age)
The summary
function gives details about the model. First, the Estimate
, gives you the coefficients. The Std. Error
is the error of the estimate for the coefficient. Higher standard error means greater uncertainty. This is relative to the average value of that variable. The t value
tells you how “big” this error really is based on standard deviations. A larger t value
implies a low probability of the null hypothesis being rejected saying that the coefficient is zero. This is the same as having a p-value (Pr (>|t|))
) being close to zero.
The little *
, **
, ***
indicate that the variable is either somewhat significant, significant, or highly significant. “significance” here means that there is a low probability of the coefficient being that size if there were no actual casual relationship, or if the data was random noise.
##
## Call:
## lm(formula = charges ~ bmi + age, data = health_insurance)
##
## Residuals:
## Min 1Q Median 3Q Max
## -14457 -7045 -5136 7211 48022
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -6424.80 1744.09 -3.684 0.000239 ***
## bmi 332.97 51.37 6.481 1.28e-10 ***
## age 241.93 22.30 10.850 < 2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 11390 on 1335 degrees of freedom
## Multiple R-squared: 0.1172, Adjusted R-squared: 0.1159
## F-statistic: 88.6 on 2 and 1335 DF, p-value: < 2.2e-16
When evaluating model performance, you should not rely on the summary
alone as this is based on the training data. To look at performance, test the model on validation data. This can be done by a) using a hold out set, or b) using cross-validation, which is even better.
Let’s create an 80% training set and 20% testing set. You don’t need to worry about understanding this code as the exam will always give this to you.
library(caret)
#create a train/test split
index <- createDataPartition(y = health_insurance$charges, p = 0.8, list = F) %>% as.numeric()
train <- health_insurance %>% slice(index)
test <- health_insurance %>% slice(-index)
Train the model on the train
and test on test
.
Let’s look at the Root Mean Squared Error (RMSE).
## [1] 11401.39
The above number does not tell us if this is a good model or not by itself. We need a comparison. The fastest check is to compare against a prediction of the mean. In other words, all values of the y_hat
are the average of charges
## [1] 11919.09
The RMSE is higher (worse) when using just the mean, which is what we expect. If you ever fit a model and get an error which is worse than the average prediction, something must be wrong.
The next test is to see if any assumptions have been violated.
First, is there a pattern in the residuals? If there is, this means that the model is missing key information. For the model below, this is a yes, which means that this is a bad model. Because this is just for illustration, I’m going to continue using it, however.
The normal QQ shows how well the quantiles of the predictions fit to a theoretical normal distribution. If this is true, then the graph is a straight 45-degree line. In this model, you can definitely see that this is not the case. If this were a good model, this distribution would be closer to normal.
Caution: This test only applies to linear models which have a gaussian response distribution.
The below is from an excellent post of Stack Exchange.
R does not have a distinct plot.glm() method. When you fit a model with glm() and run plot(), it calls ?plot.lm, which is appropriate for linear models (i.e., with a normally distributed error term).
More specifically, the plots will often ‘look funny’ and lead people to believe that there is something wrong with the model when it is perfectly fine. We can see this by looking at those plots with a couple of simple simulations where we know the model is correct:
Once you have chosen your model, you should re-train over the entire data set. This is to make the coefficients more stable because n
is larger. Below you can see that the standard error is lower after training over the entire data set.
model_full_data <- lm(data = health_insurance, formula = charges ~ bmi + age)
model_test_data <- lm(data = train, formula = charges ~ bmi + age)
| term | full_data_std_error | test_data_std_error |
|---|---|---|
| (Intercept) | 1744.1 | 1916.1 |
| bmi | 51.4 | 57.3 |
| age | 22.3 | 24.8 |
All interpretations should be based on the model which was trained on the entire data set. Obviously, this only makes a difference if you are interpreting the precise values of the coefficients. If you are just looking at which variables are included, or at the size and sign of the coefficients, then this would not change.
## (Intercept) bmi age
## -6424.8046 332.9651 241.9308
Translating the above into an equation we have
\[\hat{y_i} = -6,424.80 + 332.97 \space\text{bmi} + 241.93\space \text{age}\]
For example, if a patient has bmi = 27.9
and age = 19
then predicted value is
\[\hat{y_1} = -6,424.80 + (332.97)(27.9) + (241.93)(19) = 7,461.73\]
This model structure implies that each of the variables \(\mathbf{x_1}, ..., \mathbf{x_p}\) each change the predicted \(\mathbf{\hat{y}}\). If \(x_{ij}\) increases by one unit, then \(y_i\) increases by \(\beta_j\) units, regardless of what happens to all of the other variables. This is one of the main assumptions of linear models: variable indepdendence. If the variables are correlated, say, then this assumption will be violated.
| Readings | |
|---|---|
| ISLR 2.1 What is statistical learning? | |
| ISLR 2.2 Assessing model accuracy |
6.3 Generalized linear models (GLMs)
Instead of the model being a direct linear combination of the variables, there is an intermediate step called a link function \(g\).
\[ g(\mathbf{\hat{y}}) = \mathbf{X} \mathbf{\beta} \]
This implies that the response \(\mathbf{y}\) is related to the linear predictor \(\mathbf{X} \mathbf{\beta}\) through the inverse link function.
\[ \mathbf{\hat{y}} = g^-1(\mathbf{X} \mathbf{\beta}) \]
This means that \(g(.)\) must be an invertable. For example, if \(g\) is the natural logarithm (aka, the “log-link”), then
\[ log(\mathbf{\hat{y}}) = \mathbf{X} \mathbf{\beta} \Rightarrow \mathbf{\hat{y}} = e^{\mathbf{X} \mathbf{\beta}} \]
This is useful when the distribution of \(Y\) is skewed, as taking the log corrects skewness.
You might be asking, what if the distribution of \(Y\) is not normal, no matter what choice we have for \(g\)? The short answer is that we can change our assumption of the distribution of \(Y\), and use this to change the parameters. If you have taken exam STAM then you are familiar with maximum likelihood estimation.
We have a response \(\mathbf{Y}\), and we fit a distribution to \(\mathbf{Y} | \mathbf{X}\). This is the target variable conditioned on the data. For each \(y_i\), each observation, we assign a probability \(f_Y(y_i)\)
\[ f_y(y_i | X_1 = x_1, X_2 = x_2, ..., X_p = x_p) = Pr(Y = y_i | \mathbf{X}) \]
Now, when we choose the response family, we are simply changing \(f_Y\). If we say that the response family is Gaussian, then \(f\) has a Gaussian PDF. If we are modeling counts, then \(f\) is a Poisson PDF. This only works if \(f\) is in the exponential family of distributions, which consists of the common names such as Gaussian, Binomial, Gamma, Inverse Gamma, and so forth. Reading the CAS Monograph 5 will provide more detail into this.
The possible combinations of link functions and distribution families are summarized nicely on Wikipedia.
For this exam, a common question is to ask candiates to choose the best distribution and link function. There is no all-encompasing answer, but a few suggestions are
- If \(Y\) is counting something, such as the number of claims, number of accidents, or some other discrete and positive counting sequence, use the Poisson;
- If \(Y\) contains negative values, then do not use the Exponential, Gamma, or Inverse Gaussian as these are strictly positive. Conversely, if \(Y\) is only positive, such as the price of a policy (price is always > 0), or the claim costs, then these are good choices;
- If \(Y\) is binary, the the binomial response with either a Probit or Logit link. The Logit is more common.
- If \(Y\) has more than two categories, the multinomial distribution with either the Probit or Logic link.
The exam will always ask you to interpret the GLM. These questions can usually be answered by inverting the link function and interpreting the coefficients. In the case of the log link, simply take the exponent of the coefficients and each of these represents a “relativity” factor.
\[ log(\mathbf{\hat{y}}) = \mathbf{X} \mathbf{\beta} \Rightarrow \mathbf{\hat{y}} = e^{\mathbf{X} \mathbf{\beta}} \]
For a single observation \(y_i\), this is
\[ \text{exp}(\beta_0 + \beta_1 x_{i1} + \beta_2 x_{i2} + ... + \beta_p x_{ip}) = \\ e^{\beta_0} e^{\beta_1 x_{i1}}e^{\beta_2 x_{i2}} ... e^{\beta_p x_{ip}} = R_o R_2 R_3 ... R_{p} \]
Where \(R_k\) is the relativity of the kth variable. This terminology is from insurance ratemaking, where actuaries need to be able to explain the impact of each variable in pricing insurance. The data science community does not use this language.
For binary outcomes with logit or probit link, there is no easy interpretation. This has come up in at least one past sample exam, and the solution was to create “psuedo” observations and observe how changing each \(x_k\) would change the predicted value. Due to the time requirements, this is unlikely to come up on an exam. So if you are asked to use a logit or probit link, saying that the result is not easy to interpret should suffice.
6.3.1 Example
Just as with OLS, there is a formula
and data argument
. In addition, we need to specify the response distribution and link function.
model = glm(formula = charges ~ age + sex + children,
family = gaussian(link = "log"),
data = health_insurance)
We see that age
, sex
, and children
are all significant (p <0.01). Reading off the coefficient signs, we see that claims
- Increase as age increases
- Are higher for men
- Are slightly higher for patients wich children
## # A tibble: 4 x 5
## term estimate std.error statistic p.value
## <chr> <dbl> <dbl> <dbl> <dbl>
## 1 (Intercept) 8.55 0.0953 89.7 0.
## 2 age 0.0201 0.00179 11.3 3.12e-28
## 3 sexmale 0.112 0.0459 2.44 1.49e- 2
## 4 children 0.0489 0.0182 2.69 7.29e- 3
6.3.2 Reference levels
When a categorical variable is used in a GLM, the model actually uses indicator variables for each level. The default reference level is the order of the R factors. For the sex
variable, the order is female
and then male
. This means that the base level is female
by default.
## [1] "female" "male"
Why does this matter? Statistically, the coefficients are most stable when there are more observations.
## female male
## 662 676
There is already a function to do this in the tidyverse
called fct_infreq
. Let’s quickly fix the sex
column so that these factor levels are in order of frequency.
Now male
is the base level.
## [1] "male" "female"
6.3.3 Interactions
An interaction occurs when the effect of a variable on the response is different depending on the level of other variables in the model.
Consider this model:
Let \(x_2\) be an indicator variable, which is 1 for some records and 0 otherwise.
\[\hat{y_i} = \beta_0 + \beta_1 x_1 + \beta_2 x_2 + \beta_3 x_1 x_2\]
There are now two different linear models dependong on whether x_1
is 0 or 1.
When \(x_1 = 0\),
\[\hat{y_i} = \beta_0 + \beta_2 x_2\]
and when \(x_1 = 1\)
\[\hat{y_i} = \beta_0 + \beta_1 + \beta_2 x_2 + \beta_3 x_2\] By rewriting this we can see that the intercept changes from \(\beta_0\) to \(\beta_0^*\) and the slope changes from \(\beta_1\) to \(\beta_1^*\)
\[ (\beta_0 + \beta_1) + (\beta_2 + \beta_3 ) x_2 \\ = \beta_0^* + \beta_1^* x_2 \]
The SOA’s modules give an example with the using age and gender as below. This is not a very strong interaction, as the slopes are almost identical across gender
.
interactions %>%
ggplot(aes(age, actual, color = gender)) +
geom_line() +
theme_bw() +
labs(title = "Age vs. Actual by Gender",
subtitle = "Interactions imply different slopes",
caption= "data: interactions")
Here is a clearer example from the auto_claim
data. The lines show the slope of a linear model, assuming that only BLUEBOOK
and CAR_TYPE
were predictors in the model. You can see that the slope for Sedans and Sports Cars is higher than for Vans and Panel Trucks.
auto_claim %>%
ggplot(aes(log(CLM_AMT), log(BLUEBOOK), color = CAR_TYPE)) +
geom_point(alpha = 0.3) +
geom_smooth(method = "lm", se = F) +
theme_bw() +
labs(title = "Kelly Bluebook Value vs Claim Amount")
## Warning: Removed 7556 rows containing non-finite values (stat_smooth).
Any time that the effect that one variable has on the response is different depending on the value of other variables we say that there is an interaction. We can also use an hypothesis test with a GLM to check this. Simply include an interaction term and see if the coefficient is zero at the desired significance level.
6.3.4 Logistic Regression
The name “logistic regression” is confusing because the objective is classification and not regression. While most examples focus on binary classification, logistic regression also works for multiclass classification.
The GLM model form is as before
\[g(\mathbf{\hat{y}}) = \mathbf{X} \mathbf{\beta}\]
However, now the target \(y_i\) is a category. Our objective is to predict a probability of being in each category. For Regression problems, \(\hat{y_i}\) can be any number, but now we need \(0 \leq \hat{y_i} \leq 1\).
We can use a special link function, known as the standard logistic function , sigmoid, or logit, to force the output to be in this range of \(\{0,1\}\).
\[\mathbf{\hat{y}} = g^{-1}(\mathbf{X} \mathbf{\beta}) = \frac{1}{1 + e^{-\mathbf{X} \mathbf{\beta}}}\]
tibble(x = -6:6,y = 1/(1 + exp(6:-6))) %>%
ggplot(aes(x,y)) +
geom_line(color = "red") +
theme_bw() +
xlab("x") +
ylab("g^-1(x)")
6.3.5 Example
Using the auto_claim
data, we predict the total claims using a frequency and severity approach. We build one model for frequency (whether or not a claim occures) and another for severity (the amount of a claim).
## # A tibble: 2 x 2
## CLM_FLAG n
## <chr> <int>
## 1 No 7556
## 2 Yes 2740
We see that about 40% do not have a claim while 60% have at least one claim.
index <- createDataPartition(y = auto_claim$CLM_FLAG, p = 0.8, list = F) %>% as.numeric()
auto_claim <- auto_claim %>% mutate(target = as.factor(ifelse(CLM_FLAG == "Yes", 1,0)))
train <- auto_claim %>% slice(index)
test <- auto_claim %>% slice(-index)
frequency <- glm(target ~ AGE + GENDER + MARRIED + CAR_USE + BLUEBOOK + CAR_TYPE + AREA
, data=train,
family = binomial(link="logit"))
We see that all of the variables except for the CAR_TYPE
are highly significant. The car types SPORTS CAR
and SUV
appear to be significant, and so if we wanted to make the model simpler we could create indicator variables for CAR_TYPE == SPORTS CAR
and CAR_TYPE == SUV
.
##
## Call:
## glm(formula = target ~ AGE + GENDER + MARRIED + CAR_USE + BLUEBOOK +
## CAR_TYPE + AREA, family = binomial(link = "logit"), data = train)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -1.8671 -0.8024 -0.5180 0.9347 3.0606
##
## Coefficients:
## Estimate Std. Error z value Pr(>|z|)
## (Intercept) -3.456e-01 2.536e-01 -1.363 0.17296
## AGE -2.370e-02 3.215e-03 -7.373 1.66e-13 ***
## GENDERM -2.964e-02 9.379e-02 -0.316 0.75202
## MARRIEDYes -6.287e-01 5.465e-02 -11.504 < 2e-16 ***
## CAR_USEPrivate -9.840e-01 6.586e-02 -14.941 < 2e-16 ***
## BLUEBOOK -4.214e-05 4.730e-06 -8.909 < 2e-16 ***
## CAR_TYPEPickup -3.750e-02 1.402e-01 -0.267 0.78910
## CAR_TYPESedan -4.605e-01 1.409e-01 -3.269 0.00108 **
## CAR_TYPESports Car 6.140e-01 1.904e-01 3.224 0.00126 **
## CAR_TYPESUV 2.744e-01 1.786e-01 1.537 0.12435
## CAR_TYPEVan 4.678e-02 1.337e-01 0.350 0.72643
## AREAUrban 2.211e+00 1.085e-01 20.380 < 2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for binomial family taken to be 1)
##
## Null deviance: 9544.3 on 8236 degrees of freedom
## Residual deviance: 8237.8 on 8225 degrees of freedom
## AIC: 8261.8
##
## Number of Fisher Scoring iterations: 5
There is no easy way of interpreting the coefficients when using a logit link function. The most inference that we can make is to note which variables are significant.
The output is a predicted probability. We can see that this is centered around a probability of about 0.5.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
In order to convert these values to predicted 0’s and 1’s, we assign a cutoff value so that if \(\hat{y}\) is above this threshold we use a 1 and 0 othersise. The default cutoff is 0.5. We change this to 0.8 and see that there are 372 policies where at least one claim is predicted.
## 0 1
## 2057 2
How do we decide on this cutoff value? We need to compare cutoff values based on some evaluation metric. For example, we can use accuracy.
\[\text{Accuracy} = \frac{\text{Correct Guesses}}{\text{Total Guesses}}\] This results in an accuracy of 53%. But is this good?
## # A tibble: 1 x 1
## accuracy
## <dbl>
## 1 0.735
Consider what would happen if we just predicted all 0’s. The accuracy is 39%.
## # A tibble: 1 x 1
## accuracy
## <dbl>
## 1 0.734
For policies which experience claims the accuracy is 26%.
## # A tibble: 1 x 1
## accuracy
## <dbl>
## 1 0.00365
But for policies that don’t actually experience claims this is 95%.
## # A tibble: 1 x 1
## accuracy
## <dbl>
## 1 1
How do we know if this is a good model? We can repeat this process with a different cutoff value and get different accuracy metrics for these groups. Let’s use a cutoff of 0.4.
61%
test <- test %>% mutate(pred_zero_one = as.factor(1*(preds>.4)))
test %>% summarise(accuracy = mean(pred_zero_one == target))
## # A tibble: 1 x 1
## accuracy
## <dbl>
## 1 0.734
95% for policies with claims and 10% for policies without claims.
## # A tibble: 1 x 1
## accuracy
## <dbl>
## 1 0.409
## # A tibble: 1 x 1
## accuracy
## <dbl>
## 1 0.852
The punchline is that the accuracy depends on the cutoff value, and changing the cutoff value changes whether the model is accuracy for the positive classes (policies with actual claims) vs. the negative classes (policies without claims).
A confusion matrix shows is a table that summarises how the model classifies each group.
- 767 policies which had no claims were predicted to not have claims - True Negatives (TN) = 767
- 330 policies which had claims were accurately predicted to have claims - True Positives (TP) = 330
- 42 policies which had no claims were predited to have claims - False Negatives (FN) = 42
- 920 policies which had claims but were predicted not to - False Positives (FP) = 920
## Reference
## Prediction 0 1
## 0 1288 324
## 1 223 224
The easy way to remember this language is to ask two questions, A and B:
A. Was the prediction correct? Yes -> TRUE B. Was the class a 1? Yes -> Positive
Then just put A and B together.
These definitions allow us to measure performance on the different groups.
Precision answers the question “out of all of the positive predictions, what percentage were correct?”
\[\text{Precision} = \frac{\text{TP}}{\text{TP} + \text{FP}}\]
Recall answers the question “out of all of positive examples in the data set, what percentage were correct?”
\[\text{Recall} = \frac{\text{TP}}{\text{TP} + \text{FN}}\]
The choice of using precision or recall depends on the relative cost of making a FP or a FN error. If FP errors are expensive, then use precision; if FN errors are expensive, then use recall.
Example A: the model trying to detect a deadly disease, which only 1 out of every 1000 patient’s survive without early detection. Then the goal should be to optimize recall, because we would want every patient that has the disease to get detected.
Example B: the model is detecting which emails are spam or not. If an important email is flagged as spam incorrectly, the cost is 5 hours of lost productivity. In this case, precision is the main concern.
In some cases we can compare this “cost” in actual values. For example, if a federal court is predicting if a criminal will recommit or not, they can agree that “1 out of every 20 guilty individuals going free” in exchange for “90% of those who are guilty being convicted”. When money is involed, this a dollar amount can be used: flagging non-spam as spam may cost $ 100 whereas missing a spam email may cost $ 2. Then the cost-weighted accuracy is
\[\text{Cost} = (100)(\text{FN}) + (2)(\text{FP})\]
Then the cutoff value can be tuned in order to find the minimum cost.
Fortunately, all of this is handled in a single function called confusionMatrix
.
## Confusion Matrix and Statistics
##
## Reference
## Prediction 0 1
## 0 1288 324
## 1 223 224
##
## Accuracy : 0.7343
## 95% CI : (0.7147, 0.7533)
## No Information Rate : 0.7339
## P-Value [Acc > NIR] : 0.4916
##
## Kappa : 0.2775
##
## Mcnemar's Test P-Value : 1.905e-05
##
## Sensitivity : 0.8524
## Specificity : 0.4088
## Pos Pred Value : 0.7990
## Neg Pred Value : 0.5011
## Prevalence : 0.7339
## Detection Rate : 0.6255
## Detection Prevalence : 0.7829
## Balanced Accuracy : 0.6306
##
## 'Positive' Class : 0
##
6.3.6 Area under the ROC Curv (AUC)
What if we look at both the true-positive rate (TPR) and false positive rate (FPR) simultaneously? That is, for each value of the cutoff, we can calculate the TPR and TNR.
For example, say that we have 10 cutoff values, \(\{k_1, k_2, ..., k_{10}\}\). Then for each value of \(k\) we calculate both the true positive rates
\[\text{TPR} = \{\text{TPR}(k_1), \text{TPR}(k_2), .., \text{TPR}(k_{10})\} \]
and the true negative rates
\[\{\text{FNR} = \{\text{FNR}(k_1), \text{FNR}(k_2), .., \text{FNR}(k_{10})\}\]
Then we set x = TPR
and y = FNR
and graph x against y. The plot below shows the ROC for the auto_claims
data. The Area Under the Curv of 0.6795 is what we would get if we integrated under the curve.
##
## Call:
## roc.default(response = test$target, predictor = preds, plot = T)
##
## Data: preds in 1511 controls (test$target 0) < 548 cases (test$target 1).
## Area under the curve: 0.7303
If we just randomly guess, the AUC would be 0.5, which is represented by the 45-degree line. A perfect model would maximize the curve to the upper-left corner.
6.3.7 Poisson Regression
When the dependent variable is a count, such as the number of claims per month, Poisson regression is appropriate. This requires that each claim is independent in that one claim will not make another claim more or less likely. This means that the target variable is actually a rate, \(\frac{\text{claims}}{\text{months}}\). More generally, we call the months the exposure.
Let \(m_i\) by the units of exposure and \(y_i\) the target. We use a log-link function to correct for skewness.
\[ log(\frac{\hat{y_i}}{m_i}) = \beta_0 + \beta_1 x_1 + ... + \beta_p x_p\]
By using the fact that \(log(\frac{a}{b}) = log(a) - log(b)\) this turns into
\[log(\hat{y_i}) = log(m_i) + \beta_0 + \beta_1 x_1 + ... + \beta_p x_p\]
We call the \(log(m_i)\) the offset
term. Notice that there is no coefficient (beta) on this value, because we already know what the impact will be.
In R, the code for this equation would be
6.3.8 Tweedie regression
While this topic is briefly mentioned on the modules, the only R libraries which support Tweedie Regression (statmod
and tweedie
) are not on the syllabus.
6.3.9 Stepwise subset selection
In theory, we could test any possible combination of variables and interaction terms. This includes all \(p\) models with one predictor, all p-choose-2 models with two predictors, all p-choose-3 models with three predictors, and so forth. Then we take whichever model has the best performance as the final model.
This “brute force” approach is statistically ineffective: the more variables which are searched, the higher the chance of finding models that overfit.
A subtler method, known as stepwise selection, reduces the chances of overfitting by only looking at the most promising models.
Forward Stepwise Selection:
- Start with no predictors in the model;
- Evaluate all \(p\) models which use only one predictor and choose the one with the best performance (highest \(R^2\) or lowest \(\text{RSS}\));
- Repeat the process when adding one additional predictor, and continue until there is a model with one predictor, a model with two predictors, a model with three predictors, and so forth until there are \(p\) models;
- Select the single best model which has the best \(\text{AIC}\),\(\text{BIC}\), or adjusted \(R^2\).
Backward Stepwise Selection:
- Start with a model that contains all predictors;
- Create a model which removes all predictors;
- Choose the best model which removes all-but-one predictor;
- Choose the best model which removes all-but-two predictors;
- Continue until there are \(p\) models;
- Select the single best model which has the best \(\text{AIC}\),\(\text{BIC}\), or adjusted \(R^2\).
Both Forward & Backward Selection:
ISLR does not mention this directly, however, a GLM using this method appeared on the 2019 June exam. The following is from a stackoverflow post.
https://stats.stackexchange.com/questions/97250/stepwise-regression-in-r-with-both-direction
MASS::step()
with the option direction = 'both'
works by comparing the AIC improvements from
dropping each candidate variable, and adding each candidate variable between the upper and lower bound regressor sets supplied,
from the current model, and by dropping or adding the one variable that leads to the best AIC improvement (smallest AIC).
For example, assume that you are fitting a linear regression model with the upper set of variables \(U = \{X_1, X_2, X_3, X_4, X_5, X_6, X_7\}\), and lower set \(L = \{X_1\}\), and the starting object \(S_0 = \{X_1, X_3\}\), then the potential sets of retained regressors might be something like
\[ \begin{align} S_1 &= \{X_1, X_3, X_6\} &\text{ (add $X_6$) }\\ S_2 &= \{X_1, X_3, X_6, X_4\} &\text{ (add $X_4$) }\\ S_3 &= \{X_3, X_6, X_4\} &\text{ (drop $X_1$) }\\ S_4 &= \{X_3, X_6, X_4, X_7\} &\text{ (add $X_7$) }\\ S_5 &= \{X_3, X_4, X_7\} &\text{ (drop $X_6$) } \end{align} \]
and so on, till no AIC improvements can be made.
Tip: Always load the
MASS
library beforedplyr
ortidyverse
. Otherwise there will be conflicts as there are functions namedselect()
andfilter()
in both. Alternatively, specify the library in the function call withdplyr::select()
.
| Readings | |
|---|---|
| CAS Monograph 5 Chapter 2 | |
| ISLR 2.2 Assessing model accuracy |
6.3.10 Advantages and disadvantages
There is usually at least one question on the PA exam which asks you to “list some of the advantages and disadvantages of using this particular model”, and so here is one such list.
GLM Advantages
- Easy to interpret
- Handles skewed data through different response distributions
- Models the average response which leads to stable predictions on new data
- Handles continuous and categorical data
- Works well on small data sets
GLM Disadvantages
- Does not select features
- Strict assumptions around distribution shape, randomness of error terms, and others
- Unable to detect non-linearity directly (although this can manually be addressed through feature engineering)
- Sensitive to outliers
- Low predictive power
6.4 Penalized Linear Models
One of the main weaknesses of the GLM is that the features need to be selected by hand. For large \(p\), this means that the modeler needs to test every combination of variables. This is time consuming.
Earlier on we said that the linear model minimizes the sum of square terms, known as the residual sum of squares (RSS)
\[ \text{RSS} = \sum_i(y_i - \hat{y})^2 = \sum_i(y_i - \beta_0 - \sum_{j = 1}^p\beta_j x_{ij})^2 \]
This loss function can be modified so that models which include more (and larger) coefficients are considered as worse. In other words, when there are more \(\beta\)’s, or \(\beta\)’s which are larger, the RSS is higher.
6.4.1 Ridge Regression
Ridge regression adds a penalty term which is proportional to the square of the sum of the coefficients. This is known as the “L2” norm.
\[ \sum_i(y_i - \beta_0 - \sum_{j = 1}^p\beta_j x_{ij})^2 + \lambda \sum_{j = 1}^p\beta_j^2 \]
This \(\lambda\) controls how much of a penalty is imposed on the size of the coefficients. When \(\lambda\) is high, simpler models are treated more favorably because the \(\sum_{j = 1}^p\beta_j^2\) carries more weight. Conversely, then \(\lambda\) is low, complex models are more favored. When \(\lambda = 0\), we have an ordinary GLM.
6.4.2 Lasso
The official name is the Least Absolute Shrinkage and Selection Operator, but the common name is just “the lasso”. Just as with Ridge regression, we want to favor simpler models; however, we also want to select variables. This is the same as forcing some coefficients to be equal to 0.
Instead of taking the square of the coefficients (L2 norm), we take the absolute value (L1 norm).
\[ \sum_i(y_i - \beta_0 - \sum_{j = 1}^p\beta_j x_{ij})^2 + \lambda \sum_{j = 1}^p|\beta_j| \]
In ISLR, Hastie et al show that this results in coefficients being forced to be exactly 0. This is extremely useful because it means that by changing \(\lambda\), we can select how many variables to use in the model.
Note: While any response family is possible with penalized regression, in R, only the Gaussian family is possible in the library glmnet
, and so this is the only type of question that the SOA can ask.
6.4.3 Elastic Net
The Elastic Net uses a penalty term which is between the L1 and L2 norms. The penalty term is a weighted average using the mixing parameter $ 0 1$. The loss fucntion is then
\[\text{RSS} + (1 - \alpha)/2 \sum_{j = 1}^{p}\beta_j^2 + \alpha \sum_{j = 1}^p |\beta_j|\] When \(\alph = 1\) is turns into a Lasso; when \(\alpha = 1\) this is the Ridge model.
Luckily, none of this needs to be memorized. On the exam, read the documentation in R to refresh your memory. For the Elastic Net, the function is glmnet
, and so running ?glmnet
will give you this info.
Tip: When using complicated functions on the exam, use
?function_name
to get the documentation.
6.4.4 Advantages and disadvantages
Elastic Net/Lasso/Ridge Advantages
- All benefits from GLMS
- Automatic variable selection for Lasso; smaller coefficients for Ridge
- Better predictive power than GLM
Elastic Net/Lasso/Ridge Disadvantages
- All cons of GLMs
| Readings | |
|---|---|
| ISLR 6.1 Subset Selection | |
| ISLR 6.2 Shrinkage Methods |


%inherit file="base.htm" /> <%block name="content">
Congratulations! Now that you have the basic concept down, we are going to take it up a notch.


This is perhaps the most important part of the entire process. The method and tools discussed in this screencast demonstrate a quick and easy way for you to test your design ideas before you begin the visual design process and potentially waste your time on an idea that was never going to work once turned into live code.
Sorry for the brevity, but you will need these files to follow along with this screencast.
Part 01 of 06
Part 02 of 06
Part 03 of 06
Part 04 of 06
Part 05 of 06
Part 06 of 06
Grading
Learning Objectives Applied
Applying
Make use of an interactive design process.
Construct interactive designs with prototyping software.
Analyzing
Assess interactive prototypes for responsive web design principles.
Assessment Rubric
If you received 34–50 points you successfully used the template to test multiple layouts for the final website design and determined what elements that will need to have multiple breakpoints. You also uploaded the template to your class hosting account and added it to the assignment index.html page.
If you received 1–33 points you used the template to test one layout for the final website design and determined one or two elements that will need to have multiple breakpoints. You did not uploaded the template to your class hosting account or add it to the assignment index.html page.
If you received 0 points you did not complete the assignment.


Overview
Package
Class
Tree
Deprecated
Index
Help
PREV NEXT
FRAMES
NO FRAMES
All Classes
A
B
C
D
E
F
G
H
I
L
M
N
O
P
R
S
T
U
V
W
_
A
ALT
- Static variable in interface beroux.game.
GameCanvas.KeyModifierFlags
AbstractButton
- class beroux.mountnfall.
AbstractButton
.
AbstractButton(int, int)
- Constructor for class beroux.mountnfall.
AbstractButton
Create the button.
AiPlayer
- class beroux.mountnfall.
AiPlayer
.
Recall AlphaBeta Acceleration.
AiPlayer(int)
- Constructor for class beroux.mountnfall.
AiPlayer
AiPlayer.Level
- interface beroux.mountnfall.
AiPlayer.Level
.
addActionListener(ActionListener)
- Method in class beroux.mountnfall.
AbstractButton
assign(GameLogic)
- Method in class beroux.mountnfall.
BoardRenderer
B
BLACK
- Static variable in interface beroux.mountnfall.
Board.Counter.Colour
Board
- class beroux.mountnfall.
Board
.
Classical 8x8 game board.
Board()
- Constructor for class beroux.mountnfall.
Board
Board.Counter
- class beroux.mountnfall.
Board.Counter
.
Counter(s) inside of a board square.
Board.Counter(int, int)
- Constructor for class beroux.mountnfall.
Board.Counter
Board.Counter.Colour
- interface beroux.mountnfall.
Board.Counter.Colour
.
Board.Square
- class beroux.mountnfall.
Board.Square
.
Locate a square on the board.
Board.Square(int, int)
- Constructor for class beroux.mountnfall.
Board.Square
Board.SquaresIterator
- class beroux.mountnfall.
Board.SquaresIterator
.
Iterator through all the board squares.
Board.SquaresIterator()
- Constructor for class beroux.mountnfall.
Board.SquaresIterator
BoardRenderer
- class beroux.mountnfall.
BoardRenderer
.
BoardRenderer(GameLogic)
- Constructor for class beroux.mountnfall.
BoardRenderer
BumpingButton
- class beroux.mountnfall.
BumpingButton
.
BumpingButton(Sprite, Sprite)
- Constructor for class beroux.mountnfall.
BumpingButton
Create the button.
beroux.game
- package beroux.game
beroux.mountnfall
- package beroux.mountnfall
blackCounter
- Static variable in class beroux.mountnfall.
Board
blackPlayerName
- Variable in class beroux.mountnfall.
NewGame
C
CREDITS
- Static variable in interface beroux.mountnfall.
ScenesController.EState
CTRL
- Static variable in interface beroux.game.
GameCanvas.KeyModifierFlags
Character
- class beroux.mountnfall.
Character
.
Simple animated character in game.
Character(String)
- Constructor for class beroux.mountnfall.
Character
Create the character.
Credits
- class beroux.mountnfall.
Credits
.
Credits()
- Constructor for class beroux.mountnfall.
Credits
Cursor
- class beroux.game.
Cursor
.
Mouse cursor.
Cursor(int)
- Constructor for class beroux.game.
Cursor
Cursor(String, int, int)
- Constructor for class beroux.game.
Cursor
clear()
- Method in class beroux.mountnfall.
Board
clearHighlight()
- Method in class beroux.mountnfall.
BoardRenderer
Don't highlight any square.
clone()
- Method in class beroux.game.
FontString
clone()
- Method in class beroux.game.
Sprite
clone()
- Method in class beroux.mountnfall.
Board
clone()
- Method in class beroux.mountnfall.
GameLogic
Clone the game state.
column()
- Method in class beroux.mountnfall.
Board.Square
columns()
- Static method in class beroux.mountnfall.
Board
counter
- Variable in class beroux.mountnfall.
PileUpMove
create(Player, Player, Sprite)
- Method in class beroux.mountnfall.
InGame
create(Sprite)
- Method in class beroux.mountnfall.
Pattern
Change the pattern of the "white" squares.
D
DEFAULT
- Static variable in class beroux.game.
Cursor
DepileMove
- class beroux.mountnfall.
DepileMove
.
Depile a tower
DepileMove(Board.Square, int, int)
- Constructor for class beroux.mountnfall.
DepileMove
DepileMove(Board.Square, Board.Square)
- Constructor for class beroux.mountnfall.
DepileMove
DepileMove(int, int, int, int)
- Constructor for class beroux.mountnfall.
DepileMove
defineReferencePixel(int, int)
- Method in class beroux.game.
Sprite
Defines the reference pixel for this Sprite.
destination
- Variable in class beroux.mountnfall.
PileUpMove
doMove(Move)
- Method in class beroux.mountnfall.
GameLogic
Execute a move.
drawString(GameFont, String, float, float)
- Method in class beroux.game.
Screen
Draw a text string.
dx
- Variable in class beroux.mountnfall.
DepileMove
dy
- Variable in class beroux.mountnfall.
DepileMove
E
EASY
- Static variable in interface beroux.mountnfall.
AiPlayer.Level
EMPTY
- Static variable in interface beroux.mountnfall.
Board.Counter.Colour
END_ROUND
- Static variable in interface beroux.mountnfall.
ScenesController.EState
EndRound
- class beroux.mountnfall.
EndRound
.
EndRound()
- Constructor for class beroux.mountnfall.
EndRound
EnumButton
- class beroux.mountnfall.
EnumButton
.
EnumButton(int, int, TreeMap)
- Constructor for class beroux.mountnfall.
EnumButton
Create the button.
EnumButton(int, int, Map, Object)
- Constructor for class beroux.mountnfall.
EnumButton
Create the button.
emptyCounter
- Static variable in class beroux.mountnfall.
Board
equals(Object)
- Method in class beroux.mountnfall.
Board.Counter
equals(Object)
- Method in class beroux.mountnfall.
Board.Square
equals(Object)
- Method in class beroux.mountnfall.
Board
equals(Object)
- Method in class beroux.mountnfall.
DepileMove
equals(Object)
- Method in class beroux.mountnfall.
GameLogic
equals(Object)
- Method in class beroux.mountnfall.
PileUpMove
execute(GameCommand)
- Method in class beroux.mountnfall.
GameLogic
Execute a command.
F
FontString
- class beroux.game.
FontString
.
FontString(String)
- Constructor for class beroux.game.
FontString
fireActionPerformed(ActionEvent)
- Method in class beroux.mountnfall.
AbstractButton
Notifies all listeners that have registered interest for notification on this event type.
fireActionPerformed(ActionEvent)
- Method in class beroux.mountnfall.
EnumButton
G
GUI
- class beroux.mountnfall.
GUI
.
Game Graphical User Interface The white player is on the left, and the black player on the right.
GUI(GameLogic)
- Constructor for class beroux.mountnfall.
GUI
GameCanvas
- class beroux.game.
GameCanvas
.
GameCanvas()
- Constructor for class beroux.game.
GameCanvas
GameCanvas.KeyModifierFlags
- interface beroux.game.
GameCanvas.KeyModifierFlags
.
GameCanvas.MouseButton
- interface beroux.game.
GameCanvas.MouseButton
.
GameCommand
- class beroux.mountnfall.
GameCommand
.
GameCommand()
- Constructor for class beroux.mountnfall.
GameCommand
GameFont
- class beroux.game.
GameFont
.
Display text in game.
GameFont(Font, Color)
- Constructor for class beroux.game.
GameFont
GameLogic
- class beroux.mountnfall.
GameLogic
.
Manage the game rules.
GameLogic()
- Constructor for class beroux.mountnfall.
GameLogic
GameOver
- class beroux.mountnfall.
GameOver
.
Game over.
GameOver(int)
- Constructor for class beroux.mountnfall.
GameOver
getActionCommand()
- Method in class beroux.mountnfall.
AbstractButton
Returns the action command for this button.
getActiveKey()
- Method in class beroux.mountnfall.
EnumButton
getAiLevel()
- Method in class beroux.mountnfall.
SingleMode
getAllPossibleMoves()
- Method in class beroux.mountnfall.
GameLogic
Find possible moves of the current player.
getAwtCursor()
- Method in class beroux.game.
Cursor
getBaseX()
- Method in class beroux.mountnfall.
Tower
getBaseY()
- Method in class beroux.mountnfall.
Tower
getBlackPlayerName()
- Method in class beroux.mountnfall.
EndRound
getBlackPlayerName()
- Method in class beroux.mountnfall.
VersusMode
getBoard()
- Method in class beroux.mountnfall.
GameLogic
getBoard()
- Method in class beroux.mountnfall.
InGame
getBoardView()
- Method in class beroux.mountnfall.
GUI
Return the board renderer.
getBoundingBox()
- Method in class beroux.game.
Layer
getCanvas()
- Method in class beroux.game.
Screen
getClickedSquare(int, int)
- Method in class beroux.mountnfall.
BoardRenderer
Return the square under cursor position.
getColour()
- Method in class beroux.game.
GameFont
getColour()
- Method in class beroux.mountnfall.
Board.Counter
getCount()
- Method in class beroux.mountnfall.
Board.Counter
getCounter(Board.Square)
- Method in class beroux.mountnfall.
Board
Return counter at the specified square.
getCurrentPlayerColour()
- Method in class beroux.mountnfall.
GameLogic
Return the.getColour() of the active player.
getFont()
- Method in class beroux.game.
GameFont
getGraphics()
- Method in class beroux.game.
Screen
getHeight()
- Method in class beroux.game.
Layer
getHeight()
- Method in class beroux.mountnfall.
Tower
getImage()
- Method in class beroux.game.
Sprite
Return a java Image for the screen.
getInstance()
- Static method in class beroux.game.
Screen
getName()
- Method in class beroux.mountnfall.
Player
getNumberOfRounds()
- Method in class beroux.mountnfall.
SingleMode
getNumberOfRounds()
- Method in class beroux.mountnfall.
VersusMode
getOutlineColour()
- Method in class beroux.game.
GameFont
getOutlineSize()
- Method in class beroux.game.
GameFont
getPlayed()
- Method in class beroux.mountnfall.
AiPlayer
getPlayed()
- Method in class beroux.mountnfall.
HumanPlayer
getPlayed()
- Method in class beroux.mountnfall.
Player
getPlayerColour()
- Method in class beroux.mountnfall.
SingleMode
getPlayerMove()
- Method in class beroux.mountnfall.
InGame
Return the player move.
getRatio()
- Method in class beroux.game.
Screen
getRefPixelX()
- Method in class beroux.game.
Sprite
Gets the horizontal position of this Sprite's reference pixel in the painter's coordinate system.
getRefPixelY()
- Method in class beroux.game.
Sprite
Gets the vertical position of this Sprite's reference pixel in the painter's coordinate system.
getRoundsLeft()
- Method in class beroux.mountnfall.
EndRound
getString()
- Method in class beroux.game.
FontString
getWhitePlayerName()
- Method in class beroux.mountnfall.
EndRound
getWhitePlayerName()
- Method in class beroux.mountnfall.
VersusMode
getWidth()
- Method in class beroux.game.
Layer
getWinner()
- Method in class beroux.mountnfall.
GameLogic
getWinner()
- Method in class beroux.mountnfall.
InGame
Return the winning player's colour.
getX()
- Method in class beroux.game.
Layer
getY()
- Method in class beroux.game.
Layer
gotoState(String)
- Method in class beroux.mountnfall.
Character
Change character's state.
H
HAND
- Static variable in class beroux.game.
Cursor
HARD
- Static variable in interface beroux.mountnfall.
AiPlayer.Level
HumanPlayer
- class beroux.mountnfall.
HumanPlayer
.
HumanPlayer(String)
- Constructor for class beroux.mountnfall.
HumanPlayer
hasNext()
- Method in class beroux.mountnfall.
Board.SquaresIterator
height()
- Static method in class beroux.game.
Screen
Virtual screen height.
I
IGameObject
- interface beroux.mountnfall.
IGameObject
.
IN_GAME
- Static variable in interface beroux.mountnfall.
ScenesController.EState
InGame
- class beroux.mountnfall.
InGame
.
InGame()
- Constructor for class beroux.mountnfall.
InGame
InGameBackground
- class beroux.mountnfall.
InGameBackground
.
An accelerated version of Background.
InGameBackground(Sprite)
- Constructor for class beroux.mountnfall.
InGameBackground
initialize(JFrame)
- Method in class beroux.game.
GameCanvas
Initialize the game.
initialize(String, String, int)
- Method in class beroux.mountnfall.
EndRound
initialize(JFrame)
- Method in class beroux.mountnfall.
ScenesController
Initialize the game.
inputPlayerMove()
- Method in class beroux.mountnfall.
InGame
Wait for player to input a move.
isGameOver()
- Method in class beroux.mountnfall.
GameLogic
isInitilialized()
- Method in class beroux.mountnfall.
Credits
Check if scene is ready to be entered.
isInitilialized()
- Method in class beroux.mountnfall.
EndRound
Check if scene is ready to be entered.
isInitilialized()
- Method in class beroux.mountnfall.
InGame
Check if scene is ready to be entered.
isInitilialized()
- Method in class beroux.mountnfall.
MainMenu
Check if scene is ready to be entered.
isInitilialized()
- Method in class beroux.mountnfall.
SceneView
Check if scene is ready to be entered.
isInitilialized()
- Method in class beroux.mountnfall.
SingleMode
Check if scene is ready to be entered.
isInitilialized()
- Method in class beroux.mountnfall.
VersusMode
Check if scene is ready to be entered.
isInsideBoard()
- Method in class beroux.mountnfall.
Board.Square
isMouseOver()
- Method in class beroux.mountnfall.
AbstractButton
isMoveValid(Move)
- Method in class beroux.mountnfall.
GameLogic
Check if the move is valid.
isOutlined()
- Method in class beroux.game.
GameFont
isVisible()
- Method in class beroux.game.
Layer
L
LEFT
- Static variable in interface beroux.game.
GameCanvas.MouseButton
Layer
- class beroux.game.
Layer
.
Layer()
- Constructor for class beroux.game.
Layer
loadGame(File)
- Method in class beroux.mountnfall.
InGame
M
MAIN_MENU
- Static variable in interface beroux.mountnfall.
ScenesController.EState
MEDIUM
- Static variable in interface beroux.mountnfall.
AiPlayer.Level
MIDDLE
- Static variable in interface beroux.game.
GameCanvas.MouseButton
MainMenu
- class beroux.mountnfall.
MainMenu
.
MainMenu()
- Constructor for class beroux.mountnfall.
MainMenu
Move
- class beroux.mountnfall.
Move
.
Move()
- Constructor for class beroux.mountnfall.
Move
mouseClicked(MouseEvent)
- Method in class beroux.mountnfall.
ScenesController.MenuListener
mouseReleased(MouseEvent)
- Method in class beroux.mountnfall.
ScenesController.MenuListener
move(int, int)
- Method in class beroux.game.
Layer
N
NewGame
- class beroux.mountnfall.
NewGame
.
Start a new game.
NewGame(String, String, int)
- Constructor for class beroux.mountnfall.
NewGame
next()
- Method in class beroux.mountnfall.
Board.SquaresIterator
O
onEndRound(int, Board)
- Method in class beroux.mountnfall.
EndRound
onEntry()
- Method in class beroux.mountnfall.
Credits
onEntry()
- Method in class beroux.mountnfall.
EndRound
onEntry()
- Method in class beroux.mountnfall.
InGame
onEntry()
- Method in class beroux.mountnfall.
MainMenu
onEntry()
- Method in class beroux.mountnfall.
SceneView
Entering the scene.
onEntry()
- Method in class beroux.mountnfall.
SingleMode
onEntry()
- Method in class beroux.mountnfall.
VersusMode
onExit()
- Method in class beroux.mountnfall.
Credits
onExit()
- Method in class beroux.mountnfall.
EndRound
onExit()
- Method in class beroux.mountnfall.
InGame
onExit()
- Method in class beroux.mountnfall.
MainMenu
onExit()
- Method in class beroux.mountnfall.
SceneView
Exitting the scene.
onExit()
- Method in class beroux.mountnfall.
SingleMode
onExit()
- Method in class beroux.mountnfall.
VersusMode
onKeyDown(char, int)
- Method in class beroux.game.
GameCanvas
Called when a key is pressed.
onKeyDown(char, int)
- Method in class beroux.mountnfall.
SceneView
Called when a key is pressed.
onKeyDown(char, int)
- Method in class beroux.mountnfall.
ScenesController
Called when a key is pressed.
onKeyUp(char, int)
- Method in class beroux.game.
GameCanvas
Called when a key is pressed.
onKeyUp(char, int)
- Method in class beroux.mountnfall.
SceneView
Called when a key is pressed.
onKeyUp(char, int)
- Method in class beroux.mountnfall.
ScenesController
Called when a key is pressed.
onMouseDown(int, int, int)
- Method in class beroux.game.
GameCanvas
Called when a mouse button press is detected.
onMouseDown(int, int, int)
- Method in class beroux.mountnfall.
AbstractButton
Called when a mouse button press is detected.
onMouseDown(int, int, int)
- Method in class beroux.mountnfall.
Credits
Called when a mouse button press is detected.
onMouseDown(int, int, int)
- Method in class beroux.mountnfall.
EndRound
Called when a mouse button press is detected.
onMouseDown(int, int, int)
- Method in class beroux.mountnfall.
InGame
Called when a mouse button press is detected.
onMouseDown(int, int, int)
- Method in class beroux.mountnfall.
MainMenu
Called when a mouse button press is detected.
onMouseDown(int, int, int)
- Method in class beroux.mountnfall.
SceneView
Called when a mouse button press is detected.
onMouseDown(int, int, int)
- Method in class beroux.mountnfall.
ScenesController
Called when a mouse button press is detected.
onMouseDown(int, int, int)
- Method in class beroux.mountnfall.
SingleMode
Called when a mouse button press is detected.
onMouseDown(int, int, int)
- Method in class beroux.mountnfall.
VersusMode
Called when a mouse button press is detected.
onMouseMove(int, int)
- Method in class beroux.game.
GameCanvas
Called when the cursor has changed position.
onMouseMove(int, int)
- Method in class beroux.mountnfall.
AbstractButton
Mouse motion.
onMouseMove(int, int)
- Method in class beroux.mountnfall.
EndRound
Mouse motion.
onMouseMove(int, int)
- Method in class beroux.mountnfall.
InGame
Mouse motion.
onMouseMove(int, int)
- Method in class beroux.mountnfall.
MainMenu
Mouse motion.
onMouseMove(int, int)
- Method in class beroux.mountnfall.
SceneView
Called when the cursor has changed position.
onMouseMove(int, int)
- Method in class beroux.mountnfall.
ScenesController
Called when the cursor has changed position.
onMouseMove(int, int)
- Method in class beroux.mountnfall.
SingleMode
Mouse motion.
onMouseMove(int, int)
- Method in class beroux.mountnfall.
VersusMode
Mouse motion.
onMouseUp(int, int, int)
- Method in class beroux.game.
GameCanvas
Called when a mouse button release is detected.
onMouseUp(int, int, int)
- Method in class beroux.mountnfall.
SceneView
Called when a mouse button release is detected.
onMouseUp(int, int, int)
- Method in class beroux.mountnfall.
ScenesController
Called when a mouse button release is detected.
onPlay(GameLogic)
- Method in class beroux.mountnfall.
AiPlayer
onPlay(GameLogic)
- Method in class beroux.mountnfall.
Player
P
Pattern
- class beroux.mountnfall.
Pattern
.
Render a moving pattern.
Pattern(Sprite)
- Constructor for class beroux.mountnfall.
Pattern
PileUpMove
- class beroux.mountnfall.
PileUpMove
.
Pile up counter to for a tower or increase a tower.
PileUpMove(Board.Square, Board.Square)
- Constructor for class beroux.mountnfall.
PileUpMove
Player
- class beroux.mountnfall.
Player
.
Player(String)
- Constructor for class beroux.mountnfall.
Player
paint(Graphics)
- Method in class beroux.game.
FontString
paint(Graphics2D)
- Method in class beroux.game.
GameCanvas
Render the game.
paint(Graphics)
- Method in class beroux.game.
Layer
paint(Graphics)
- Method in class beroux.game.
Sprite
paint(Graphics2D)
- Method in class beroux.mountnfall.
AbstractButton
Render the object on screen.
paint(Graphics2D)
- Method in class beroux.mountnfall.
BoardRenderer
paint(Graphics2D)
- Method in class beroux.mountnfall.
BumpingButton
Render the object on screen.
paint(Graphics2D)
- Method in class beroux.mountnfall.
Character
paint(Graphics2D)
- Method in class beroux.mountnfall.
Credits
paint(Graphics2D)
- Method in class beroux.mountnfall.
EndRound
paint(Graphics2D)
- Method in class beroux.mountnfall.
EnumButton
Render the object on screen.
paint(Graphics2D)
- Method in class beroux.mountnfall.
GUI
paint(Graphics2D)
- Method in interface beroux.mountnfall.
IGameObject
Render the object on screen.
paint(Graphics2D)
- Method in class beroux.mountnfall.
InGame
paint(Graphics2D)
- Method in class beroux.mountnfall.
InGameBackground
paint(Graphics2D)
- Method in class beroux.mountnfall.
MainMenu
paint(Graphics)
- Method in class beroux.mountnfall.
Pattern
Render the patten.
paint(Graphics2D)
- Method in class beroux.mountnfall.
SceneView
Render the scene.
paint(Graphics2D)
- Method in class beroux.mountnfall.
ScenesController
Render the game.
paint(Graphics2D)
- Method in class beroux.mountnfall.
SingleMode
paint(Graphics2D)
- Method in class beroux.mountnfall.
Tower
paint(Graphics2D)
- Method in class beroux.mountnfall.
VersusMode
pushMessage(String)
- Method in class beroux.mountnfall.
ScenesController
R
RIGHT
- Static variable in interface beroux.game.
GameCanvas.MouseButton
row()
- Method in class beroux.mountnfall.
Board.Square
rows()
- Static method in class beroux.mountnfall.
Board
S
SHIFT
- Static variable in interface beroux.game.
GameCanvas.KeyModifierFlags
SINGLE
- Static variable in interface beroux.mountnfall.
ScenesController.EState
SceneView
- class beroux.mountnfall.
SceneView
.
SceneView()
- Constructor for class beroux.mountnfall.
SceneView
ScenesController
- class beroux.mountnfall.
ScenesController
.
ScenesController()
- Constructor for class beroux.mountnfall.
ScenesController
ScenesController.EState
- interface beroux.mountnfall.
ScenesController.EState
.
ScenesController.MenuListener
- class beroux.mountnfall.
ScenesController.MenuListener
.
ScenesController.MenuListener(String, JMenu)
- Constructor for class beroux.mountnfall.
ScenesController.MenuListener
Screen
- class beroux.game.
Screen
.
Virtual screen to display graphics on.
Screen()
- Constructor for class beroux.game.
Screen
SingleMode
- class beroux.mountnfall.
SingleMode
.
SingleMode()
- Constructor for class beroux.mountnfall.
SingleMode
Sprite
- class beroux.game.
Sprite
.
2D image that can be renderer on screen.
Sprite(String)
- Constructor for class beroux.game.
Sprite
Create a new sprite.
saveGame(File)
- Method in class beroux.mountnfall.
InGame
sendMessageToController(String)
- Method in class beroux.mountnfall.
SceneView
setActionCommand(String)
- Method in class beroux.mountnfall.
AbstractButton
Sets the action command for this button.
setActiveKey(Object)
- Method in class beroux.mountnfall.
EnumButton
setCanvas(Canvas)
- Method in class beroux.game.
Screen
setController(ScenesController)
- Method in class beroux.mountnfall.
SceneView
setCounter(Board.Square, Board.Counter)
- Method in class beroux.mountnfall.
Board
Define counter at the specified square.
setCursor(Cursor)
- Method in class beroux.game.
Screen
Change the screen cursor.
setFont(Font, Color)
- Method in class beroux.game.
GameFont
Change font.
setGameLogic(GameLogic)
- Method in class beroux.mountnfall.
GUI
setGraphics(Graphics2D)
- Method in class beroux.game.
Screen
setHighlight(Board.Square, boolean)
- Method in class beroux.mountnfall.
BoardRenderer
Highlight a square or don't.
setHitBox(Rectangle)
- Method in class beroux.mountnfall.
AbstractButton
setInitialHeight(int)
- Method in class beroux.mountnfall.
Tower
Tower's maximum height.
setOutline(float, Color)
- Method in class beroux.game.
GameFont
Define font outline.
setPosition(int, int)
- Method in class beroux.game.
Layer
setRatio(float)
- Method in class beroux.game.
Screen
setRefPixelPosition(int, int)
- Method in class beroux.game.
Sprite
Sets this Sprite's position such that its reference pixel is located at (x,y) in the painter's coordinate system.
setScale(float)
- Method in class beroux.mountnfall.
Tower
Define tower's height.
setStartingPlayer(int)
- Method in class beroux.mountnfall.
InGame
setString(String)
- Method in class beroux.game.
FontString
setTitle(Sprite)
- Method in class beroux.mountnfall.
GUI
Set the title to display.
setVisible(boolean)
- Method in class beroux.game.
Layer
shift(int, int)
- Method in class beroux.mountnfall.
Board.Square
startingPlayer
- Variable in class beroux.mountnfall.
NewGame
stringWidth(String)
- Method in class beroux.game.
GameFont
Return the length of the string.
T
TEXT
- Static variable in class beroux.game.
Cursor
Tower
- class beroux.mountnfall.
Tower
.
Render a fort's tower.
Tower(int, int, Sprite, Sprite, Sprite)
- Constructor for class beroux.mountnfall.
Tower
Create the tower.
toString()
- Method in class beroux.game.
Sprite
toString()
- Method in class beroux.mountnfall.
Board.Square
toString()
- Method in class beroux.mountnfall.
DepileMove
toString()
- Method in class beroux.mountnfall.
GameOver
toString()
- Method in class beroux.mountnfall.
NewGame
toString()
- Method in class beroux.mountnfall.
PileUpMove
toString()
- Method in class beroux.mountnfall.
Player
tower
- Variable in class beroux.mountnfall.
DepileMove
translate(float, float)
- Method in class beroux.mountnfall.
Pattern
Translate the background.
U
undoLastMove()
- Method in class beroux.mountnfall.
InGame
update(float)
- Method in class beroux.game.
GameCanvas
Update the game.
update(float)
- Method in class beroux.mountnfall.
AbstractButton
Update the object.
update(float)
- Method in class beroux.mountnfall.
BoardRenderer
update(float)
- Method in class beroux.mountnfall.
BumpingButton
Update the object.
update(float)
- Method in class beroux.mountnfall.
Character
update(float)
- Method in class beroux.mountnfall.
Credits
update(float)
- Method in class beroux.mountnfall.
EndRound
update(float)
- Method in class beroux.mountnfall.
EnumButton
Update the object.
update(float)
- Method in class beroux.mountnfall.
GUI
update(float)
- Method in interface beroux.mountnfall.
IGameObject
Update the object.
update(float)
- Method in class beroux.mountnfall.
InGame
update(float)
- Method in class beroux.mountnfall.
MainMenu
update(float)
- Method in class beroux.mountnfall.
SceneView
Update the scene between two rendering.
update(float)
- Method in class beroux.mountnfall.
ScenesController
Update the game.
update(float)
- Method in class beroux.mountnfall.
SingleMode
update(float)
- Method in class beroux.mountnfall.
Tower
update(float)
- Method in class beroux.mountnfall.
VersusMode
V
VERSUS
- Static variable in interface beroux.mountnfall.
ScenesController.EState
VersusMode
- class beroux.mountnfall.
VersusMode
.
VersusMode()
- Constructor for class beroux.mountnfall.
VersusMode
W
WAIT
- Static variable in class beroux.game.
Cursor
WHITE
- Static variable in interface beroux.mountnfall.
Board.Counter.Colour
whiteCounter
- Static variable in class beroux.mountnfall.
Board
whitePlayerName
- Variable in class beroux.mountnfall.
NewGame
width()
- Static method in class beroux.game.
Screen
Virtual screen width.
winner
- Variable in class beroux.mountnfall.
GameOver
_
_height
- Variable in class beroux.game.
Layer
_mouseOver
- Variable in class beroux.mountnfall.
AbstractButton
_originX
- Variable in class beroux.mountnfall.
Pattern
_originY
- Variable in class beroux.mountnfall.
Pattern
_pattern
- Variable in class beroux.mountnfall.
Pattern
_width
- Variable in class beroux.game.
Layer
_x
- Variable in class beroux.game.
Layer
_x
- Variable in class beroux.mountnfall.
AbstractButton
_y
- Variable in class beroux.game.
Layer
_y
- Variable in class beroux.mountnfall.
AbstractButton
A
B
C
D
E
F
G
H
I
L
M
N
O
P
R
S
T
U
V
W
_
Overview
Package
Class
Tree
Deprecated
Index
Help
PREV NEXT
FRAMES
NO FRAMES
All Classes


<script>
alert('Hello world!');
</script>
<style>
body {
margin: 0 auto;
}
</style>
Make changes to the appearance of the page
Get access to the cookies of this site
Get access to the clipboard
Run JavaScript programs such as keylogger
Permanent (stored)
Non-permanent (reflected)
Nothing was found for the query 'our text' :(
<script>
alert(‘You are broken!’)
</script>
toStaticHTML()
<iframe sandbox>
...
</iframe>
tag in tag
</script><script>alert("You are broken!")</script>
changing case
<ScRiPt>alert("You are broken!")</sCrIpT>
Hexadecimal encoding
%253script%253ealert(/You are broken!/)%253c/script%253e


---
layout: post
title: 2/18
date: '2013-02-18T22:20:00.002-07:00'
author: Jacob .
tags:
modified_time: '2013-02-18T22:28:33.370-07:00'
blogger_id: tag:blogger.com,1999:blog-6400085873105072120.post-4723321085072538923
blogger_orig_url: http://www.svlark.com/2013/02/218.html
---
I got the kitchen grout all sealed, the window trim back up, sorta, removed the last of the baby gates, and all the baby locks on the cabinets.
I also did some pricing research with some comps. It's really weird the way things are priced right now. Big beautiful houses are cheap; little ones are expensive. Fortunately for us, ours is little. Hopefully things will be better sorted out in a few weeks.
Audrey did a great job with lesson 68.
239.4


| Class | Description |
|---|---|
| FullScreenViewActivity |
Crated by Skryt on Nov 17, 2018
|
| LoginActivity |
this activity only exists for LoginFragment to work
|
| LoginFragment |
the main parts to this fragment is a text box where user can input their username which will send
that user name to the database to get their relevant information.
|
| MainActivity |
for this activity it just shows a bar at the bottom with 5 buttons
button 1 is a problems button which will take the user to the problems fragment
button 2 is a map button which will take the user to the map fragment
button 3 is a camera button which in the future will allow user to take a picture
button 4 is a search button which will allow a user to search for their patients or careprovider
depending on their account type
button 5 is a person button which brings the user to a page where they can view or edit their
profile info
|
| MessageListFragment |
Created by Skryt on Nov 15, 2018
|
| RegisterFragment |
this fragment lets a user create a profile
the main parts to this fragment is a text box where user can input a username for their account
if the username is already in use or invalid there will be a toast message letting the user try again
there is a spot for the user to enter their phone number if phone number is invalid a toast message
will prompt the user to try again
there is a spot for the user to enter their email if the email is invalid a toast message
will prompt the user to try again
there are also two button for the user to indicate if they are a patient or care provider.
|
| SearchFragment |
Crated by Skryt on Nov 18, 2018
|
| SettingsFragment |
A simple
Fragment subclass. |
| UserEditFragment |
this fragment allows the user to change their username, phone number and email
there is also a button that will change the information that they had to the new data and
saves it to the database.
|
| UserFragment |
this fragment shows the users username, phone number, email and an image of the patient if they added one
there is also a button that will take the user to an edit profile fragment (UserEditFragment)
|


--- layout: page title: Archives headline: Archives ---
Looking for something? Check below to see a collection of all of our posts, ever.
{{post.preview}} View full post here


@* * Copyright 2023 HM Revenue & Customs * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *@ @import config.AppConfig @this() @(optedIn: Boolean)(implicit messages: Messages, appConfig: AppConfig)