Skip to content

Commit

Permalink
Format the code
Browse files Browse the repository at this point in the history
  • Loading branch information
statwangz committed Jan 2, 2024
1 parent 0926f58 commit 912bd1a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 7 deletions.
30 changes: 24 additions & 6 deletions vignettes/ml100k.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,21 @@ After fitting the MFAI model, we can use the `getImportance()` function to obtai

```{r}
# Get importance score
importance <- as.data.frame(getImportance(mfairObject, which_factors = 1:3))
importance <- as.data.frame(
getImportance(mfairObject, which_factors = 1:3)
)
importance$Genre <- rownames(importance)
# Convert the wide table to the long table
importance_long <- melt(
data = importance,
id.vars = "Genre",
variable.name = "Factor",
value.name = "Importance"
)
importance_long$Genre <- factor(importance_long$Genre, levels = rev(colnames(X)))
importance_long$Genre <- factor(
importance_long$Genre,
levels = rev(colnames(X))
)
# head(importance_long)
```

Expand Down Expand Up @@ -126,15 +132,21 @@ mfairObject_pmt <- fitGreedy(mfairObject_pmt,

```{r}
# Get importance score
importance_pmt <- as.data.frame(getImportance(mfairObject_pmt, which_factors = 1:3))
importance_pmt <- as.data.frame(
getImportance(mfairObject_pmt, which_factors = 1:3)
)
importance_pmt$Genre <- rownames(importance_pmt)
# Convert the wide table to the long table
importance_pmt_long <- melt(
data = importance_pmt,
id.vars = "Genre",
variable.name = "Factor",
value.name = "Importance"
)
importance_pmt_long$Genre <- factor(importance_pmt_long$Genre, levels = rev(colnames(X_pmt)))
importance_pmt_long$Genre <- factor(
importance_pmt_long$Genre,
levels = rev(colnames(X_pmt))
)
# head(importance_pmt_long)
# Visualize the importance score
Expand Down Expand Up @@ -179,15 +191,21 @@ mfairObject_both <- fitGreedy(mfairObject_both,

```{r}
# Get importance score
importance_both <- as.data.frame(getImportance(mfairObject_both, which_factors = 1:3))
importance_both <- as.data.frame(
getImportance(mfairObject_both, which_factors = 1:3)
)
importance_both$Genre <- rownames(importance_both)
# Convert the wide table to the long table
importance_both_long <- melt(
data = importance_both,
id.vars = "Genre",
variable.name = "Factor",
value.name = "Importance"
)
importance_both_long$Genre <- factor(importance_both_long$Genre, levels = rev(colnames(X_both)))
importance_both_long$Genre <- factor(
importance_both_long$Genre,
levels = rev(colnames(X_both))
)
# head(importance_both_long)
# Visualize the importance score
Expand Down
4 changes: 3 additions & 1 deletion vignettes/neocortex.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ p <- ggplot(
data = FX_long,
aes(
x = `Time period`, y = F,
linetype = `Neocortex area`, colour = `Neocortex area`, group = `Neocortex area`
linetype = `Neocortex area`,
colour = `Neocortex area`,
group = `Neocortex area`
)
) +
geom_line(linewidth = 0.5) +
Expand Down

0 comments on commit 912bd1a

Please sign in to comment.