-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathprojet.Rmd
More file actions
79 lines (61 loc) · 1.84 KB
/
projet.Rmd
File metadata and controls
79 lines (61 loc) · 1.84 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
---
title: "R Notebook"
output: html_notebook
---
```{r}
library(dplyr)
```
```{r}
players=read.csv("FIFA.csv")
players_2=players[,c("Position","Crossing", "Finishing","Heading.Accuracy","Short.Passing", "Volleys", "Dribbling", "Curve", "FK.Accuracy","Long.Passing", "Ball.Control", "Acceleration", "Sprint.Speed","Agility","Reactions","Balance","Shot.Power","Jumping", "Stamina","Strength","Long.Shots", "Aggression", "Interceptions", "Positioning","Vision","Penalties", "Composure", "Defensive.Awareness", "Standing.Tackle", "Sliding.Tackle")]
colnames(players_2)
```
```{r}
players_2
```
```{r}
Attack=c("LW", "LF", "RW","RF", "CF", "ST", "CAM")
Defense=c("RB", "RWB", "LB", "LWB", "CB")
index_attack=which(players_2$Position %in%(Attack))
index_attack
players_2[index_attack, "Position"]="A"
players_2
index_defense=which(players_2$Position %in%(Defense))
index_defense
players_2[index_defense, "Position"]="D"
players_2=players_2[c(index_attack,index_defense),]
players_2
```
Séparation en jeu de données test et validation
```{r}
n=length(players_2[,1])
len.app=as.integer(3*n/4)
tirage=sample(seq(1,n),len.app, replace=FALSE)
train=players_2[tirage,]
x_train= train[,2:length(train[1,])]
y_train= train[,1]
test=players_2[-tirage,]
x_test= test[,2:length(test[1,])]
y_test= test[,1]
```
```{r}
#install.packages("keras")
library(keras)
```
```{r}
single_perceptron<-function(activation='sigmoid'){
model = tf.keras.Sequential()
model %>% layers_dense(1, activation=activation, input_shape=(length(x_train[,1],)))
return(model)
}
```
## SVM
On considère les données sont non-séparables
```{r}
library(e1071)
```
```{r}
svm_player <- train
svm_player$Position <- as.factor(svm_player$Position)
mod.svm.lin = svm(Position~.,data=svm_player,kernel="linear",cost=1)
plot(mod.svm.lin,data = svm_player, Crossing~Finishing)