-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprevisao_diaria.R
47 lines (40 loc) · 1.36 KB
/
previsao_diaria.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# Instalando pacotes (se necessário) e carregando ----------------------------------------------------------
remotes::install_github('Juniorffonseca/r-pacote-valorant')
library(caret)
library(dplyr)
library(tidyr)
library(rvest)
library(rsample)
library(readr)
library(quantmod)
library(httr)
library(tibble)
library(stringr)
library(neuralnet)
library(caret)
library(ggplot2)
library(ModelMetrics)
library(beepr)
library(purrr)
library(valorant)
setwd('C:/Users/anonb/Documents/TCC_Pós/Scripts')
load(file = 'rede_neural_10_04_2023.rda')
nome_arquivo_urls <- paste(Sys.Date(), '_urls.csv', sep = '')
nome_arquivo_previsoes <- paste(Sys.Date(), '_previsoes.csv', sep = '')
b <- read.csv2(paste('csv/catalogacao_diaria/', nome_arquivo_urls, sep = '')) %>% select(-X) %>% unlist()
previsoes <- matrix(nrow = 0, ncol = 2)
for (url in b){
# prever as variáveis
tryCatch({
prev <- prever(url)
# criar matriz temporária com duas colunas para armazenar as previsões
temp <- matrix(0, nrow = 1, ncol = 2)
temp[1, ] <- prev
# adicionar as previsões à matriz
previsoes <- rbind(previsoes, temp)
}, error = function(e) {
# caso ocorra um erro, imprimir mensagem de erro e continuar o loop
cat("Erro ao prever a URL", url, ":", conditionMessage(e), "\n")
})
}
write.csv2(previsoes, paste('csv/previsao_diaria/', nome_arquivo_previsoes, sep = ''))