Menu

Introduction to Machine Learning with R: Classification and Clustering

Introduction to Machine Learning with R

Understanding Classification Algorithms

Classification predicts a group, such as Pass or Fail. A decision tree, built with the rpart package, learns simple if-then rules and is easy to explain. A random forest, built with the randomForest package, combines many trees and is usually more stable.

A confusion matrix shows how many students were classified correctly and incorrectly, so you can see what kind of mistakes the model makes.

Start with a simple model, and use a more complex one only if it clearly does better.

Introduction to Clustering

Clustering finds natural groups without being told the answer. The k-means method places k centres in the data and puts each student with the nearest one.

Scale your columns first, so that a column with large numbers does not dominate. The silhouette score, from −1 to 1, shows how well separated the groups are. Higher scores generally indicate better-separated clusters.

You choose k yourself, so try a few values and pick the one that gives clear, useful groups.

Training and Testing a Model Using a Sample Dataset

Always follow the same order:

  1. Split the data.
  2. Train on the training set.
  3. Test on the test set.

Use the same split to compare models, so the comparison is fair. Call set.seed() before any random step, so you and other people get the same results.

In the project, you will train three kinds of models on one student dataset. Never test a model on the same rows it learned from, or the score will look better than it is.


R for Data Science

HA

Harini A



Learn via Video Course

Data Analysis and Processing with Python using Pandas - Data Science Course Logo

Data Analysis and Processing with Python using Pandas - Data Science Course

5 hrs



Get in Touch For Details