Row 4041

Row ID: 4041 | Dataset Entry | Axioma AXP Content Repository

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)

&#x200B;

\# train and test df

index <- createDataPartition(dados$CR, p = 0.8, list = FALSE)

dados\_treino <- dados\[index, \]

dados\_teste <- dados\[-index, \]

&#x200B;

\# ID as character

dados\_teste$ID <- as.character(dados\_teste$ID)

&#x200B;

\# init H2O

h2o.init()

&#x200B;

\# data as h2o

dados\_treino\_h2o <- as.h2o(dados\_treino)

dados\_teste\_h2o <- as.h2o(dados\_teste)

&#x200B;

\# response features

preditoras <- setdiff(names(dados\_treino\_h2o), c("ID", "CR"))

resposta <- "CR"

&#x200B;

\# 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\]\])

}

&#x200B;

dados\_treino\_h2o\[\[resposta\]\] <- as.factor(dados\_treino\_h2o\[\[resposta\]\])

dados\_teste\_h2o\[\[resposta\]\] <- as.factor(dados\_teste\_h2o\[\[resposta\]\])

&#x200B;

\# train model

modelo <- h2o.deeplearning(

x = preditoras,

y = resposta,

training\_frame = dados\_treino\_h2o,

activation = "TanhWithDropout",

hidden = c(10, 10, 10),

epochs = 10

)

&#x200B;

\# use predict

previsoes <- h2o.predict(modelo, dados\_teste\_h2o)

&#x200B;

previsoes <- as.data.frame(previsoes)

View(previsoes)

FieldValue
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 &#x200B; script: library(h2o) library(readxl) library(caret) library(dplyr) &#x200B; \# Load dados <- read\_excel("dados\_exportadosidlimpo.xlsx") set.seed(123) &#x200B; \# 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&#x200B;\n\nscript:\n\n library(h2o)\n\nlibrary(readxl)\n\nlibrary(caret)\n\nlibrary(dplyr)\n\n&#x200B;\n\n\\# Load\n\ndados <- read\\_excel(\"dados\\_exportadosidlimpo.xlsx\")\n\nset.seed(123)\n\n&#x200B;\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&#x200B;\n\n\\# ID as character\n\ndados\\_teste$ID <- as.character(dados\\_teste$ID)\n\n&#x200B;\n\n\\# init H2O\n\nh2o.init()\n\n&#x200B;\n\n\\# data as h2o\n\ndados\\_treino\\_h2o <- as.h2o(dados\\_treino)\n\ndados\\_teste\\_h2o <- as.h2o(dados\\_teste)\n\n&#x200B;\n\n\\# response features\n\npreditoras <- setdiff(names(dados\\_treino\\_h2o), c(\"ID\", \"CR\"))\n\nresposta <- \"CR\"\n\n&#x200B;\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&#x200B;\n\ndados\\_treino\\_h2o\\[\\[resposta\\]\\] <- as.factor(dados\\_treino\\_h2o\\[\\[resposta\\]\\])\n\ndados\\_teste\\_h2o\\[\\[resposta\\]\\] <- as.factor(dados\\_teste\\_h2o\\[\\[resposta\\]\\])\n\n&#x200B;\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&#x200B;\n\n\\# use predict\n\nprevisoes <- h2o.predict(modelo, dados\\_teste\\_h2o)\n\n&#x200B;\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