Code Monkey home page Code Monkey logo

dsci-310-group-09-pkg's Introduction

ln.knn.regression

codecov

The goal of ln.knn.regression is to assist in creating a regression analysis project from start to finish. It includes R functions that help to explore, summarize and visualize the data. It also includes functions that directly build and visualize linear and k-nn models. Additionally, it contains functions that can test the model’s error and accuracy.

ln.knn.regression is similar to tidymodels which is a collection of packages for modeling and machine learning using tidyverse principles. ln.knn.regression imports many of the same packages that tidymodels and tidyverse use, such as dplyr, ggplot2, parsnip, rsample and more. Like tidymodels, ln.knn.regression contains functions for building models and performing data analysis. However, ln.knn.regression is a smaller and more simple package that is used specifically for regression modeling and analysis.

Installation

You can install the development version of ln.knn.regression from GitHub with:

# install.packages("devtools")
devtools::install_github("DSCI-310/dsci-310-group-09-pkg")

Functions

  • bar_graph()
  • hist_plot()
  • knn_model()
  • linearmodel()
  • model_rmspe()
  • scatter_plot()
  • summarize_column()

Example

Here is a basic example which shows you how to explore the data and build a linear regression model.

1. EDA

library(ln.knn.regression)

summarize_column(mtcars, mtcars$mpg)
#>       mean  med       sd
#> 1 20.09062 19.2 6.026948

hist_plot(mtcars, mpg, "MPG", "Count", "Histogram for MPG of Cars", 10)
#> `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.

2. Model Building

mtcars_model <- linearmodel(recipes::recipe(mpg ~ hp, mtcars_training), mtcars_training)
mtcars_model
#> ══ Workflow [trained] ══════════════════════════════════════════════════════════
#> Preprocessor: Recipe
#> Model: linear_reg()
#> 
#> ── Preprocessor ────────────────────────────────────────────────────────────────
#> 0 Recipe Steps
#> 
#> ── Model ───────────────────────────────────────────────────────────────────────
#> 
#> Call:
#> stats::lm(formula = ..y ~ ., data = data)
#> 
#> Coefficients:
#> (Intercept)           hp  
#>    28.36292     -0.05863

3. Visualizations

scatter_plot(mtcars_training, 
             hp, 
             mpg, 
             "Horse Power (HP)", 
             "Miles Per Gallon (mpg)",
             "Best Fit Line for MPG vs HP", 
             15,
             "lm") 
#> `geom_smooth()` using formula = 'y ~ x'

4. Finding model’s accuracy

mtcars_rmspe <- model_rmspe(mtcars_model, mtcars_testing, "mpg")
mtcars_rmspe
#> [1] 4.99694

This tells us that the model has a prediction error of around 5 miles per gallon when tested on data it has not seen before.

Further Resources

For a detailed tutorial on how to use each of the functions in ln.knn.regression, refer to our Vignette.

To view an example of when this package was used for an analysis, please view this repository.

Contributing

We appreciate contributions to the ln.knn.regression package. Please refer to our Contributing document and Code of Conduct for more information.

License

The software provided in this project is offered under the MIT open source license. Refer to the license file for more information.

dsci-310-group-09-pkg's People

Contributors

jennalenoble avatar yuwangy avatar moirarenata avatar veradanilova765 avatar

Stargazers

 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.