nkarasiak / dzetsaka

dzetsaka : classification plugin for Qgis
GNU General Public License v3.0
80 stars 21 forks source link

Training algorithm #37

Open Timvdhilst opened 3 months ago

Timvdhilst commented 3 months ago

Hi all,

Sorry in advance, I am pretty new to programming in general. For my research project, I am working on a SAR image, and I want to do supervised classifications on it to assess areas of water and non-water using training data I created in QGIS Lima. The image is quite big, so I Have broken it into smaller sample areas. I am currently running QGIS on mac OSX.

When running either the RF or SVM algorithm using the plugin. I receive these messages. Not sure where to go from here. If anyone has any advice, I would be deeply grateful.

Cheers, Tim

Screen Shot 2024-03-06 at 8 27 40 PM
Lahers commented 1 week ago

Hello,

I can offer you a solution, it may not work, but we can try! First of all, remember to carefully record the lines of code that you are going to change (because if it doesn't work, you can quickly modify them and go back). To correct errors, you will need a code editor (for my part, I use VisualCode which allows you to make modifications in many languages).

The problems therefore come from line 412 and 451 of your "mainfunction.py" file. It's there for you: "/Users/timvanderhilst/LibraolApplication Support/QGlS/QGlS3/profiles/default/python/plugins/dzetsaka/scripts/mainfunction.py".

To fix line 412, I think you can replace these lines: _param_grid = dict( n_estimators=3np.arange( 1, 5), max_features=range( 1, x.shape[1], int( x.shape[1] / 3))) if 'param_algo' in locals(): classifier = RandomForestClassifier(param_algo) else: classifier = RandomForestClassifier() nsplits = 5

By these: param_grid = dict( n_estimators=3 ** np.arange(1, 5), max_features=range(1, x.shape[1], step_size) )

if 'param_algo' in locals(): classifier = RandomForestClassifier(**param_algo) else: classifier = RandomForestClassifier()

n_splits = 5

For the problem on line 451, you can replace these lines: except BaseException: pushFeedback( "Cannot train with classifier" + inClassifier, feedback=feedback) pB.reset()

By these: _except BaseException as e: in_classifier_str = str(inClassifier) ​​if 'inClassifier' in locals() else "unknown classifier" pushFeedback( "Cannot train with classifier " + in_classifierstr, feedback=feedback ) if hasattr(pB, 'reset'): pB.reset() else: print("The pB object does not have a 'reset' method")

I do not guarantee that the problem can be resolved with these lines of code to be evolved, but this can be tested and if it does not work, you can go back with the old lines of code! Please let me know if it worked!