Advertisement
CastelShal

Linear reggie

Sep 19th, 2024
232
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Linear regression
  2. data = data.frame(X=c(25,28,35,32,31,36,29,38,34,32), Y = c(43,46,49,41,36,32,31,30,33,39))
  3. model = lm(Y~X, data=data)
  4. test = data.frame(X=40)
  5. predict(model, test)
  6.  
  7.  
  8. ### https://github.com/scikit-learn/scikit-learn/blob/main/sklearn/datasets/data/boston_house_prices.csv
  9. data = read.csv("boston_house_prices.csv")
  10. test = tail(data, n=2)
  11. train = head(data, n=-2)
  12. model = lm(MEDV ~ ., data=train)
  13. predict(model, train[50,])
  14. test
  15.  
  16.  
  17.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement