Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Linear_Regression_sri
# Simple Linear Regression YearsExperience <- c(1.1, 1.3, 1.5, 2, 2.2, 2.9, 3, 3.2, 3.2, 3.7, 3.9, 4, 4, 4.1, 4.5, 4.9, 5.1, 5.3, 5.9, 6, 6.8, 7.1, 7.9, 8.2, 8.7, 9, 9.5, 9.6, 10.3, 10.5) Salary <- c(39343, 46205, 37731, 43525, 39891, 56642, 60150, 54445, 64445, 57189, 63218, 55794, 56957, 57081, 61111, 67938, 66029, 83088, 81363, 93940, 91738, 98273, 101302, 113812, 109431, 105582, 116969, 112635, 122391, 121872) dataset <- data.frame(YearsExperience, Salary) # Importing the dataset #dataset = read.csv('Salary_Data.csv') #adding missing data # Splitting the dataset into the Training set and Test set #install.packages('caTools') library(caTools) set.seed(123) split = sample.split(dataset$Salary, SplitRatio = 2/3) training_set = subset(dataset, split == TRUE) test_set = subset(dataset, split == FALSE) #print(training_set) #print(test_set) # Feature Scaling # training_set = scale(training_set) # test_set = scale(test_set) # Fitting Simple Linear Regression to the Training set regressor = lm(formula = Salary ~ YearsExperience, data = training_set) #print(summary(regressor)) # Predicting the Test set results y_pred = predict(regressor, newdata = test_set) print(y_pred) #newvalue = data.frame(YearsExperience=5) #y_pred = predict(regressor, newvalue) #print(y_pred) # Visualising the Training set results #install.packages("ggplot2") library(ggplot2) ggplot() + geom_point(aes(x = training_set$YearsExperience, y = training_set$Salary), colour = 'red') + geom_line(aes(x = training_set$YearsExperience, y = predict(regressor, newdata = training_set)), colour = 'blue') + ggtitle('Salary vs Experience (Training set)') + xlab('Years of experience') + ylab('Salary') # Visualising the Test set results library(ggplot2) ggplot() + geom_point(aes(x = test_set$YearsExperience, y = test_set$Salary), colour = 'red') + geom_line(aes(x = training_set$YearsExperience, y = predict(regressor, newdata = training_set)), colour = 'blue') + ggtitle('Salary vs Experience (Test set)') + xlab('Years of experience') + ylab('Salary')
run
|
edit
|
history
|
help
0
Grad-sistemac
This is python
plot_cars
16-09-2020ExVitor
College
Dendrogramm_Clusteranalyse_Länderflächen_euclid_average
Pràctica 1
Quartile Formula
Assignment2 Q1
Mann Whitney wilcoxon test