Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Training algorithm #37

Open
Timvdhilst opened this issue Mar 6, 2024 · 1 comment
Open

Training algorithm #37

Timvdhilst opened this issue Mar 6, 2024 · 1 comment

Comments

@Timvdhilst
Copy link

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
Copy link

Lahers commented Jun 21, 2024

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=3**np.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()
n_splits = 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_classifier_str,
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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants