diamonds |
dplyr |DT |ggplot2
|# Carregar pacotes
library(dplyr)
library(ggplot2)
library(DT)
dados <- ggplot2::diamonds
head(dados)
## # A tibble: 6 × 10
## carat cut color clarity depth table price x y z
## <dbl> <ord> <ord> <ord> <dbl> <dbl> <int> <dbl> <dbl> <dbl>
## 1 0.23 Ideal E SI2 61.5 55 326 3.95 3.98 2.43
## 2 0.21 Premium E SI1 59.8 61 326 3.89 3.84 2.31
## 3 0.23 Good E VS1 56.9 65 327 4.05 4.07 2.31
## 4 0.29 Premium I VS2 62.4 58 334 4.2 4.23 2.63
## 5 0.31 Good J SI2 63.3 58 335 4.34 4.35 2.75
## 6 0.24 Very Good J VVS2 62.8 57 336 3.94 3.96 2.48
dados_manip <- dados %>%
mutate(
# Criar variável: preço por quilate
preco_por_quilate = price / carat
) %>%
# Filtrar diamantes do tipo "Ideal" e "Premium"
filter(cut %in% c("Ideal", "Premium")) %>%
# Ordenar pelo preço por quilate (decrescente)
arrange(desc(preco_por_quilate))
datatable(
dados_manip,
options = list(pageLength = 10),
caption = "Tabela 1: Subconjunto de diamantes 'Ideal' e 'Premium' com preço por quilate."
)
## Warning in instance$preRenderHook(instance): It seems your data is too big for
## client-side DataTables. You may consider server-side processing:
## https://rstudio.github.io/DT/server.html
A seguir, apresento cinco equações fundamentais em estatística e aprendizado de máquina, escritas usando a sintaxe do LaTeX.
\[ y = \beta_0 + \beta_1 x + \varepsilon \] > Representa uma relação linear entre uma variável dependente \(y\) e uma variável independente \(x\), onde \(\varepsilon\) é o erro aleatório.
\[ J(\theta) = \frac{1}{2m}\sum_{i=1}^{m}(h_\theta(x^{(i)}) - y^{(i)})^2 \] > Mede o erro médio quadrático entre os valores previstos \(h_\theta(x^{(i)})\) e os valores reais \(y^{(i)}\).
\[ \sigma(x) = \frac{1}{1 + e^{-x}} \] > Utilizada em regressão logística e redes neurais, transforma qualquer valor real em um intervalo entre 0 e 1.
\[ H(p, q) = - \sum_{i=1}^{n} p(x_i) \log q(x_i) \] > Mede a diferença entre duas distribuições de probabilidade — é usada para avaliar classificadores probabilísticos.
\[ \theta := \theta - \alpha \nabla_\theta J(\theta) \] > Fórmula usada para otimizar os parâmetros \(\theta\) em modelos de aprendizado, ajustando-os na direção oposta ao gradiente da função de custo.
ggplot(dados, aes(x = carat, y = price, color = cut)) +
geom_point(alpha = 0.5) +
labs(
title = "Relação entre Quilates e Preço dos Diamantes",
x = "Peso (carat)",
y = "Preço (US$)"
) +
theme_minimal()
James, G., Witten, D., Hastie, T., Tibshirani, R. (2021). An Introduction to Statistical Learning. Springer.
Géron, A. (2022). Hands-On Machine Learning with Scikit-Learn, Keras & TensorFlow. O’Reilly Media.
Kuhn, M., Johnson, K. (2020). Feature Engineering and Selection: A Practical Approach for Predictive Models. CRC Press.
Bishop, C. M. (2006). Pattern Recognition and Machine Learning. Springer.
Provost, F., Fawcett, T. (2013). Data Science for Business. O’Reilly Media.