Skip to content

Commit f16e5b4

Browse files
committed
hpc...
1 parent d5ebff3 commit f16e5b4

File tree

2 files changed

+21
-18
lines changed

2 files changed

+21
-18
lines changed

geospatial_learn/learning.py

+20-17
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,8 @@ class names in order of their numercial equivalents
465465
def create_model(X_train, outModel, clf='erf', group=None, random=False,
466466
cv=5, params=None, pipe='default', cores=-1, strat=True,
467467
test_size=0.3, regress=False, return_test=True,
468-
scoring=None, class_names=None, save=True, cat_feat=None):
468+
scoring=None, class_names=None, save=True, cat_feat=None,
469+
plot=True):
469470

470471
"""
471472
Brute force or random model creating using scikit learn.
@@ -679,24 +680,25 @@ class names in order of their numercial equivalents
679680
testresult = grid.best_estimator_.predict(X_test)
680681

681682
if regress == True:
682-
regrslt = regression_results(y_test, testresult)
683+
regrslt = regression_results(y_test, testresult, plot=plot)
683684
results = [grid]
684685

685686
else:
686687
crDf = hp.plot_classif_report(y_test, testresult, target_names=class_names,
687688
save=outModel[:-3]+'._classif_report.png')
688689

689690
confmat = metrics.confusion_matrix(testresult, y_test, labels=class_names)
690-
disp = metrics.ConfusionMatrixDisplay(confusion_matrix=confmat,
691-
display_labels=class_names)
692-
disp.plot()
691+
692+
if plot == True:
693+
disp = metrics.ConfusionMatrixDisplay(confusion_matrix=confmat,
694+
display_labels=class_names)
695+
disp.plot()
693696

694697
# confmat = hp.plt_confmat(X_test, y_test, grid.best_estimator_,
695698
# class_names=class_names,
696699
# cmap=plt.cm.Blues,
697700
# fmt="%d",
698-
# save=outModel[:-3]+'_confmat.png')
699-
701+
# save=outModel[:-3]+'_confmat.png')
700702
results = [grid, crDf, confmat]
701703

702704
if return_test == True:
@@ -861,7 +863,7 @@ class names in order of their numercial equivalents
861863
return comb, X_test, y_test
862864

863865

864-
def regression_results(y_true, y_pred):
866+
def regression_results(y_true, y_pred, plot=True):
865867

866868
# Regression metrics
867869
explained_variance = metrics.explained_variance_score(y_true, y_pred)
@@ -878,15 +880,16 @@ def regression_results(y_true, y_pred):
878880
print('MSE: ', round(mse,4))
879881
print('MedianAE', round(median_absolute_error, 4))
880882
print('RMSE: ', round(np.sqrt(mse),4))
881-
#TODO add when sklearn updated
882-
display = metrics.PredictionErrorDisplay.from_predictions(
883-
y_true=y_true,
884-
y_pred=y_pred,
885-
kind="actual_vs_predicted",
886-
#ax=ax,
887-
scatter_kwargs={"alpha": 0.2, "color": "tab:blue"},
888-
line_kwargs={"color": "tab:red"},
889-
)
883+
#TODO add when sklearn updated
884+
if plot == True:
885+
display = metrics.PredictionErrorDisplay.from_predictions(
886+
y_true=y_true,
887+
y_pred=y_pred,
888+
kind="actual_vs_predicted",
889+
#ax=ax,
890+
scatter_kwargs={"alpha": 0.2, "color": "tab:blue"},
891+
line_kwargs={"color": "tab:red"},
892+
)
890893

891894

892895

geospatial_learn/shape.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2426,7 +2426,7 @@ def meshgrid(inRaster, outShp, gridHeight=1, gridWidth=1):
24262426
bwRas = inRaster[:-4]+'bw.tif'
24272427
maskShp = inRaster[:-4]+'bwmask.shp'
24282428
array2raster(bw, 1, inRaster, bwRas, gdal.GDT_Byte)
2429-
polygonize(bwRas, maskShp, outField=None, mask = True, band = 1)
2429+
polygonize(bwRas, maskShp, outField=None, mask=True, band=1)
24302430

24312431
inRas = None
24322432
del bw, tempIm

0 commit comments

Comments
 (0)