Git Product home page Git Product logo

Comments (2)

gagolews avatar gagolews commented on May 26, 2024

This is the exercise I started writing...

Let's consider the Wine Quality dataset (winequality-all.csv)
that you can download from SIT114's CloudDeakin site
(Resources → Datasets). It is assumed that the file is stored in
the same current working directory (e.g., the same where the Rmd file is).

wines <- read.csv("winequality-all.csv", comment="#")
head(wines)

These are Vinho Verde red and white wine samples from the north of Portugal,
see https://www.vinhoverde.pt/en/homepage.
There are 11 physicochemical features reported.
Moreover, there is a wine rating on the scale 0 (bad) to 10 (excellent)
given by wine experts, read more at
https://archive.ics.uci.edu/ml/datasets/Wine+Quality.

  1. Remove all the red wines from wines (replacing the old data frame
    with the new one). Then, get rid of the color and response columns.

    Click here for a solution

    First let's handle the red wines.

    wines <- wines[wines$color != "red", ]
    

    Omitting the aforementioned columns can be done in a few ways. Here is one:

    wines <- wines[, is.na(match(names(wines), c("color", "response")))]
    

    To recall, names(data.frame) gives the vector of column names.
    On the other hand, the match() function, matches all the values
    in the first argument against all the values in the second argument.
    If there is no match (in our case, if a column name is not amongst
    the two names we wish to remove), NA is generated.

  2. Compute the Pearson correlation coefficient between alcohol and
    every other variable in the dataset.

    Click here for a solution

    This can be done via a call to cor(). A quick glimpse at the manual page
    (?cor) reveals, that this task can be solved as follows:

    cor(wines$alcohol, wines)
    

    We could have got rid of the the alcohol vs. alcohol comparison,
    but wanted to show that any column is always perfectly linearly correlated
    with itself, hence the 1.0 coefficient obtained.

  3. Fit simple regression models for alcohol as functions
    of the three most correlated variables (three individual models).

round(cor(wines),2)
f_density <- lm(alcohol~density, data=wines)
plot(alcohol~density, data=wines)
summary(f_density)
abline(f_density, col="red")
step(lm(alcohol~1, data=wines), # empty model
    scope=formula(lm(alcohol~., data=wines)), # full model
    direction="forward")

from lmlcr.

gagolews avatar gagolews commented on May 26, 2024

(the to-do list has moved)

from lmlcr.

Related Issues (20)

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.