-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTask3.R
More file actions
118 lines (98 loc) · 4.03 KB
/
Copy pathTask3.R
File metadata and controls
118 lines (98 loc) · 4.03 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#librerie
library("FactoMineR")
library("factoextra")
#lettura dei dati flows.csv
data<- read.csv('flows/flows1.csv')
data.pca <- prcomp(data, scale=TRUE)
data.pca
#biplot
fviz_pca_var(data.pca, col.var = "black",
title="Biplot variables - scale = TRUE")+
theme(plot.title = element_text(hjust = 0.5),
aspect.ratio = 4/4,) +
expand_limits(x=c(-1.12,1.12), y=c(-1.12,1.12))
# coord_cartesian(xlim = c(-1.1,1.1))
# 1
# VARIABILI CORRELATE: Bwd.Packet.Length.Std - Average.Packet.Size
x<-data$Bwd.Packet.Length.Std
y<-data$Average.Packet.Size
plot(x, y, pch=20, xlab = ("Bwd.Packet.Length.Std"), ylab=("Average.Packet.Size"),
main=("Linear fitting: 95% regression confidence and prediction intervals"))
# 2
# VARIABILI CORRELATE: Total.Length.of.Bwd.Packet - Total.Fwd.Packet
x<-data$Total.Length.of.Bwd.Packet
y<-data$Total.Fwd.Packet
plot(x, y, pch=20, xlab = ("Total.Length.of.Bwd.Packet"), ylab=("Total.Fwd.Packet"),
main=("Linear fitting: 95% regression confidence and prediction intervals"))
# 3
# VARIABILI CORRELATE: Fwd.IAT.Std - Flow.Duration
x<-data$Fwd.IAT.Std
y<-data$Flow.Duration
plot(x, y, pch=20, xlab = ("Fwd.IAT.Std"), ylab=("Flow.Duration"),
main=("Linear fitting: 95% regression confidence and prediction intervals"))
# 4
# VARIABILI CORRELATE: Total.TCP.Flow.Time - Fwd.IAT.Std
x<-data$Total.TCP.Flow.Time
y<-data$Fwd.IAT.Std
plot(x, y, pch=20, xlab = ("Total.TCP.Flow.Time "), ylab=("Fwd.IAT.Std"),
log="xy",
main=("Linear fitting: 95% regression confidence and prediction intervals"))
# 5
# VARIABILI CORRELATE: Total.TCP.Flow.Time - Flow.Duration
x<-data$Total.TCP.Flow.Time
y<-data$Flow.Duration
plot(x, y, pch=20, xlab = ("Total.TCP.Flow.Time "), ylab=("Flow.Duration"),
log="xy",
main=("Linear fitting: 95% regression confidence and prediction intervals"))
# 6
# VARIABILI ANTICORRELATE: Bwd.Packet.Length.Std - Total.TCP.Flow.Time
x<-data$Bwd.Packet.Length.Std
y<-data$Total.TCP.Flow.Time
plot(x, y, pch=20, xlab = ("Bwd.Packet.Length.Std "), ylab=("Total.TCP.Flow.Time"),
ylim=c(-1e10,3e10),
main=("Linear fitting: 95% regression confidence and prediction intervals"))
# 7
# VARIABILI ANTICORRELATE: Average.Packet.Size - Total.TCP.Flow.Time
x<-data$Average.Packet.Size
y<-data$Total.TCP.Flow.Time
plot(x, y, pch=20, xlab = ("Average.Packet.Size "), ylab=("Total.TCP.Flow.Time"),
ylim=c(-1e10,3e10),
main=("Linear fitting: 95% regression confidence and prediction intervals"))
# 8
# VARIABILI ANTICORRELATE: Fwd.IAT.Std - Flow.Bytes.s
x<-data$Fwd.IAT.Std
y<-data$Flow.Bytes.s
plot(x, y, pch=20, xlab = ("Fwd.IAT.Std "), ylab=("Flow.Bytes.s"),
ylim=c(-1e7,1.5e8),
main=("Linear fitting: 95% regression confidence and prediction intervals"))
# 9
# VARIABILI ANTICORRELATE: Flow.Duration - Flow.Bytes.s
x<-data$Flow.Duration
y<-data$Flow.Bytes.s
plot(x, y, pch=20, xlab = ("Flow.Duration "), ylab=("Flow.Bytes.s"),
ylim=c(-1e7,1.5e8),
main=("Linear fitting: 95% regression confidence and prediction intervals"))
# 10
# VARIABILI ANTICORRELATE: Total.Fwd.Packet - Flow.Bytes.s
x<-data$Total.Fwd.Packet
y<-data$Flow.Bytes.s
plot(x, y, pch=20, xlab = ("Total.Fwd.Packet "), ylab=("Flow.Bytes.s"),
#ylim=c(-1e7,1.5e8),
log="xy",
main=("Linear fitting: 95% regression confidence and prediction intervals"))
l_mod<-lm(y~x)
lines(x,predict(l_mod), col="red", lwd=2)
# Coefficiente di determinazione
R2<-summary(l_mod)$r.squared
R2
c_int<- predict(l_mod, level = 0.95, interval="confidence")
p_int<- predict(l_mod, level = 0.95, interval="prediction")
#plot(x, y, pch=20, xlab = ("Bwd.Packet.Length.Std"), ylab=("Average.Packet.Size"))
lines(x,predict(l_mod), col="red", lwd=2)
lines(x, c_int[,2], type="o", lty=2, col="blue")
lines(x, c_int[,3], type="o", lty=2, col="blue")
lines(x, p_int[,2], type="o", lty=2, col="green")
lines(x, p_int[,3], type="o", lty=2, col="green")
legend( x="right",
legend=c("Linear fitting", "Confidence intervals", "Prediction intervals"),
col=c("red","blue", "green"), lwd=1, cex=0.7)