Recently Published
Intro to R Workshop by FAZR ma'am
Data Visualizations
Tugas Kelompok K1 Analisis Regresi
Pada analisis regresi linier sederhana ini, data yang digunakan diambil dari situs kaggle.com/dataset berupa penelitian terkait tingkat kebahagiaan di setiap negara atau wilayah pada tahun 2019, dengan variabel Y adalah skor tingkat kebahagiaan dan X adalah GDP per kapita
Plot ML together
Combine predictions into df
```{r}
predictions_df <- data.frame(
Actual = actual_values,
ANN = predictions_ann,
SVM = predictions_svm,
RF = predictions_rf,
KNN = predictions_knn,
LM = predictions_lm
)
# Convert to long format for plotting
predictions_long <- predictions_df %>%
pivot_longer(cols = c("ANN", "SVM", "RF", "KNN", "LM"), names_to = "Model", values_to = "Predicted")
```
Plot together
```{r}
ggplot(predictions_long, aes(x = Actual, y = Predicted, colour = Model)) +
geom_point() +
geom_abline(intercept = 0, slope = 1, linetype = "dashed") +
labs(title = "All Models: Actual vs Predicted", x = "Actual Life Expectancy", y = "Predicted Life Expectancy") +
theme_minimal() +
scale_colour_manual(values = c("blue", "green", "red", "purple", "orange"))
```
ML dataframe
```{r}
# Combine all predictions into a single data frame
predictions_df <- data.frame(
Actual = actual_values,
ANN = predictions_ann,
SVM = predictions_svm,
RF = predictions_rf,
KNN = predictions_knn,
LM = predictions_lm
)
```
Convert to long for plot
```{r}
# Convert to long format for plotting
predictions_long <- predictions_df %>%
pivot_longer(cols = -Actual, names_to = "Model", values_to = "Predicted")
```
## Plot all together:
```{r}
# Plot all models together
ggplot(predictions_long, aes(x = Actual, y = Predicted, colour = Model)) +
geom_point() +
geom_abline(intercept = 0, slope = 1, linetype = "dashed") +
labs(title = "All Models: Actual vs Predicted", x = "Actual Life Expectancy", y = "Predicted Life Expectancy") +
theme_minimal() +
scale_colour_manual(values = c("blue", "green", "red", "purple", "orange"))
```