Skip to content

Commit a9bcf7c

Browse files
committed
Merge remote-tracking branch 'ColinTalbert/sahm_2_0' into SAHM_2_0
2 parents 1de15ee + a0aa9fa commit a9bcf7c

File tree

4 files changed

+55
-18
lines changed

4 files changed

+55
-18
lines changed

pySAHM/Resources/R_Modules/MAXENT.helper.fcts.r

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
read.maxent<-function(lambdas){
2-
32
lambdas <- read.csv(lambdas,header=FALSE)
43
normalizers<-lambdas[(nrow(lambdas)-3):nrow(lambdas),]
54
entropy<-normalizers[4,2]
65
lambdas<-lambdas[1:(nrow(lambdas)-4),]
7-
8-
fctType <- rep("raw",times=nrow(lambdas)-4)
6+
fctType <- rep("raw",times=nrow(lambdas))
97
fctType[grep("`",as.character(lambdas[,1]))] <- "reverse.hinge"
108
fctType[grep("'",as.character(lambdas[,1]))] <- "forward.hinge"
119
fctType[grep("\\^",as.character(lambdas[,1]))]<-"quadratic"

pySAHM/Resources/R_Modules/ResponseCurves/external/responseCurves.r

+3-2
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,11 @@ responseCurves<-function(fitLst,model,vals=NULL,varImp,addImp,pIdx){
3535
modelCycle<-1:length(fitLst)
3636
predCycle<-1:ncol(dat)
3737
if(byVar) predCycle <- pIdx
38-
for(j in modelCycle){
3938

39+
for(j in modelCycle){
40+
4041
allVarImp<-rep(0,times=ncol(dat))
41-
allVarImp[match(rownames(varImp[[j]]),names(dat))]<-as.vector(varImp[[j]][,1])
42+
allVarImp[match(names(varImp[[j]]),names(dat))]<-as.vector(varImp[[j]][1])
4243
allVarImp[allVarImp<0]<-0 #set the minimum to zero so it shows up white
4344
bgCol<-bgRamp[cut(x=allVarImp,breaks=seq(from=0,to=max(varImp[[j]]),length=11),include.lowest=TRUE)]
4445
for (pIdx in predCycle) {

pySAHM/Resources/R_Modules/Testing/QuickDebug.r

+47-9
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ FitModels(ma.name=input.file,
5252
'multicore=TRUE', 'om=2', 'maxent_path=K:\\USERS\\ISS\\VisTrails\\VisTrails2.1.2_SAHM_x64_1.2.0\\Central_Maxent', 'species_name=species', 'cur_processing_mode=single models sequentially (n - 1 cores each)', 'c=J:\\Projects\\CNHPforJorge\\Maxent_WildParsnip_4\\CovariateCorrelationOutputMDS_WildParsnip_initial.csv', 'o=J:\\Projects\\CNHPforJorge\\Maxent_WildParsnip_4'
5353

5454

55-
lambdas.file="J:\\Projects\\CNHPforJorge\\Maxent_WildParsnip_4"
56-
input.file="J:\\Projects\\CNHPforJorge\\Maxent_WildParsnip_4\\CovariateCorrelationOutputMDS_WildParsnip_initial.csv"
55+
lambdas.file="J:\\Projects\\NASADevelop\\AK\\Elodea2\\Elodea_1\\Elodea_1\\Maxent_kdeContOpt_1"
56+
input.file="J:\\Projects\\NASADevelop\\AK\\Elodea2\\Elodea_1\\Elodea_1\\Maxent_kdeContOpt_1\\CovariateCorrelationOutputMDS_kdeContOpt_initial.csv"
5757

5858
FitModels(ma.name=input.file,
5959
output.dir=output.dir,
@@ -64,14 +64,26 @@ FitModels(ma.name=input.file,
6464
#================================================================#
6565
input.file = "J:\\Projects\\MojaveInvasives\\DerivedData\\AnalysisWith2000to2010base\\BRORUB20002010prism\\brt_1\\CovariateCorrelationOutputMDS_initial.csv"
6666
input.file = "I:\\VisTrails\\WorkingFiles\\workspace\\_yetAnotherTest\\brewersSparrow_presenceONLY\\mars_1\\CovariateCorrelationOutputMDS_initial.csv"
67-
input.file = "I:\\VisTrails\\WorkingFiles\\workspace\\_yetAnotherTest\\brewersSparrow_presenceONLY\\mars_1\\CovariateCorrelationOutputMDS_initial.csv"
6867

6968
FitModels(ma.name=input.file,
7069
tif.dir=NULL,output.dir=output.dir,
7170
response.col=rc,make.p.tif=F,make.binary.tif=F,
7271
mars.degree=1,mars.penalty=2,debug.mode=F,seed=123,
7372
script.name="mars",opt.methods=2,MESS=F,ScriptPath=ScriptPath)
74-
73+
74+
input.file = "C:\\temp\\SAHM_workspace\\WarnTesting\\SAHMTestingOutput\\brewersSparrow_justMaurerObs\\mars_asage_1\\CovariateCorrelationOutputMDS_asage_initial.csv"
75+
output.dir="C:\\temp\\SAHM_workspace\\MarsParameter"
76+
mars.penalty=seq(from=5,to=15)
77+
for(i in 1:length(mars.penalty)){
78+
output.diri<-paste(output.dir,mars.penalty[i],sep="_")
79+
dir.create(output.diri)
80+
FitModels(ma.name=input.file,
81+
tif.dir=NULL,output.dir=output.diri,
82+
response.col=rc,make.p.tif=F,make.binary.tif=F,
83+
mars.degree=1,mars.penalty=mars.penalty[i],debug.mode=F,seed=123,
84+
script.name="mars",opt.methods=2,MESS=F,ScriptPath=ScriptPath)
85+
}
86+
7587
#================================================================#
7688
# Evaluate New Data
7789
#================================================================#
@@ -111,13 +123,29 @@ input.file = "C:\\temp\\SAHM_workspace\\ForResponseCurveTool\\rf_1\\CovariateCor
111123
input.file="I:\\VisTrails\\WorkingFiles\\workspace\\_tutorial_2.0_testing\\brewersSparrow_justMaurerObs\\rf_asage_1\\CovariateCorrelationOutputMDS_asage_initial.csv
112124
input.file="I:\\VisTrails\\WorkingFiles\\workspace\\_clutteredWarnings\\brewersSparrow\\rf_1\\CovariateCorrelationOutputMDS_initial.csv"
113125
input.file="J:\\Projects\\NAS\\SAHM_output\\Pomacea\\rf_optimizedGastroBacks_1\\CovariateCorrelationOutputMDS_optimizedGastroBacks_initial.csv"
126+
input.file="I:\\VisTrails\\WorkingFiles\\workspace\\Tutorial_2.0_output\\brewersSparrow_justMaurerObs\\rf_asage_1\\CovariateCorrelationOutputMDS_asage_initial.csv"
114127
FitModels(ma.name=input.file,
115128
tif.dir=NULL,
116129
output.dir=output.dir,nodesize=NULL,maxnodes=NULL,sampsize=NULL,mtry=NULL,samp.replace=FALSE,keep.forest=NULL,xtest=NULL,ytest=NULL,
117130
response.col=rc,make.p.tif=F,make.binary.tif=F, localImp=FALSE,nPerm=1,proximity=NULL,n.trees=1000,keep.forest=NULL,
118131
keep.inbag=FALSE,
119132
debug.mode=T,opt.methods=2,script.name="rf",ScriptPath=ScriptPath,multCore=FALSE)
120133
134+
135+
#RF loop to select parameters
136+
input.file = "C:\\temp\\SAHM_workspace\\WarnTesting\\SAHMTestingOutput\\brewersSparrow_justMaurerObs\\mars_asage_1\\CovariateCorrelationOutputMDS_asage_initial.csv"
137+
output.dir="C:\\temp\\SAHM_workspace\\MarsParameter"
138+
n.trees=c(30,50,70,100,500)
139+
for(i in 1:length(n.trees)){
140+
output.diri<-paste(output.dir,i,sep="_")
141+
dir.create(output.diri)
142+
FitModels(ma.name=input.file,
143+
tif.dir=NULL,
144+
output.dir=output.dir,nodesize=NULL,maxnodes=NULL,sampsize=NULL,mtry=NULL,samp.replace=FALSE,keep.forest=NULL,xtest=NULL,ytest=NULL,
145+
response.col=rc,make.p.tif=F,make.binary.tif=F, localImp=FALSE,nPerm=1,proximity=NULL,n.trees=30,keep.forest=NULL,
146+
keep.inbag=FALSE,
147+
debug.mode=T,opt.methods=2,script.name="rf",ScriptPath=ScriptPath,multCore=FALSE)
148+
121149
C:\R-3.2.0\bin\i386\Rterm.exe --vanilla -f C:\GoogleDrive\Python\DevWorkspace\userpackages\sahm\pySAHM\Resources\R_Modules\FIT_RF_pluggable.r --args mbt=TRUE mpt=TRUE c="I:\VisTrails\\WorkingFiles\workspace\_clutteredWarnings\brewersSparrow\rf_1\CovariateCorrelationOutputMDS_initial.csv" o="C:\temp\SAHM_workspace\WarnTesting" rc=responseBinary mes=TRUE
122150
123151
rc="responseBinary"
@@ -127,17 +155,27 @@ rc="responseBinary"
127155
input.file="J:\Projects\NormalsComparison\SAHM4\AHB\MergedDataset_1.csv"
128156
input.file="I:\\VisTrails\\WorkingFiles\\workspace\\_ntr\\brt_BrewersSparrowCV_1\\CovariateCorrelationOutputMDS_BrewersSparrowCV_initial.csv"
129157
#input.file="I:\\VisTrails\\WorkingFiles\\workspace\\_FinalTest\\CovariateCorrelationOutputMDS_initial.csv"
130-
input.file="J:\\Projects\\MojaveInvasives\\DerivedData\\AnalysisWith2000to2010base\\BRORUB20002010prism\\brt_1\\CovariateCorrelationOutputMDS_initial.csv"
158+
input.file="J:\\Projects\\buffelgrass\\SNP\\HabitatSuitability\\SAHM\\CeCi\\BRT_OPT\\brt_finalmaps_4\\CovariateCorrelationOutputMDS_finalmaps_initial.csv"
159+
input.file="J:\\Projects\\NASADevelop\\AK\\Elodea2\\Elodea_1\\Revisions\\brt_First_1\\CovariateCorrelationOutputMDS_First_initial.csv"
160+
FitModels(ma.name=input.file,
161+
tif.dir=NULL,output.dir=output.dir,
162+
response.col=rc,make.p.tif=F,make.binary.tif=F,n.folds=3,simp.method="cross-validation",tc=NULL,alpha=1,
163+
family = "bernoulli",n.trees =NULL,tolerance.method = "auto",
164+
tolerance = 0.001,seed=1234,opt.methods=2,learning.rate=NULL,
165+
simp.method="cross-validation",debug.mode=T,responseCurveForm="pdf",script.name="brt",
166+
bag.fraction = 0.5,prev.stratify = TRUE, opt.methods=2,MESS=F,ScriptPath=ScriptPath,multCore=FALSE,predSelect=FALSE)
167+
168+
131169
maxTrees=c(25,50,75,100,150,NULL)
132170
output.dir="C:\\temp\\BRT"
133171
for(i in 1:length(maxTrees)){
134172
d<-file.path(output.dir,paste("brt",i,sep="_"))
135173
dir.create(d)
136174
FitModels(ma.name=input.file,
137-
tif.dir=NULL,output.dir=d,
138-
response.col=rc,make.p.tif=F,make.binary.tif=F,n.folds=3,simp.method="cross-validation",tc=NULL,alpha=1,
139-
family = "bernoulli",n.trees =maxTrees[i],tolerance.method = "auto",
140-
tolerance = 0.001,seed=1234,opt.methods=2,
175+
tif.dir=NULL,output.dir=output.dir,
176+
response.col=rc,make.p.tif=F,make.binary.tif=F,n.folds=3,simp.method="cross-validation",tc=1,alpha=1,
177+
family = "bernoulli",n.trees =NULL,tolerance.method = "auto",
178+
tolerance = 0.001,seed=1234,opt.methods=2,learning.rate=0.0005,
141179
simp.method="cross-validation",debug.mode=T,responseCurveForm="pdf",script.name="brt",
142180
bag.fraction = 0.5,prev.stratify = TRUE, opt.methods=2,MESS=F,ScriptPath=ScriptPath,multCore=FALSE,predSelect=FALSE)
143181
}

pySAHM/Resources/R_Modules/Testing/RunResponse.r

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ ChkLibs(list("gbm","randomForest","maptools","rgdal","shiny","leaflet","maptools
1717

1818

1919
wsLst<-list()
20-
wsLst[[1]]<-"C:\\temp\\SAHM_workspace\\ForResponseCurveTool\\brewersSparrow\\brt_1\\modelWorkspace"
21-
wsLst[[2]]<-"C:\\temp\\SAHM_workspace\\ForResponseCurveTool\\brewersSparrow\\glm_1\\modelWorkspace"
22-
wsLst[[3]]<-"C:\\temp\\SAHM_workspace\\ForResponseCurveTool\\brewersSparrow\\mars_1\\modelWorkspace"
23-
wsLst[[4]]<-"C:\\temp\\SAHM_workspace\\ForResponseCurveTool\\brewersSparrow\\rf_1\\modelWorkspace"
20+
wsLst[[1]]<-"C:\\temp\\SAHM_workspace\\ForResponseCurveTool\\brewersSparrow\\mars_1\\modelWorkspace"
21+
wsLst[[2]]<-"C:\\temp\\SAHM_workspace\\ForResponseCurveTool\\brewersSparrow\\rf_1\\modelWorkspace"
22+
wsLst[[3]]<-"C:\\temp\\SAHM_workspace\\ForResponseCurveTool\\brewersSparrow\\brt_1\\modelWorkspace"
23+
wsLst[[4]]<-"C:\\temp\\SAHM_workspace\\ForResponseCurveTool\\brewersSparrow\\glm_1\\modelWorkspace"
2424

2525
wsLst<-list()
2626
wsLst[[1]]<-"C:\\temp\\SAHM_workspace\\ForResponseCurveTool\\vespersSparrow\\brt_1\\modelWorkspace"

0 commit comments

Comments
 (0)