Row 4041
Content Data
This page contains data entry 4041 from the Axioma AXP content repository. The structured data below represents the complete record for this entry.
I am training a neural network using the h2o library in R. However, when I perform predictions on the test set, I receive a data frame with identical rows. Shouldn't I receive the prediction of the CR variable based on the others (all categorical), for each of the IDs?
My output is in the image
​
script:
library(h2o)
library(readxl)
library(caret)
library(dplyr)
​
\# Load
dados <- read\_excel("dados\_exportadosidlimpo.xlsx")
set.seed(123)
​
\# train and test df
index <- createDataPartition(dados$CR, p = 0.8, list = FALSE)
dados\_treino <- dados\[index, \]
dados\_teste <- dados\[-index, \]
​
\# ID as character
dados\_teste$ID <- as.character(dados\_teste$ID)
​
\# init H2O
h2o.init()
​
\# data as h2o
dados\_treino\_h2o <- as.h2o(dados\_treino)
dados\_teste\_h2o <- as.h2o(dados\_teste)
​
\# response features
preditoras <- setdiff(names(dados\_treino\_h2o), c("ID", "CR"))
resposta <- "CR"
​
\# turn as factor variable
for (coluna in preditoras) {
dados\_treino\_h2o\[\[coluna\]\] <- as.factor(dados\_treino\_h2o\[\[coluna\]\])
dados\_teste\_h2o\[\[coluna\]\] <- as.factor(dados\_teste\_h2o\[\[coluna\]\])
}
​
dados\_treino\_h2o\[\[resposta\]\] <- as.factor(dados\_treino\_h2o\[\[resposta\]\])
dados\_teste\_h2o\[\[resposta\]\] <- as.factor(dados\_teste\_h2o\[\[resposta\]\])
​
\# train model
modelo <- h2o.deeplearning(
x = preditoras,
y = resposta,
training\_frame = dados\_treino\_h2o,
activation = "TanhWithDropout",
hidden = c(10, 10, 10),
epochs = 10
)
​
\# use predict
previsoes <- h2o.predict(modelo, dados\_teste\_h2o)
​
previsoes <- as.data.frame(previsoes)
View(previsoes)
| Field | Value |
|---|---|
| text | I am training a neural network using the h2o library in R. However, when I perform predictions on the test set, I receive a data frame with identical rows. Shouldn't I receive the prediction of the CR variable based on the others (all categorical), for each of the IDs? My output is in the image ​ script: library(h2o) library(readxl) library(caret) library(dplyr) ​ \# Load dados <- read\_excel("dados\_exportadosidlimpo.xlsx") set.seed(123) ​ \# train and test … |
| label | r/neuralnetworks |
| dataType | post |
| communityName | r/neuralnetworks |
| datetime | 2024-04-01 |
| username_encoded | Z0FBQUFBQm5LakwxMVBUMHNsa2lBQjcwLWE5TGFvRENUaGRXMkg1LXJFVGUyeUJScW8zQ29qcWdNdkxCTk4yWWZXVDVrMHJMMjVBQngwbVlPMnU3NVNmNDlQcW53MzJFQVNDMm12RV9WNmlWZUI0WkhuVVRNa0k9 |
| url_encoded | Z0FBQUFBQm5Lak9GVFVaWmdNVzY1U3lmTDUyd3llNk9TYnRGMEQzREdHQzNkZXJiV2czYnZrM1hOVE9tTzNNQ0NUM2pSYzREWFRYRENqRUw3NGh1LWYxRkVKTGlTSldsZnozWHJtSnN6NThzXzI0X2p5SmRmaF9CSXpKVkUtMmVDVnpCMlpjY0RkZ2pjWTdTVTdhMUFLeWdCT2xzV21hVVdoUWRkYzFteFZUYVBHWTl0RDdBOEg4NmpoXzZVcVZCVHQ0U0RMVU40R3IzOG1tbDVtekY4OG8wTDNsZ2dwQWJiQT09 |
Raw Record
{
"text": " \n\nI am training a neural network using the h2o library in R. However, when I perform predictions on the test set, I receive a data frame with identical rows. Shouldn't I receive the prediction of the CR variable based on the others (all categorical), for each of the IDs? \n\nMy output is in the image\n\n​\n\nscript:\n\n library(h2o)\n\nlibrary(readxl)\n\nlibrary(caret)\n\nlibrary(dplyr)\n\n​\n\n\\# Load\n\ndados <- read\\_excel(\"dados\\_exportadosidlimpo.xlsx\")\n\nset.seed(123)\n\n​\n\n\\# train and test df\n\nindex <- createDataPartition(dados$CR, p = 0.8, list = FALSE)\n\ndados\\_treino <- dados\\[index, \\]\n\ndados\\_teste <- dados\\[-index, \\]\n\n​\n\n\\# ID as character\n\ndados\\_teste$ID <- as.character(dados\\_teste$ID)\n\n​\n\n\\# init H2O\n\nh2o.init()\n\n​\n\n\\# data as h2o\n\ndados\\_treino\\_h2o <- as.h2o(dados\\_treino)\n\ndados\\_teste\\_h2o <- as.h2o(dados\\_teste)\n\n​\n\n\\# response features\n\npreditoras <- setdiff(names(dados\\_treino\\_h2o), c(\"ID\", \"CR\"))\n\nresposta <- \"CR\"\n\n​\n\n\\# turn as factor variable\n\nfor (coluna in preditoras) {\n\n dados\\_treino\\_h2o\\[\\[coluna\\]\\] <- as.factor(dados\\_treino\\_h2o\\[\\[coluna\\]\\])\n\n dados\\_teste\\_h2o\\[\\[coluna\\]\\] <- as.factor(dados\\_teste\\_h2o\\[\\[coluna\\]\\])\n\n}\n\n​\n\ndados\\_treino\\_h2o\\[\\[resposta\\]\\] <- as.factor(dados\\_treino\\_h2o\\[\\[resposta\\]\\])\n\ndados\\_teste\\_h2o\\[\\[resposta\\]\\] <- as.factor(dados\\_teste\\_h2o\\[\\[resposta\\]\\])\n\n​\n\n\\# train model\n\nmodelo <- h2o.deeplearning(\n\n x = preditoras,\n\n y = resposta,\n\n training\\_frame = dados\\_treino\\_h2o,\n\n activation = \"TanhWithDropout\",\n\n hidden = c(10, 10, 10),\n\n epochs = 10\n\n)\n\n​\n\n\\# use predict\n\nprevisoes <- h2o.predict(modelo, dados\\_teste\\_h2o)\n\n​\n\nprevisoes <- as.data.frame(previsoes)\n\nView(previsoes)",
"label": "r/neuralnetworks",
"dataType": "post",
"communityName": "r/neuralnetworks",
"datetime": "2024-04-01",
"username_encoded": "Z0FBQUFBQm5LakwxMVBUMHNsa2lBQjcwLWE5TGFvRENUaGRXMkg1LXJFVGUyeUJScW8zQ29qcWdNdkxCTk4yWWZXVDVrMHJMMjVBQngwbVlPMnU3NVNmNDlQcW53MzJFQVNDMm12RV9WNmlWZUI0WkhuVVRNa0k9",
"url_encoded": "Z0FBQUFBQm5Lak9GVFVaWmdNVzY1U3lmTDUyd3llNk9TYnRGMEQzREdHQzNkZXJiV2czYnZrM1hOVE9tTzNNQ0NUM2pSYzREWFRYRENqRUw3NGh1LWYxRkVKTGlTSldsZnozWHJtSnN6NThzXzI0X2p5SmRmaF9CSXpKVkUtMmVDVnpCMlpjY0RkZ2pjWTdTVTdhMUFLeWdCT2xzV21hVVdoUWRkYzFteFZUYVBHWTl0RDdBOEg4NmpoXzZVcVZCVHQ0U0RMVU40R3IzOG1tbDVtekY4OG8wTDNsZ2dwQWJiQT09"
}
Entry Information
- Entry ID: 4041
- Repository: Axioma AXP
- Dataset: arrmlet/reddit_dataset_36
- Total Entries: 100,000