def do_gridSearch(training_shp, training_image, model_out_path, bands): PYEO_model.train_cairan_model(image_path=training_image, shp_path=training_shp, outModel_path=model_out_path, bands=bands, attribute='Id', shape_projection_id=32630)
def do_grid_search( training_shape, training_image, image_out_path, model_out_path, ): PYEO_model.train_cairan_model(image_dir=s0_dir, outModel_path=outModel, bands=8, attribute='Code') features, classes = get_training_data(training_image, training_shape, attribute="Id") print(features.shape) print(classes.shape) X_train, X_test, y_train, y_test = train_test_split( features.astype(np.uint8), classes.astype(np.uint8), train_size=0.7, test_size=0.3) # grid search for the best parameters for SVM # https://scikit-learn.org/stable/auto_examples/svm/plot_rbf_parameters.html # C_range = np.logspace(0, 1, 2, base=10) # base = 2 for a fine tuning # gamma_range = np.logspace(0, 128, 2, base=10) # param_grid = dict(gamma=gamma_range, C=C_range) # cv = StratifiedShuffleSplit(n_splits=5, test_size=0.2, random_state=42) # grid = GridSearchCV(SVC(), param_grid=param_grid, cv=cv, n_jobs=6) # grid.fit(X_train, y_train) # # print("The best parameters are %s with a score of %0.2f" # % (grid.best_params_, grid.best_score_)) # c, gamma = grid.best_params_ # c= # gamma = model = svm.SVC(kernel='rbf') # model = TPOTClassifier(generations=10, population_size=20, verbosity=2,n_jobs=-1) model.fit(features, classes) print(model.score(X_test, y_test)) model.export(model_out_path)