← back

Model Performance Measurement

In this exercise we tried different measurements of a machine learning model's performance. How close are the model's predictions to actual values?

The example code we were given didn't work at first - there were several errors and warnings which I debugged.

I fixed errors such as this by taking out extra spaces at the start of lines of code.

IndentationError: unexpected indent

I fixed errors such as this by updating the code to match the latest versions of Python libraries.

Using the 'liblinear' solver for multiclass classification is deprecated.

I tried out different measurements of performance such as these.

I also tried changing some parameters to see how they would affect the performance measurements.

One example is the Iris dataset, which contains 150 samples of iris flowers. I introduced different amounts of "noise" to the data like this.

X = np.c_[X, random_state.randn(n_samples, 200 * n_features)]

I started with a value of 200 for noise, and gradually reduced it to 0, to see how it would effect Area Under the Curve (AUC) and R-squared (R²) - both of these measurements have values closer to 1 for higher performance.

noise valueAUC
2000.790.95
1500.720.95
1000.760.95
500.910.95
01.000.95

As you can see, reducing the amount of noise definitely improved the true positive/false positive rate (AUC) but it didn't affect how well the model exlains the data (R²).

Here is my complete Python code.