-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmpml2.py
72 lines (55 loc) · 2.63 KB
/
mpml2.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import Perspective as pr
import Learn as lr
import Analyse as alz
import DrawGraph as dr
class mpml:
def __init__(self,base_classifier,dataFrame,target,max_perspectives=0,sig=False,perspectiveList=[]):
self.max_perspectives = max_perspectives
self.sig = sig #Significant change value
self.base_classifier = base_classifier #The algo that will create the base classifiers
self.dataFrame = dataFrame
self.target = target
self.perspectiveList = perspectiveList
self.clf_name = self.base_classifier.__class__.__name__
#Calcualte the significant change value
def calc_sig(self):
pr.sigValCsv(self.dataFrame,self.target)
#Generate relationship scores between features
def gen_relation_scores(self):
pr.generateRelations(self.dataFrame,self.target)
#Generate perspectives
def gen_perspectives(self):
self.perspectiveList = pr.generatePerspectives(self.dataFrame,self.target)
#Generate custom perspectives
def gen_custom_perspectives(self, custom_perspective_list):
self.perspectiveList = pr.generatePerspectives(self.dataFrame,self.target,custom_perspective_list)
#Train a modle on each perspective created
def train_perspectives(self):
lr.MPML(self.dataFrame,self.base_classifier,self.perspectiveList,self.target,1,"Name")
#Prints out th list of all features in the dataset
def list_features(self):
print(pr.viewFeatures(self.dataFrame,self.target))
#Prints out a list of all perspectives generated by this instance
def view_perspectives(self):
print(self.perspectiveList)
#Generates an analysis report for a single instance
def analyse_inst(self,inst):
alz.analysePerspective(self.dataFrame,self.target,inst,self.base_classifier,self.base_classifier.__class__.__name__,"Data",False)
#Generates an analysis report for a list instances
def analyse_inst_list(self,instList):
for inst in instList:
alz.analysePerspective(self.dataFrame,self.target,inst,self.base_classifier,self.clf_name,"Data",False,self.perspectiveList)
dr.quad_plot(instList,self.clf_name)
#List of Methods
#analye a particular instance
# analyse_inst()
# #if they want to control truon test and returen score on spcific inourt
# fit()
# score()
# #get the modles created from each perspective
# get_models()
# #get_acuracy on each perspective
# get_models_score()
# #functon to set custom persspectives
# set_perspectives()
# train_custom_perspeectives()