-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathclassification.py
More file actions
53 lines (37 loc) · 1.37 KB
/
classification.py
File metadata and controls
53 lines (37 loc) · 1.37 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
from lda import ClassificationModel, Viewer, Info
from sklearn.tree import DecisionTreeClassifier
def classification():
##### PARAMETERS #####
path = 'Documents/PACI.csv'
info = Info()
info.data = 'ICAAD'
info.identifier = 'classification'
#targetFeature = 'Domestic.Violence.Manual'
targetFeature = 'Sexual.Assault'
droplist = ['Sexual.Assault.Manual', 'Unnamed: 0']
# droplist = ['Strength.of.SA', 'Sexual.Assault.Manual', 'Unnamed: 0']
# droplist = ['Unnamed: 0']
### PREPROCESSING ###
model = ClassificationModel(path, targetFeature, droplist)
# TO-DO: Consider symmetrie in age values
model.createNumericFeature('Age')
model.createNumericFeature('Court')
model.data.loc[model.data['Reconciliation_freq']=='False', 'Reconciliation_freq' ] = '0'
model.toNumeric('Reconciliation_freq')
model.cleanDataset()
### SELECT TEST AND TRAINING DATA ###
model.balanceDataset()
model.createTarget()
model.dropFeatures()
model.splitDataset(len(model.data)/2)
### CLASSIFICATION ###
classifier = DecisionTreeClassifier()
model.trainClassifier(classifier)
model.predict(classifier)
### EVALUATION ###
model.evaluate()
model.confusionMatrix()
model.featureImportance()
Viewer(info).classificationResults(model)
if __name__ == "__main__":
classification()