Salary Prediction on Years of Experience — Beginner’s Machine Learning Problem

In this notebook, we will train a model by providing years of experience as independent data and salary as dependent data. We will solve the problem by two ways -

  1. Linear Regression
  2. Decision Tree Regression

Prerequisites — Basic Understanding of Linear Regression and Decision Tree.

Linear Regression — LinearRegression fits a linear model with coefficients w = (w1, …, wp) to minimize the residual sum of squares between the observed targets in the dataset, and the targets predicted by the linear approximation.

Refer to the below code for building your model — To keep it simple and beginner friendly, the no. of independent variables are kept one.

Dataset Link —

Decision Tree Regression — Decision tree builds regression or classification models in the form of a tree structure. It breaks down a dataset into smaller and smaller subsets while at the same time an associated decision tree is incrementally developed. The final result is a tree with decision nodes and leaf nodes.

I hope the code helped you know more about solving basic ML problems.

Thanks for reading…



Flutter Developer | ML | AR

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store