04 - machine learning basics
needs to be predicted from some input , so the model is some function:
where,
- eg: for Hooke's law,
, is the extension, , , and , where was previously determined from experiment
- input variables used by a model to make a prediction
- the fi anal output or target values that the model tries to learn and predict
- the features is denoted as
, which can more than one number, so it is written as a vector:
regression and classification
-
regression involves predicting a continuous numerical quantity
-
eg: weather measurements
temperature tomorrow -
classification involves predicting a category
-
eg: detector measurements
normal/faulty -
they often produce probabilities such as :
and -
they can be binary or multiclass
learning
- considering the simple model:
- here, the model has some adjustable parameter,
- defining the loss function:
-
so mathematically, learning can be formulated as:
-
hence, it is simply an optimisation problem
-
now considering a more realistic model:
- the model parameters are:
- training involves finding good values for these parameters
- conceptually, the same thing happens for a neural network, where there may be:
- a billion-parameter model roughly means a model with a billion adjustable parameters
- the architecture is vastly more sophisticated but the principle remains: data + objective + optimisation
learned parameters
parameters and hyperparameters
-
a parameter is learned during the training
-
eg: slope of a regression model, intercept, decision-tree values, neural-network weights, neural-network biases
-
a hyperparameter is chosen/configured by the user
-
eg: learning rate, number of trees, max tree depth, batch size, number of neural-network layers, regularisation strength
model = RandomForestClassifier(
n_estimators=200,
max_depth=10
)
model.fit(X_train, y_train)
- here,
n_estimatorsandmax_depthare hyperparameters - the internal properties learned by those 200 trees from the training data are parameters
supervised and unsupervised learning
-
previous discussions have assumed possession of both
and -
so, the model can compare
against , hence it is supervised learning -
consider there are
events with measurements for each event, but no labels -
an algorithm can discover groups of events, which is an example of clustering, falling under unsupervised learning
-
note that there is no known targe
being supplied during the training -
other unsupervised learning tasks include dimensionality reduction and discovering latent structure
overfitting
- a complicated function can exactly fit 1000 points, but this is not the objective
- the model must learn a relationship that generalised to new data rather than perform perfectly on a given dataset
- an ML model will need a sufficiently flexible family of functions and data, and it will optimize the parameters to approximate it