Mercurial > repos > anmoljh > rcaret_classification_model
comparison modelBuilding.py @ 0:2cb81da69c73 draft
planemo upload commit a1f4dd8eb560c649391ada1a6bb9505893a35272
author | anmoljh |
---|---|
date | Thu, 31 May 2018 11:58:59 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:2cb81da69c73 |
---|---|
1 def __inputArguments(): | |
2 | |
3 import argparse | |
4 parser = argparse.ArgumentParser() | |
5 | |
6 parser.add_argument("--method", nargs='?',default ='pls',help="Name of the method on which model will build; \ | |
7 Available Methods are:- pls, glm , glmboost ") | |
8 parser.add_argument("rdata",help="Descriptor file for model building") | |
9 parser.add_argument("--getdatainfoeval",nargs='?',default='TRUE',help="Validation of the data ") | |
10 parser.add_argument("--getdatainfoecho",nargs='?',default='FALSE',help="print on consol about Validity of the data ") | |
11 parser.add_argument("--getdatainforesult",nargs='?',default='hide',help="print in output file about Validity of the data ") | |
12 parser.add_argument("--missingfiltereval",nargs='?',default='FALSE',help="Processing step :: removal of missing value ") | |
13 parser.add_argument("--missingfilterecho",nargs='?',default='FALSE',help="print Processing step :: removal of missing value ") | |
14 parser.add_argument("--missingfilterresult",nargs='?',default='hide',help="print in output file about Processing step :: removal of missing value ") | |
15 parser.add_argument("--missingfilterthreshc",nargs='?',default=0.20,type=float,help="info about highly missing column data") | |
16 parser.add_argument("--missingfilterthreshr",nargs='?',default=0.20,type=float,help="info about highly missing row number") | |
17 parser.add_argument("--pcaeval",nargs='?',default='FALSE',help="PCA of data ") | |
18 parser.add_argument("--pcaecho",nargs='?',default='FALSE',help="PCA of data ") | |
19 parser.add_argument("--pcaresult",nargs='?',default='hide',help="print in file about PCA of data ") | |
20 parser.add_argument("--pcacomp",nargs='?',default=3,type=int,help="Number of PCA componant will be plotted ") | |
21 parser.add_argument("--pcaploteval",nargs='?',default='FALSE',help="PCA plot of data ") | |
22 parser.add_argument("--pcaplotecho",nargs='?',default='FALSE',help="print PCA plot of data ") | |
23 parser.add_argument("--pcaplotresult",nargs='?',default='hide',help="write in output file about PCA plot of data") | |
24 parser.add_argument("--pcaplotfig",nargs='?',default='TRUE',help="make figure file for integration in output file") | |
25 parser.add_argument("--initialdataspliteval",nargs='?',default='TRUE',help="data splitting in test and train set ") | |
26 parser.add_argument("--initialdatasplitecho",nargs='?',default='FALSE',help="print about data splitting in test and train set") | |
27 parser.add_argument("--initialdatasplitresult",nargs='?',default='hide',help="write in outputfile about data splitting in test and train set") | |
28 parser.add_argument("--saampling",nargs='?',default="garBage",help="Perform sampling from data") | |
29 parser.add_argument("--percent",nargs='?',default=0.8,type=float,help="percent value at which data splitting is done") | |
30 parser.add_argument("--nzveval",nargs='?',default='FALSE',help="remove near zero values") | |
31 parser.add_argument("--nzvresult",nargs='?',default='hide',help="write in outputfile about removing near zero values") | |
32 parser.add_argument("--nzvecho",nargs='?',default='FALSE',help="print about removing near zero values") | |
33 parser.add_argument("--corrfiltereval",nargs='?',default='FALSE',help="remove higly correlated values") | |
34 parser.add_argument("--corrfilterresult",nargs='?',default='hide',help="write in outputfile about removing highly correlated values") | |
35 parser.add_argument("--corrfilterecho",nargs='?',default='FALSE',help="print about removing correlated values") | |
36 parser.add_argument("--threshholdcor",nargs='?',default=0.75,type=float,help="percent value at which correlated values ommitted ") | |
37 parser.add_argument("--preproceval",nargs='?',default='FALSE',help="pre proccesing") | |
38 parser.add_argument("--preprocecho",nargs='?',default='FALSE',help="print about pre proccesing") | |
39 parser.add_argument("--preprocresult",nargs='?',default='hide',help="write in output file about pre proccesing") | |
40 parser.add_argument("--setupworkersecho",nargs='?',default='FALSE',help="print about number of processors") | |
41 parser.add_argument("--setupworkersresult",nargs='?',default='tex',help="write about number of processors in output file") | |
42 parser.add_argument("--numworkers",nargs='?',default=1,type=int,help="defines used processors") | |
43 parser.add_argument("--setupresamplingecho",nargs='?',default='FALSE',help="print resampling rules") | |
44 parser.add_argument("--setupresamplingresult",nargs='?',default='hide',help="write resampling rules in output file") | |
45 parser.add_argument("--resampname",nargs='?',default='boot632',help="choose type of resampling") | |
46 parser.add_argument("--resamplenumber",nargs='?',default=10,type=int,help="set number of resampling") | |
47 parser.add_argument("--numrepeat",nargs='?',default=3,type=int,help="set times of repeat") | |
48 parser.add_argument("--resamplenumberpercent",nargs='?',default=0.75,type=float,help="set PERCENT resampling") | |
49 parser.add_argument("--setupgridresult",nargs='?',default='hide',help="write about number of grids in output file") | |
50 parser.add_argument("--setupgridecho",nargs='?',default='FALSE',help="print about number of grids") | |
51 parser.add_argument("--setupgridsize",nargs='?',default=3,type=int,help="set number of grids") | |
52 parser.add_argument("--fitmodelresult",nargs='?',default='hide',help="write about model") | |
53 parser.add_argument("--fitmodelecho",nargs='?',default='FALSE',help="print about model") | |
54 parser.add_argument("--fitmodeleval",nargs='?',default='TRUE',help="start model building") | |
55 parser.add_argument("--modeldescrecho",nargs='?',default='FALSE',help="print model description") | |
56 parser.add_argument("--modeldescrresult",nargs='?',default='hide',help="write model description in outout file") | |
57 parser.add_argument("--resamptableecho",nargs='?',default='FALSE',help="print resample table") | |
58 parser.add_argument("--resamptableresult",nargs='?',default='tex',help="write resample table in output file") | |
59 parser.add_argument("--profileplotecho",nargs='?',default='FALSE',help="print about profile plots") | |
60 parser.add_argument("--profileplotfig",nargs='?',default='TRUE',help=" profile plots") | |
61 parser.add_argument("--stopworkersecho",nargs='?',default='FALSE',help="stop workers ie processors") | |
62 parser.add_argument("--stopworkersresult",nargs='?',default='hide',help="write about workers ie processors used") | |
63 parser.add_argument("--testpredresult",nargs='?',default='tex',help="write about statistical measure") | |
64 parser.add_argument("--testpredecho",nargs='?',default='FALSE',help="print about statistical measure") | |
65 parser.add_argument("--classprobstexresult",nargs='?',default='tex',help="paste various figure of statistical measure in outputfile") | |
66 parser.add_argument("--classprobstexecho",nargs='?',default='FALSE',help="print various figure of statistical measure") | |
67 parser.add_argument("--classprobstexresult1",nargs='?',default='hide',help="create roc curve in outputfile") | |
68 parser.add_argument("--classprobstexecho1",nargs='?',default='FALSE',help="print figure of statistical measure") | |
69 parser.add_argument("--savedataecho",nargs='?',default='FALSE',help="information about completion of model building ") | |
70 parser.add_argument("--savedataresult",nargs='?',default='hide',help="write information about completion of model building in outputfile ") | |
71 parser.add_argument("--datasets", help="name of the generated datasets") | |
72 parser.add_argument("--outputmodel", help="give name for the generated model") | |
73 parser.add_argument("--outputresultpdf", help="give name for the output pdf file") | |
74 | |
75 args = parser.parse_args() | |
76 return args | |
77 | |
78 def generateRnwScript(): | |
79 | |
80 import templateLibrary | |
81 t = templateLibrary.__template4Rnw() | |
82 | |
83 from string import Template | |
84 s = Template(t) | |
85 | |
86 args = __inputArguments() | |
87 | |
88 templt = s.safe_substitute(METHOD=args.method, | |
89 RDATA=args.rdata, | |
90 GETDATAINFOEVAL=args.getdatainfoeval, | |
91 GETDATAINFOECHO=args.getdatainfoecho, | |
92 GETDATAINFORESULT=args.getdatainforesult, | |
93 MISSINGFILTEREVAL=args.missingfiltereval, | |
94 MISSINGFILTERECHO=args.missingfilterecho, | |
95 MISSINGFILTERRESULT=args.missingfilterresult, | |
96 MISSINGFILTERTHRESHC=args.missingfilterthreshc, | |
97 MISSINGFILTERTHRESHR=args.missingfilterthreshr, | |
98 PCAEVAL=args.pcaeval, | |
99 PCAECHO=args.pcaecho, | |
100 PCARESULT=args.pcaresult, | |
101 PCACOMP=args.pcacomp, | |
102 PCAPLOTEVAL=args.pcaploteval, | |
103 PCAPLOTECHO=args.pcaplotecho, | |
104 PCAPLOTRESULT=args.pcaplotresult, | |
105 PCAPLOTFIG=args.pcaplotfig, | |
106 INITIALDATASPLITEVAL=args.initialdataspliteval, | |
107 INITIALDATASPLITECHO=args.initialdatasplitecho, | |
108 INITIALDATASPLITRESULT=args.initialdatasplitresult, | |
109 SAAMPLING=args.saampling, | |
110 PERCENT=args.percent, | |
111 NZVEVAL=args.nzveval, | |
112 NZVRESULT=args.nzvresult, | |
113 NZVECHO=args.nzvecho, | |
114 CORRFILTEREVAL=args.corrfiltereval, | |
115 CORRFILTERRESULT=args.corrfilterresult, | |
116 CORRFILTERECHO=args.corrfilterecho, | |
117 THRESHHOLDCOR=args.threshholdcor, | |
118 PREPROCEVAL=args.preproceval, | |
119 PREPROCECHO=args.preprocecho, | |
120 PREPROCRESULT=args.preprocresult, | |
121 SETUPWORKERSECHO=args.setupworkersecho, | |
122 SETUPWORKERSRESULT=args.setupworkersresult, | |
123 NUMWORKERS=args.numworkers, | |
124 SETUPRESAMPLINGECHO=args.setupresamplingecho, | |
125 SETUPRESAMPLINGRESULT=args.setupresamplingresult, | |
126 RESAMPNAME=args.resampname, | |
127 RESAMPLENUMBER=args.resamplenumber, | |
128 NUMREPEAT=args.numrepeat, | |
129 RESAMPLENUMBERPERCENT=args.resamplenumberpercent, | |
130 SETUPGRIDRESULT=args.setupgridresult, | |
131 SETUPGRIDECHO=args.setupgridecho, | |
132 SETUPGRIDSIZE=args.setupgridsize, | |
133 FITMODELRESULT=args.fitmodelresult, | |
134 FITMODELECHO=args.fitmodelecho, | |
135 FITMODELEVAL=args.fitmodeleval, | |
136 MODELDESCRECHO=args.modeldescrecho, | |
137 MODELDESCRRESULT=args.modeldescrresult, | |
138 RESAMPTABLEECHO=args.resamptableecho, | |
139 RESAMPTABLERESULT=args.resamptableresult, | |
140 PROFILEPLOTECHO=args.profileplotecho, | |
141 PROFILEPLOTFIG=args.profileplotfig, | |
142 STOPWORKERSECHO=args.stopworkersecho, | |
143 STOPWORKERSRESULT=args.stopworkersresult, | |
144 TESTPREDRESULT=args.testpredresult, | |
145 TESTPREDECHO=args.testpredecho, | |
146 CLASSPROBSTEXRESULT=args.classprobstexresult, | |
147 CLASSPROBSTEXECHO=args.classprobstexecho, | |
148 CLASSPROBSTEXRESULT1=args.classprobstexresult1, | |
149 CLASSPROBSTEXECHO1=args.classprobstexecho1, | |
150 SAVEDATAECHO=args.savedataecho, | |
151 SAVEDATARESULT=args.savedataresult ) | |
152 | |
153 | |
154 f = open('result-doc.Rnw','w') | |
155 f.write(templt) | |
156 f.close() | |
157 | |
158 def modelBuilding(): | |
159 | |
160 import os | |
161 os.system('R CMD Sweave result-doc.Rnw > cmd.log.1 2>&1') | |
162 os.system('R CMD pdflatex result-doc.tex > cmd.log.2 2>&1') | |
163 os.system('R CMD pdflatex result-doc.tex > cmd.log.2 2>&1') | |
164 args = __inputArguments() | |
165 | |
166 from string import Template | |
167 s1 = Template('cp $METHOD-Fit.RData $OUTPUTMODEL') | |
168 s2 = Template('cp result-doc.pdf $OUTPUTRESULTPDF') | |
169 s3 = Template('cp datasets.RData $DATASETS') | |
170 | |
171 cmd1 = s1.safe_substitute(METHOD=args.method, OUTPUTMODEL=args.outputmodel) | |
172 cmd2 = s2.safe_substitute(OUTPUTRESULTPDF=args.outputresultpdf) | |
173 cmd3 = s3.safe_substitute(DATASETS=args.datasets) | |
174 | |
175 os.system(cmd1) | |
176 os.system(cmd2) | |
177 os.system(cmd3) | |
178 | |
179 if __name__ == "__main__" : | |
180 | |
181 generateRnwScript() | |
182 modelBuilding() |