Giter VIP home page Giter VIP logo

course-project-for-getting-and-cleaning-data's Introduction

Course-Project-for-Getting-and-Cleaning-Data

Peer Assignment The method I was implementing:

1.Read X_train.txt, y_train.txt and subject_train.txt from the data folder and store them in trainData, trainLabel and trainSubject variables respectively.

2.Read X_test.txt, y_test.txt and subject_test.txt from the data folder and store them in testData, testLabel and testsubject variables respectively.

3.Concatenate testData to trainData to generate a 10299x561 data frame, mergeData; concatenate testLabel to trainLabel to generate a 10299x1 data frame, mergeLabel; concatenate testSubject to trainSubject to generate a 10299x1 data frame, mergeSubject.

4.Read the features.txt file from the data folder and store the data in a variable called features. We only extract the measurements on the mean and standard deviation. This results in a 66 indices list. We get a subset of mergeData with the 66 corresponding columns.

5.Clean the column names of the subset. We remove the "()" and "-" symbols in the names, as well as make the first letter of "mean" and "std" a capital letter "M" and "S" respectively.

6.Read the activity_labels.txt file from the data folder and store the data in a variable called activity.

7.Clean the activity names in the second column of activity. We first make all names to lower cases. If the name has an underscore between letters, we remove the underscore and capitalize the letter immediately after the underscore.

8.Transform the values of mergeLabel according to the activity data frame.

9.Combine the mergeSubject, mergeLabel and mergeData by column to get a new cleaned 10299x68 data frame, cleanedData. Properly name the first two columns, "subject" and "activity". The "subject" column contains integers that range from 1 to

30 inclusive; the "activity" column contains 6 kinds of activity names; the last 66 columns contain measurements that range from -1 to 1 exclusive.

10.Write the cleanedData out to "merged_data.txt" file in current working directory.

11.Finally, generate a second independent tidy data set with the average of each measurement for each activity and each subject. We have 30 unique subjects and 6 unique activities, which result in a 180 combinations of the two. Then, for each combination, we calculate the mean of each measurement with the corresponding combination. So, after initializing the result data frame and performing the two for-loops, we get a 180x68 data frame. 12.Write the result out to "finalresult" file in current working directory.

course-project-for-getting-and-cleaning-data's People

Contributors

arcozhang avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.