-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtutoriel.py
56 lines (40 loc) · 1.75 KB
/
tutoriel.py
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
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
from sklearn.preprocessing import StandardScaler
from sklearn.cross_validation import train_test_split
from sklearn import svm
data = pd.read_csv('resources/training_dat.csv')
test_well = data[data['Well Name'] == 'SHANKLE'] #Well = puit -> nom du puit, pour tester le machine learning
data = data[data['Well Name'] != 'SHANKLE'] #Pour le machine learning
#print(data)
# Extraction du vecteur features composés des colonnes
features = ['GR', 'ILD_log10', 'DeltaPHI', 'PHIND', 'PE', 'NM_M', 'RELPOS']
features_vectors = data[features]
facies_labels = data['Facies']
#print(facies_labels)
# Affichage d'un crossplots
sns.pairplot(features_vectors[['GR', 'ILD_log10', 'DeltaPHI', 'PHIND', 'PE']])
plt.show()
# Faire devenir les echantillons gaussiens (moyenne nulle, variance 1)
"""
scaler = StandardScaler().fit(features_vectors)
scaled_feature = scaler.transform(features_vectors)
"""
# Préparer la cross-validation
x_train, x_cv, y_train, y_cv = train_test_split(scaled_feature, facies_labels, test_size=0.05, random_state=10)
# Paramétrage de la machine
clf = svm.SVC(C=10, gamma=1)
# Apprentissage
clf.fit(x_train, y_train)
#TODO voir ce qu'on fait avec x_cv et y_cv
# On normalise les données de test
y_test = test_well['Facies']
well_features = test_well.drop(['Facies', 'Formation', 'Well Name', 'Depth'], axis=1) # On retire les colonnes en param, on aurait pu utiliser l15-l16
x_test = scaler.transform(well_features)
# On prédit y
y_pred = clf.predict(x_test)
test_well['Prediction'] = y_pred
from sklearn.metrics import classification_report
target_names = ['SS', 'CSiS', 'FSiS', 'SiSh', 'MS', 'WS', 'D', 'PS', 'BS']
print(classification_report(y_test, y_pred, target_names=target_names))