## What is underfitting?

Underfitting occurs in machine learning when a model performs poorly on training data. This is usually due to the model being too simplistic and not having enough capacity to learn the complexities of the data. Underfitting can also be caused by not enough data, or by features that are not informative.

### Bias and variance

Underfitting is a modeling error that occurs when a statistical model or machine learning algorithm cannot accurately capture the underlying relationship between the input variables and the target variable.

Underfitting occurs when a model is too simple to learn the underlying relationship between the input variables and the target variable. For example, a linear regression model with only one feature would be underfitted because it would be unable to learn the relationship between the input variable and the target variable.

Underfitting can also occur when a model is too complex, such as when it contains too many features. In this case, the model is said to be overfitted.

The bias of a model is its ability to accurately capturing the underlying relationship between the input variables and the target variable. The variance of a model is its ability to accurately predicting new data points.

A model that is underfitted has high bias and low variance. A model that is overfitted has low bias and high variance.

## How to avoid underfitting?

The main ways to avoid underfitting are to use more data, use a more complex model, or use a model with more features. Reducing the bias will usually also reduce the variance, but this is not always the case. In general, the more complex the model, the higher the risk of overfitting.

### Use more data

One way to avoid underfitting is to use more data. This will help the model generalize better and avoid overfitting on the training data. Using more data is not always possible, and sometimes increasing the amount of data can actually lead to overfitting. In these cases, you can use cross-validation or try different model architectures.

Another way to avoid underfitting is to use a more complex model. This will help the model learn the underlying relationships in the data better and prevent it from making too many simplifying assumptions. This comes at the cost of increased computational complexity and the risk of overfitting on the training data.

### Use a more complex model

You can avoid underfitting your data by using a more complex model. This means adding more features, or increasing the degree of the polynomial for regression models. You can also use a cross-validation set to tune your model’s hyperparameters.

### Use a less complex model

If your model is too simple, it may suffer from underfitting. Underfitting occurs when your model is not complex enough to capture the underlying relationships in your data. This can lead to bias and variance errors.

To avoid underfitting, you should use a less complex model. This will help ensure that your model captures the underlying relationships in your data.