Comments (5)
hi @R-icntay could you lend your expertise here please?
from ml-for-beginners.
Firstly, thank you for providing a reproducible example. You were almost there, so good job!
The only thing that was missing is evaluating for a second condition, i.e if lm.cv.r[i] > 0.70
. I have modified your example and it works as expected and ensures that R does not accidentally overwrite a similar previous value.
data("USArrests")
head(USArrests)
df.norm <- USArrests
set.seed(100)
lm.cv.mse <- NULL
lm.cv.r <- NULL
k <- 100
for(i in 1:k){
index.cv <- sample(1:nrow(df.norm),round(0.8*nrow(df.norm)))
df.cv.train <- df.norm[index.cv, ]
df.cv.test <- df.norm[-index.cv, ]
lm.cv <- glm(Rape~., data = df.cv.train)
lm.cv.predicted <- predict(lm.cv, df.cv.test)
lm.cv.mse[i] <- sum((df.cv.test$rape - lm.cv.predicted)^2)/nrow(df.cv.test)
lm.cv.r[i] <- as.numeric(round(cor(lm.cv.predicted, df.cv.test$Rape, method = "pearson"), digits = 3))
if (!is.na(lm.cv.r[i]) && lm.cv.r[i] > 0.70){
saveRDS(lm.cv, file = paste("lm.cv", i, lm.cv.r[i], ".rds", sep = '_'))
}
}
We invite you to check to check out our R lessons that show you how to build Machine Learning models using the Tidymodels framework: https://github.com/microsoft/ML-For-Beginners.
Do enjoy the ride and feel free to reach out in case of any difficulty.
Happy leaRning!
from ml-for-beginners.
from ml-for-beginners.
all set? should I close this? thanks everyone!
from ml-for-beginners.
Yes yes Jen.
All good here!
from ml-for-beginners.
Related Issues (20)
- Lesson 1 HOT 1
- Graph ML HOT 6
- Beginner friendly ML from scratch HOT 2
- Machine l
- ML for beginners
- Build Web App with Gradio HOT 1
- Incorrect data manipulation HOT 13
- [TRANSLATIONS] Hindi HOT 21
- [TRANSLATIONS] Tamil HOT 1
- hi-telugu added
- Titles Guidelines HOT 2
- Pranjay OS
- outdated link in 1-Introduction/4-techniques-of-ML/README.md HOT 1
- Guide
- 1-Tools/notebook.ipynb is an empty file HOT 1
- Machine language for beginners
- Shall I add DBSCAN and Hierarchical Clustering Algo? HOT 3
- [TRANSLATIONS]
- Microsoft/ML-For-Beginners HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ml-for-beginners.