You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Francois Pelletier 4db05d2b0e Mise à jour de 'README.md' 3 months ago
LICENSE Initial commit 3 months ago
README.md Mise à jour de 'README.md' 3 months ago

README.md

Installer OpenJDK8

apt-get install openjdk-8-jdk-headless

Installer Tomcat

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install tomcat8

Documentation et outils

sudo apt-get install tomcat8-docs tomcat8-admin tomcat8-examples

Ajouter un utilisateur

nano /var/lib/tomcat8/conf/tomcat-users.xml
<!-- 
<role rolename="manager-gui"/>
<user username="tomcat" password="tomcat" roles="manager-gui"/>
--!>

Modifier la configuration de Tomcat pour la taille du serveur

sudo nano /etc/default/tomcat8

<!-- 
JAVA_OPTS="-Djava.security.egd=file:/dev/./urandom -Djava.awt.headless=true -Xmx128m -XX:MaxPermSize=64m -XX:+UseConcMarkSweepGC"
--!>

sudo service tomcat8 restart

Installer Maven

sudo apt-get install maven

Télécharger et compiler OpenScoring

mkdir apps
cd apps

git clone https://github.com/openscoring/openscoring.git
cd openscoring/
mvn clean install

cp /root/apps/openscoring/openscoring-webapp/target/openscoring-webapp-1.2-SNAPSHOT.war /var/lib/tomcat8/webapps/openscoring.war

Aller à http://localhost:8080/manager et démarrer l'application OpenScoring

Tester l'application http://localhost:8080/openscoring/model/

Installer R

sudo apt-get install build-essential libcurl4-openssl-dev r-base-dev libssl-dev
sudo apt-get install libxml2-dev
sudo apt-get install r-base r-recommended
sudo apt-get install libgfortran-5-dev

Ouvrir R

R

Installer les devtools et pmml

install.packages("pmml")
install.packages("randomForest")
q()

Télécharger les données

mkdir ~/data
cd ~/data
mkdir abalone
cd abalone

wget https://archive.ics.uci.edu/ml/machine-learning-databases/abalone/abalone.data
wget https://archive.ics.uci.edu/ml/machine-learning-databases/abalone/abalone.names

Construire le modèle

Ouvrir R

R

Charger les librairies

library("pmml")
library("randomForest")

Construire le modèle

abalone <- read.csv("~/data/abalone/abalone.data", header=FALSE)
names(abalone) <- c("Sex","Length","Diam","Height","Whole","Shucked","Viscera","Shell","Rings")
model1 <- randomForest(Rings ~ ., data = abalone, ntree = 7)

Exporter en PMML

saveXML(pmml(model1), file="/root/data/abalone/model1.pmml")
q()

Mettre le PMML en production

curl -X PUT --data-binary @model1.pmml -H "Content-type: text/xml" http://localhost:8080/openscoring/model/model1

Vérifier la présence du modèle

curl -X GET http://localhost:8080/openscoring/model

Appeler le modèle

nano exemple.json
{
    "id" : "record-001",
    "arguments" : {
        "Sex" : "I",
        "Length" : 0.520,
        "Diam" : 0.380,
		"Height" : 0.135,
		"Whole" : 0.5395,
		"Shucked" : 0.2295,
		"Viscera" : 0.1330,
		"Shell" : 0.1570
    }
}
curl -X POST --data-binary @exemple.json -H "Content-type: application/json" http://localhost:8080/openscoring/model/model1