Install.packages('ggplot2') # install once * newdata : the new set of observations that you want to predict Y for. * regressor : the regressor model that was previously created for training. This line predicts the values of dependent factor for new given values of independent factor. Predicted_Y = predict(regressor, newdata = test_set) * data : The data the model trains on, training_set. * Y: dependent Variable.The column label is specified. * formula : Used to differentiate the independent variable(s) from the dependent variable.In case of multiple independent variables, the variables are appended using ‘+’ symbol. This line creates a regressor and provides it with the data set to train. Regressor = lm(formula = Y ~ X, data = training_set) Creating the Linear Regression Model and fitting it with training_Set The Simple Linear Regression is handled by the inbuilt function ‘lm’ in R. Based on the derived formula, the model will be able to predict salaries for any given age or experience. Given a dataset consisting of two columns age or experience in years and salary, the model can be trained to understand and formulate a relationship between the two factors. The model is capable of predicting the salary of an employee with respect to his/her age or experience. The model is used when there are only two factors, one dependent and one independent. Simple linear regression is the simplest regression model of all. Understanding of Linear Regression Models.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |