[GRASS-SVN] r71062 - grass-addons/grass7/raster/r.object.activelearning
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon May 8 04:24:52 PDT 2017
Author: mlennert
Date: 2017-05-08 04:24:52 -0700 (Mon, 08 May 2017)
New Revision: 71062
Modified:
grass-addons/grass7/raster/r.object.activelearning/r.object.activelearning.py
Log:
r.object.activelearning: lazy loading of scikit-learn in main() to allow compilation on server
Modified: grass-addons/grass7/raster/r.object.activelearning/r.object.activelearning.py
===================================================================
--- grass-addons/grass7/raster/r.object.activelearning/r.object.activelearning.py 2017-05-08 08:07:13 UTC (rev 71061)
+++ grass-addons/grass7/raster/r.object.activelearning/r.object.activelearning.py 2017-05-08 11:24:52 UTC (rev 71062)
@@ -101,16 +101,6 @@
except ImportError :
pass
-try :
- from sklearn import svm
- from sklearn import preprocessing
- from sklearn.model_selection import train_test_split
- from sklearn.model_selection import RandomizedSearchCV
- from sklearn.model_selection import StratifiedKFold
- from sklearn.metrics.pairwise import rbf_kernel
-except ImportError :
- gcore.fatal("This module requires the scikit-learn python package. Please install it.")
-
import numpy as np
import scipy
import os.path
@@ -535,6 +525,18 @@
global nbr_uncertainty
global search_iter
+ global svm, preprocessing, train_test_split, RandomizedSearchCV
+ global StratifiedKFold, rbf_kernel
+ try :
+ from sklearn import svm
+ from sklearn import preprocessing
+ from sklearn.model_selection import train_test_split
+ from sklearn.model_selection import RandomizedSearchCV
+ from sklearn.model_selection import StratifiedKFold
+ from sklearn.metrics.pairwise import rbf_kernel
+ except ImportError :
+ gcore.fatal("This module requires the scikit-learn python package. Please install it.")
+
learning_steps = int(options['learning_steps']) if options['learning_steps'] != '0' else 5
search_iter = int(options['search_iter']) if options['search_iter'] != '0' else 10 # Number of samples to label at each iteration
diversity_lambda = float(options['diversity_lambda']) if options['diversity_lambda'] != '' else 0.25 # Lambda parameter used in the diversity heuristic
More information about the grass-commit
mailing list