https://github.com/frahik/ibcf.mtme
Item Based Collaborative Filtering For Multi-trait and Multi-environment Data [R Package - dev version]
https://github.com/frahik/ibcf.mtme
bayesian-methods predictive-modeling r-package
Last synced: 4 months ago
JSON representation
Item Based Collaborative Filtering For Multi-trait and Multi-environment Data [R Package - dev version]
- Host: GitHub
- URL: https://github.com/frahik/ibcf.mtme
- Owner: frahik
- License: lgpl-3.0
- Created: 2018-02-06T23:26:55.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2019-03-24T01:33:45.000Z (almost 7 years ago)
- Last Synced: 2025-10-22T05:50:55.240Z (4 months ago)
- Topics: bayesian-methods, predictive-modeling, r-package
- Language: R
- Homepage:
- Size: 453 KB
- Stars: 2
- Watchers: 1
- Forks: 4
- Open Issues: 2
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE
Awesome Lists containing this project
README
---
output: github_document
---
**I**tem **B**ased **C**ollaborative **F**ilterign For **M**ulti-**T**rait and **M**ulti-**E**nvironment Data in R - Development version `r packageVersion('IBCF.MTME')`.
[Last README update: `r format(Sys.Date())`]
# Table Of Contents
- [NEWS](#news)
- [Instructions](#instructions)
- [Installation](#install)
- [Load the package](#package)
- [Example of Cross-validation with IBCF.MTME and external data](#example1)
- [Load external data](#external-data)
- [Generate a data set in tidy data](#generate-tidydata)
- [Generate a Cross-validation](#generate-crossvalidation)
- [Fitting the predictive model](#fit-model)
- [Show some results](#results)
- [Example of Years prediction with IBCF.Years Function](#example2)
- [Loading your data](#external-data2)
- [Transforming the data from Tidy data to matrix form](#generate-matrixform)
- [Adjust the model](#adjust-model)
- [Show some results](#results)
- [Load available data from the package](#load-data)
- [How to cite this package](#cite)
- [Contributions](#contributions)
- [Authors](#authors)
News of this version (`r packageVersion('IBCF.MTME')`)
* Fixed important issue with the predictions output.
* Fixed compatibility with dplyr 0.8.
* Fixed barplot function.
See the last updates in [NEWS](NEWS.md).
Instructions for proper implementation
Installation
To complete installation of dev version of the package `IBCF.MTME` from GitHub, you must have previously installed the devtools package.
```{r installation, eval = FALSE}
install.packages('devtools')
devtools::install_github('frahik/IBCF.MTME')
```
If you want to use the stable version of `IBCF.MTME` package, install it from CRAN.
```{r, eval=FALSE}
install.packages('IBCF.MTME')
```
Load the package
```{r}
library(IBCF.MTME)
```
Example of Cross-validation with IBCF.MTME
Load available data from other package
```{r CVModel}
library(BGLR)
data(wheat)
```
Generate a new data set in tidy data form
```{r}
pheno <- data.frame(ID = gl(n = 599, k = 1, length = 599*4),
Response = as.vector(wheat.Y),
Env = paste0('Env', gl(n = 4, k = 599)))
head(pheno)
```
Generate 10 partitions to do cross-validation
```{r}
CrossV <- CV.RandomPart(pheno, NPartitions = 10, PTesting = 0.25, Set_seed = 123)
```
Fitting the predictive model
```{r}
pm <- IBCF(CrossV)
```
Show some results
All the predictive model printed output:
```{r}
pm
```
Predictions and observed data in tidy format
```{r}
head(pm$predictions_Summary, 6)
```
Predictions and observed data in matrix format
```{r}
head(pm$Data.Obs_Pred, 5)
```
Some plots
```{r}
par(mai = c(2, 1, 1, 1))
plot(pm, select = 'Pearson')
plot(pm, select = 'MAAPE')
```
Example of Years prediction with IBCF.Years Function
```{r YearsData, echo = FALSE, warning = FALSE}
library(mvtnorm)
library(IBCF.MTME)
set.seed(2)
A <- matrix(0.65, ncol = 12, nrow = 12)
diag(A) <- 1
Sdv <- diag(c(0.9^0.5,0.8^0.5,0.9^0.5,0.8^0.5,0.86^0.5,0.7^0.5,0.9^0.5,0.8^0.5,0.9^0.5,0.7^0.5,0.7^0.5,0.85^0.5))
Sigma <- Sdv %*% A %*% Sdv
No.Lines <- 80
Z <- rmvnorm(No.Lines,mean = c(15, 15.5, 16, 15.5, 17, 16.5, 16.0, 17, 16.6, 18, 16.3, 18), sigma = Sigma)
Years <- c(rep(2014,20), rep(2015,20), rep(2016,20), rep(2017,20))
Gids <- c(1:No.Lines)
Data.Example <- data.frame(cbind(Years,Gids,Z))
colnames(Data.Example) <- c("Years","Gids","Trait1","Trait2","Trait3","Trait4","Trait5","Trait6","Trait7","Trait8","Trait9","Trait10","Trait11","Trait12")
Data.Example <- getTidyForm(Data.Example, onlyTrait = T)
save(Data.Example, file = 'DataExample.RData')
```
Loading your data
```{r}
load('DataExample.RData')
head(Data.Example)
```
Transforming the data from Tidy data to matrix form
```{r}
Data.Example <- getMatrixForm(Data.Example, onlyTrait = TRUE)
head(Data.Example)
```
Adjust the model
```{r Years}
pm <- IBCF.Years(Data.Example, colYears = 1, Years.testing = c('2014', '2015', '2016'),
Traits.testing = c('Trait1', 'Trait2', 'Trait3', 'Trait4', "Trait5"))
```
Show some results
```{r}
summary(pm)
par(mai = c(2, 1, 1, 1))
barplot(pm, las = 2)
barplot(pm, select = 'MAAPE', las = 2)
```
Load available data from the package
You can use the data sets in the package to test the functions
```{r loadData}
library(IBCF.MTME)
data('Wheat_IBCF')
head(Wheat_IBCF)
```
```{r loadYearData}
data('Year_IBCF')
head(Year_IBCF)
```
Citation
First option, by the article paper
```
@article{IBCF2018,
author = {Montesinos-L{\'{o}}pez, Osval A. and Luna-V{\'{a}}zquez, Francisco Javier and Montesinos-L{\'{o}}pez, Abelardo and Juliana, Philomin and Singh, Ravi and Crossa, Jos{\'{e}}},
doi = {10.3835/plantgenome2018.02.0013},
issn = {1940-3372},
journal = {The Plant Genome},
number = {3},
pages = {16},
title = {{An R Package for Multitrait and Multienvironment Data with the Item-Based Collaborative Filtering Algorithm}},
url = {https://dl.sciencesocieties.org/publications/tpg/abstracts/0/0/180013},
volume = {11},
year = {2018}
}
```
Second option, by the manual package
```{r}
citation('IBCF.MTME')
```
Contributions
If you have any suggestions or feedback, I would love to hear about it. Feel free to report new issues in [this link](https://github.com/frahik/IBCF.MTME/issues/new), also if you want to request a feature/report a bug, or make a pull request if you can contribute.
Authors
- Francisco Javier Luna-Vázquez (Author, Maintainer)
- Osval Antonio Montesinos-López (Author)
- Abelardo Montesinos-López (Author)
- José Crossa (Author)