Tumgik
#parttraining
rodprojects · 3 years
Video
Fun chest press with live weight. #exercisesforcouple #workoutforcouple #trainingforcouole #acroyoga #sportforcouple #fitnessforcouple #funfitness #futparktraining #openairworkout #bodyweightworkout #friendsworkout #friendstraining #friendsexercises #usegfasbarbell #usegfasdumbbell #usewifeasbarbell #usefiweasdumbbell #freeweiggtworkout #liveweiggtworkout #parttraining #gardenworkout #girlsworkout #trainingfortwo #workoutfortwo #exercisesfortwo #gymnasticforcouple #athlethicforcouple #funcouple #funnycouple #justcouple (at Benja Kitti park@Asoke) https://www.instagram.com/p/CUb4LZ8FrK8/?utm_medium=tumblr
1 note · View note
bitcsera · 7 years
Text
Background
Using devices such as Jawbone Up, Nike FuelBand, and Fitbit it is now possible to collect a large amount of data about personal activity relatively inexpensively. These type of devices are part of the quantified self movement – a group of enthusiasts who take measurements about themselves regularly to improve their health, to find patterns in their behavior, or because they are tech geeks. One thing that people regularly do is quantify how much of a particular activity they do, but they rarely quantify how well they do it. In this project, your goal will be to use data from accelerometers on the belt, forearm, arm, and dumbell of 6 participants. They were asked to perform barbell lifts correctly and incorrectly in 5 different ways. More information is available from the website here: http://groupware.les.inf.puc-rio.br/har (see the section on the Weight Lifting Exercise Dataset).
Data
The training data for this project are available here:
https://d396qusza40orc.cloudfront.net/predmachlearn/pml-training.csv
The test data are available here:
https://d396qusza40orc.cloudfront.net/predmachlearn/pml-testing.csv
The data for this project come from this source: http://groupware.les.inf.puc-rio.br/har. If you use the document you create for this class for any purpose please cite them as they have been very generous in allowing their data to be used for this kind of assignment.
What you should submit
The goal of your project is to predict the manner in which they did the exercise. This is the "classe" variable in the training set. You may use any of the other variables to predict with. You should create a report describing how you built your model, how you used cross validation, what you think the expected out of sample error is, and why you made the choices you did. You will also use your prediction model to predict 20 different test cases.
---------------------------------------------------------------
# Load the packages useful for the analysis
library(caret)
library(randomForest)
 # Load data provided on Coursera
# Any blank value is replaced by "NA"
training <- read.csv("pml-training.csv", na.strings = c("NA", ""))
testing <- read.csv("pml-testing.csv", na.strings = c("NA", ""))
 # Take a look to number of rows and variables
dim(training)
dim(testing)
# training -> 19622 rows, 160 variables
# testing -> 20 rows, 160 variables
 # See the structure
str(training)
str(testing)
 # Remove all the columns that show any missing values
training_1 <- training[, colSums(is.na(training)) == 0]
testing_1 <- testing[, colSums(is.na(testing)) == 0]
 # Remove the first seven colums as they have no such predictive power to "classe"
training_2 <- training_1[, -c(1:7)]
testing_2 <- testing_1[, -c(1:7)]
 # So, take again a look to number of rows and variables
dim(training_2)
dim(testing_2)
# training -> 19622 rows, 53 variables (variables have been reduced, as consequence)
# testing -> 20 rows, 53 variables (variables have been reduced, as consequence)
 # Set a seed in order then to have a new training set (split is 70%) for prediction and
# a validation set (split is 30%).
set.seed(1234)
PartTrain <- createDataPartition(training_2$classe, p = 0.7, list = FALSE)
train <- training_2[PartTrain, ]
valid <- training_2[-PartTrain, ]
 # Train a model using random forest with a k-fold cross validation
mod_rf <- train(classe ~., method="rf", data=train, trControl=trainControl(method='cv'),
                number=5, allowParallel=TRUE, importance=TRUE )
print(mod_rf)
# Print and show result
#
# Random Forest
#
# 13737 samples
# 52 predictor
# 5 classes: 'A', 'B', 'C', 'D', 'E'
#
# No pre-processing
# Resampling: Cross-Validated (10 fold)
# Summary of sample sizes: 12365, 12365, 12362, 12361, 12363, 12364, ...
# Resampling results across tuning parameters:
# mtry  Accuracy   Kappa   
# 2    0.9922856  0.9902402
# 27    0.9931575  0.9913439
# 52    0.9903183  0.9877527
#
# Accuracy was used to select the optimal model using  the largest value.
# The final value used for the model was mtry = 27.
 # Plot
varImpPlot(mod_rf$finalModel, sort = TRUE, type = 1, pch = 25, col = "red", cex = 0.7,
           main = "Principal components: IMPORTANCE", sub = "ORDERED")
# Graph shows the principal components in order of importance
 pred_rf <- predict(mod_rf, valid)
confusion <- confusionMatrix(valid$classe, pred_rf)
print(confusion$table)
# Print and show the table result
# Reference
# Prediction    A    B    C    D    E
# A 1674    0    0    0    0
# B   11 1127    1    0    0
# C    0    3 1019    4    0
# D    0    2    6  954    2
# E    0    1    2    3 1076
#
# A few cases are not properly predicted
 # Estimate accuracy
accuracy <- postResample(valid$classe, pred_rf)
Fit_Accuracy <- accuracy[[1]]
print(Fit_Accuracy)
# Print and show result of accuracy rate
# [1] 0.9940527
 # Calculate out-of-sample error rate
1-0.9940527
# [1] 0.0059473
 # There is high correlation between the variables
 prediction <- predict(mod_rf, testing_2)
print(prediction)
#  [1] B A B A A E D B A A B C B A E E A B B B
# Levels: A B C D E
0 notes