我在R中运行MaxEnt时遇到了一些问题。我不断收到两条错误消息:
#MaxEnt (Maximum Entropy) Modeling is a species distribution model and machine-learning technique
#The package "dismo" calls in the java program.
#The package "maxnet" is an R-based Maxent implementation that uses glmnet with regularization to approximate the fit of maxent.jar
#The packages "raster" and "sp" are also required to run the model.
library(dismo)
library(maxnet)
library(raster)
library(sp)
#Load the Data
KCStatic = read.csv(file="D:/KCs3.csv", row.names="ID")
#Need to partition 'training dataset' and 'validation dataset'
KCwoT.Tng<-subset(KCStatic, Valid==0)
KCwoT.Val<-subset(KCStatic, Valid==1)
pvtest<-KCwoT.Val[KCwoT.Val[,1] == 1, 2:7]
avtest<-KCwoT.Val[KCwoT.Val[,1] == 0, 2:7]
#MaxEnt Model
KCwoT.ME.x<-KCwoT.Tng[,2:7]
KCwoT.ME.p<-KCwoT.Tng[,1]
KCwoT.ME<-maxent(KCwoT.ME.x,KCwoT.ME.p)
KCwoT.ME
KCwoT.ME.testp <- predict(KCwoT.ME, pvtest)
KCwoT.ME.testa <- predict(KCwoT.ME, avtest)
KCwoT.ME.eval <- evaluate(p=KCwoT.ME.testp, a=KCwoT.ME.testa)
KCwoT.ME.eval
#10 fold x validation:
xVal<- subset(KCwoT.Tng, select = c(ag, cent, jor, kliv, traw, silt))
k <- 10
group <- kfold(xVal, k)
e <- list()
for (i in 1:k) {
train <- xVal[group != i,]
test <- xVal[group == i,]
trainx<- train[,2:length(xVal)]
trainp<- train[,1]
me <- maxent(trainx,trainp)
testxp<-test[test[,1] == 1,2:length(xVal)]
testxa<-test[test[,1] == 0,2:length(xVal)]
testp <- predict(me, testxp)
testa <- predict(me, testxa)
e[[i]] <- evaluate(p=testp, a=testa)
}
mean(sapply( e, function(x){slot(x, 'auc')} ))
median(sapply( e, function(x){slot(x, 'auc')} ))
mean(sapply( e, function(x){slot(x, 'cor')} ))
median(sapply( e, function(x){slot(x, 'cor')} ))
KCwoT.ME.eval@TPR[match(threshold(KCwoT.ME.eval)[2],KCwoT.ME.eval@t)]
KCwoT.ME.eval@TNR[match(threshold(KCwoT.ME.eval)[2],KCwoT.ME.eval@t)]
KCwoT.ME.eval@CCR[match(threshold(KCwoT.ME.eval)[2],KCwoT.ME.eval@t)]
我对R有点新手并不确定这些错误消息的含义。列都具有相同的行数,并且没有非数字数据。任何帮助将不胜感激。我已经包含了数据和R脚本。感谢您的时间和任何帮助 -
s3_Pa ag cent jor kliv traw silt ID Valid
0 2712.814007 5944.620219 7664 7545 0 0 3174 0
0 2732.815985 5646.817407 7527 7516 0 0 3221 0
0 5383.266705 5383.266705 7970 7970 0 0 3230 0
0 4857.46024 6259.344198 7726 5781 0 0 3300 0
0 8352.51324 8352.51324 7198 7198 0 0 3356 0
0 49378.96152 16984.2808 12172 7890 0 0 3415 0
0 4319.437464 4319.437464 6297 6297 0 0 3461 0
0 9444.516272 9444.516272 7394 7394 0 0 3552 0
0 3589.880714 3265.163078 6131 5188 0 0 3605 0
0 28749.74389 28749.74389 6466 6466 0 0 3653 0
0 6959.890193 4073.928736 5213 5412 0 0 3764 0
0 5118.247173 3272.811018 4705 4705 0 0 3829 0
0 2559.80507 3984.939677 4965 5422 0 0 3857 0
0 5189.140315 5189.140315 4864 4864 0 0 3903 0
0 2243.265175 2513.775258 5407 5285 0 0 3942 0
0 2798.840052 2798.840052 5284 5284 0 0 3943 0
0 3049.900227 3049.900227 5044 5044 0 0 4034 0
0 5314.032326 5314.032326 5336 5336 0 0 4049 0
0 2416.851993 2483.681392 4529 4204 0 0 4093 0
0 2527.316522 2527.316522 4898 4898 0 0 4199 0
0 2281.407824 2281.407824 4848 4848 0 0 4216 0
0 2257.802423 2257.802423 4873 4873 0 0 4285 0
0 2678.746278 2678.746278 5137 5137 0 0 4360 0
0 2319.915204 2319.915204 5138 5138 0 0 4362 0
0 3516.384174 3516.384174 4725 4725 0 0 4557 0
0 2218.583063 2218.583063 4464 4464 0 0 4583 0
0 7433.978369 6832.621571 3963 5527 0 0 4586 0
0 2604.437581 2604.437581 4565 4565 0 0 4630 0
0 2372.751422 3930.504765 4787 5560 0 0 4739 0
0 2516.984733 7087.776431 4219 5885 0 0 4818 0
0 2437.56414 2437.56414 4596 4596 0 0 4825 0
0 2440.659167 2440.659167 4556 4556 0 0 4933 0
0 2416.905821 2416.905821 4540 4540 0 0 4942 0
0 2428.521085 2428.521085 4867 4867 0 0 5121 0
0 2463.594566 2463.594566 5125 5125 0 0 5196 0
0 2487.539855 2487.539855 4803 4803 0 0 5249 0
0 3302.718352 3302.718352 4958 4958 0 0 5252 0
0 2605.906908 2605.906908 4846 4846 0 0 5332 0
0 2577.784698 2577.784698 5463 5463 0 0 5402 0
0 2764.191937 8861.087669 4848 6376 0 0 5494 0
0 2566.989482 2566.989482 4938 4938 0 0 5565 0
0 2592.787269 2592.787269 4889 4889 0 0 5626 0
0 2757.964558 2757.964558 5077 5077 0 0 5693 0
0 2620.543732 2620.543732 5216 5216 0 0 5769 0
0 5309.434576 5309.434576 5867 5867 0 0 5908 0
1 5921.125287 6881.922922 7736 7707 0 0 3217 0
1 2774.199514 21747.29759 7669 9197 0 0 3280 0
1 15495.78183 15495.78183 7826 7826 0 0 3307 0
1 2548.237657 4019.296229 7503 7421 0 0 3310 0
1 7666.402192 7666.402192 7501 7501 0 0 3342 0
1 4891.62472 4891.62472 7384 7384 0 0 3350 0
1 5042.36752 4343.180161 7456 7344 0 0 3373 0
1 5193.293844 5772.4049 7390 6359 0 0 3377 0
1 3534.172197 16711.2551 7446 7646 0 0 3423 0
1 14070.79994 14070.79994 7601 7601 0 0 3443 0
1 3255.725951 3255.725951 7345 7345 0 0 3450 0
1 4786.893258 4786.893258 6125 6125 0 0 3493 0
1 40210.85968 4484.216909 12105 5479 0 0 3517 0
1 4333.860544 4333.860544 7262 7262 0 0 3535 0
1 7795.332317 7795.332317 6679 6679 0 0 3542 0
1 3364.563525 3364.563525 6608 6608 0 0 3545 0
1 3303.389553 3303.389553 6879 6879 0 0 3547 0
1 3619.497747 3619.497747 6561 6561 0 0 3551 0
1 5450.874516 3356.834908 6633 5425 0 0 3570 0
1 2725.057799 2725.057799 6024 6024 0 0 3583 0
1 5691.763254 5691.763254 6377 6377 0 0 3602 0
1 3169.96849 3169.96849 5673 5673 0 0 3645 0
1 3275.840301 3250.607347 5876 5165 0 0 3660 0
1 2889.723967 2889.723967 6250 6250 0 0 3662 0
1 7669.776341 7669.776341 6345 6345 0 0 3686 0
1 3834.198391 2710.905485 5632 5238 0 0 3687 0
1 2460.824512 2626.740765 5489 5011 0 0 3714 0
1 2486.475314 5285.960072 5944 5571 0 0 3743 0
1 3044.274943 3780.675875 6001 5272 0 0 3779 0
1 2330.782119 2330.782119 5254 5254 0 0 3798 0
1 6918.421155 4441.631393 5837 5400 0 0 3807 0
1 2283.770553 2283.770553 5352 5352 0 0 3843 0
1 4017.235221 4017.235221 5268 5268 0 0 3897 0
1 7856.113523 7856.113523 5280 5280 0 0 3936 0
1 5723.619574 5723.619574 5414 5414 0 0 3985 0
1 3204.713159 2870.945921 5145 5082 0 0 3988 0
1 4486.528634 2810.032147 4970 4900 0 0 3992 0
1 4014.434161 2728.881238 5213 5069 0 0 4005 0
1 2752.918679 2752.918679 4704 4704 0 0 4007 0
1 2277.264207 2277.264207 4998 4998 0 0 4019 0
1 5711.280538 3392.648953 5123 4870 0 0 4020 0
1 3203.948015 3203.948015 4714 4714 0 0 4067 0
1 2767.113359 2767.113359 4886 4886 0 0 4091 0
1 2865.961261 2865.961261 4892 4892 0 0 4110 0
1 2911.739735 2911.739735 4780 4780 0 0 4116 0
1 2361.708077 2361.708077 4724 4724 0 0 4117 0
1 2286.082622 2360.683427 5355 5185 0 0 4118 0
1 2331.814226 2331.814226 5037 5037 0 0 4137 0
1 2308.986958 2308.986958 4682 4682 0 0 4140 0
1 2300.537289 2300.537289 4852 4852 0 0 4177 0
1 2321.675121 2321.675121 4638 4638 0 0 4238 0
1 2237.444686 2237.444686 5043 5043 0 0 4239 0
1 2390.690086 2390.690086 4395 4395 0 0 4241 0
1 2229.52996 2229.52996 5109 5109 0 0 4279 0
1 2520.728579 2520.728579 5119 5119 0 0 4283 0
1 2258.03747 2258.03747 5071 5071 0 0 4284 0
1 2278.607183 2278.607183 4785 4785 0 0 4298 0
1 2505.662096 2505.662096 4083 4083 0 0 4320 0
1 2225.789635 2225.789635 4880 4880 0 0 4331 0
1 2183.306088 2183.306088 4425 4425 0 0 4525 0
1 2263.787317 2263.787317 4964 4964 0 0 4540 0
1 2245.845341 2245.845341 4750 4750 0 0 4640 0
1 2283.423493 2283.423493 4806 4806 0 0 4662 0
1 2266.360563 2266.360563 4765 4765 0 0 4721 0
1 2260.095621 2260.095621 5038 5038 0 0 4732 0
1 2301.432888 2301.432888 4854 4854 0 0 4736 0
1 2329.630779 2329.630779 5708 5708 0 0 4762 0
1 2454.336191 3935.49151 4318 5562 0 0 4772 0
1 2361.297036 3624.034037 4331 5232 0 0 4779 0
1 2323.874056 2323.874056 4757 4757 0 0 4790 0
1 2382.420745 2382.420745 5349 5349 0 0 4798 0
1 2352.659926 2352.659926 4452 4452 0.0000846 0.020143027 4799 0
1 2409.321197 2409.321197 4475 4475 0 0 4815 0
1 2360.118466 2360.118466 4369 4369 0 0 4819 0
1 2339.601538 2339.601538 5518 5518 0 0 4861 0
1 2358.67411 2358.67411 4574 4574 0 0 4880 0
1 2386.410926 3718.035094 4393 5278 0 0 4894 0
1 2528.234053 2528.234053 4703 4703 0 0 4910 0
1 2291.851083 2291.851083 5101 5101 0 0 4925 0
1 2459.766511 2459.766511 4814 4814 0 0 4973 0
1 2490.775395 2490.775395 5044 5044 0 0 5025 0
1 2514.079723 5099.787095 4459 5380 0 0 5032 0
1 2427.873473 2427.873473 4754 4754 0 0 5037 0
1 2380.611838 2380.611838 5461 5461 0 0 5055 0
1 2511.565392 2511.565392 5059 5059 0 0 5056 0
1 3622.514274 3622.514274 4827 4827 0 0 5109 0
1 2475.631468 2475.631468 4908 4908 0 0 5118 0
1 2492.200769 2492.200769 4822 4822 0 0 5143 0
1 2509.438134 2509.438134 4628 4628 0 0 5185 0
1 2556.501335 2556.501335 4737 4737 0 0 5309 0
1 2548.650994 2548.650994 4802 4802 0 0 5316 0
1 2530.378885 2530.378885 4952 4952 0 0 5363 0
1 2528.110558 2551.811713 4629 4785 0 0 5392 0
1 2590.935464 2590.935464 4645 4645 0.000394667 0.093930809 5480 0
1 2631.168824 2958.393588 5187 5380 0 0 5521 0
1 2581.504472 2581.504472 5062 5062 0 0 5531 0
1 2575.585115 2575.585115 5185 5185 0 0 5538 0
1 2551.676567 2551.676567 4892 4892 0 0 5542 0
1 2569.698254 2569.698254 5053 5053 0 0 5557 0
1 2624.237765 2624.237765 4912 4912 0 0 5604 0
1 2614.385919 2614.385919 5301 5301 0 0 5640 0
1 2598.787723 2598.787723 5364 5364 0 0 5642 0
1 2578.060432 2578.060432 5090 5090 0 0 5656 0
1 4001.119207 5895.989889 4925 5693 0 0 5662 0
1 2623.749151 2623.749151 5440 5440 0 0 5673 0
1 2644.030557 2644.030557 5377 5377 0 0 5710 0
1 2669.872842 2669.872842 5177 5177 0 0 5734 0
1 3646.204271 3646.204271 5193 5193 0 0 5794 0
1 2618.429271 2618.429271 5035 5035 0 0 5815 0
1 2690.323195 2690.323195 4821 4821 0 0 5818 0
1 2633.516256 2633.516256 4956 4956 0 0 5883 0
1 2701.966232 2701.966232 5470 5470 0 0 5898 1
1 2946.4581 6141.938828 5043 5935 0 0 5919 1
1 2658.347761 2658.347761 5162 5162 0 0 5938 1
0 2424.833017 2424.833017 5726 5726 0 0 3737 1
0 2644.544075 2644.544075 4857 4857 0 0 3799 1
1 2410.138972 2280.102484 4816 4905 0 0 3974 1
1 2968.445375 2968.445375 4705 4705 0 0 4006 1
1 2267.857714 2267.857714 5088 5088 0 0 4330 1
1 2293.989337 2293.989337 5007 5007 0 0 4612 1
1 2308.364875 2281.548644 4560 4720 0 0 4922 1
1 2492.057156 2492.057156 4737 4737 0 0 5089 1
1 2566.653701 2566.653701 4989 4989 0 0 5478 1
var dbsenderPostal = (from a in db.TblCUSTOMER_PROFILE
where a.FullName == search
select a.PostalAddress).ToArray();