Commit 38f909ea authored by Daniel Scheffler's avatar Daniel Scheffler
Browse files

Improved console output.

parent ec4dddb2
Pipeline #3247 failed with stage
in 17 minutes and 35 seconds
......@@ -41,6 +41,7 @@ class _ImageClassifier(object):
self.n_features = train_spectra.shape[1]
self.clf = None # to be implemented by the subclass
self.cmap = None
self.clf_name = ''
def _predict(self, tilepos):
raise NotImplementedError('This method has to be implemented by the subclass.')
......@@ -55,7 +56,7 @@ class _ImageClassifier(object):
cmap = GeoArray(np.empty((image_cube_gA.rows, image_cube_gA.cols),
dtype=np.array(self.train_labels).dtype), nodata=nodataVal)
print('Performing image classification...')
print('Performing %s image classification...' % self.clf_name)
if self.CPUs is None or self.CPUs > 1:
with Pool(self.CPUs, initializer=initializer, initargs=(self.train_spectra, image_cube_gA)) as pool:
tiles_cm = pool.map(self._predict, bounds_alltiles)
......@@ -94,6 +95,8 @@ class MinimumDistance_Classifier(_ImageClassifier):
super(MinimumDistance_Classifier, self).__init__(train_spectra, train_labels, CPUs=CPUs)
self.clf_name = 'minimum distance (nearest centroid)'
self.clf = NearestCentroid()
self.clf.fit(train_spectra, train_labels)
......@@ -111,6 +114,8 @@ class kNN_Classifier(_ImageClassifier):
# type: (np.ndarray, Union[np.ndarray, List[int]], Union[int, None], int) -> None
super(kNN_Classifier, self).__init__(train_spectra, train_labels, CPUs=CPUs)
self.clf_name = 'k-nearest neighbour (kNN)'
self.clf = KNeighborsClassifier(n_neighbors=n_neighbors, n_jobs=1)
self.clf.fit(train_spectra, train_labels)
......@@ -128,6 +133,8 @@ class SAM_Classifier(_ImageClassifier):
# type: (np.ndarray, Union[int, None]) -> None
super(SAM_Classifier, self).__init__(train_spectra, np.array(range(train_spectra.shape[0])), CPUs=CPUs)
self.clf_name = 'spectral angle mapper (SAM)'
def _predict(self, tilepos):
assert global_shared_endmembers is not None and global_shared_im2classify is not None
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment