High training accuracy with low testing accuracy is overfitting: the model has memorised the training data, noise included, and fails to generalise.
Reasons
- Model too complex for the data (too many parameters, deep trees, high-degree polynomials).
- Too little training data, or noisy / unrepresentative data.
- Too many irrelevant features.
- Training for too long.
- Data leakage or a test set drawn from a different distribution than training.
Mitigation
- More or augmented data.
- Simpler model; feature selection; pruning.
- Regularization (L1 / L2), dropout for neural networks.
- Early stopping on validation loss.
- k-fold cross-validation for model and hyperparameter choice.
- Ensembles (bagging, random forest).
— rhs