X_test[:, 1], c=y_test, cmap=cm_bright, alpha=0.6) ax.set_xlim(xx.min(), xx.max()) ax.set_ylim(yy.min(), yy.max()) ax.set_xticks(()) ax.set_yticks(()) if ds_cnt == 0: ax.set_title(name) ax.text(xx.max() - .3, yy.min() + .3, ('%.2f' % score).lstrip('0'), size=15, horizontalalignment='right') i += 1 #plt.tight_layout() #plt.figure() # plt.show() g if args.plot == 'save': fname = 'svc_plot.png' plt.savefig(fname) write_dict({'svc_plot_file': fname}) elif args.plot == 'show': plt.show() sc.save_model(svc, args.model_output_file)
parser.add_argument( '--class_weight', help= 'list of dicts, balanced, balanced_subsample or None, optional (default=None) Weights associated with classes in the form {class_label: weight}. If not given, all classes are supposed' ' to have weight one. For multi-output problems, a list of dicts can be provided in the same order as the columns of y. The balanced mode uses the values of y to automatically adjust weights inversely ' 'proportional to class frequencies in the input data as n_samples / (n_classes * np.bincount(y)) The balanced_subsample mode is the same as balanced except that weights are computed based on the bootstrap sample for ' 'every tree grown. For multi-output, the weights of each column of y will be multiplied. Note that these weights will be multiplied with sample_weight (passed through the fit method) if sample_weight is specified.' ) args = sc.parse_args(parser) rf = RandomForestClassifier( n_estimators=args.n_estimators, criterion=args.criterion, max_depth=args.max_depth, min_samples_split=args.min_samples_split, min_samples_leaf=args.min_samples_leaf, min_weight_fraction_leaf=args.min_weight_fraction_leaf, max_features=args.max_features, max_leaf_nodes=args.max_leaf_nodes, min_impurity_split=args.min_impurity_split, bootstrap=args.bootstrap, oob_score=args.oob_score, n_jobs=args.n_jobs, random_state=args.random_state, verbose=args.verbose, warm_start=args.warm_start, class_weight=args.class_weight) sc.save_model(rf, args.model_output_file)
import scrape as sc sc.model_options(parser) sc.all_options(parser) sc.output_options(parser) from scrape import write_dict args = sc.parse_args(parser) # # Compute PCA # kpca = KernelPCA(kernel=args.kernel, fit_inverse_transform=args.fit_inverse_transform, gamma=args.gamma, n_components=args.n_components, degree=args.degree, coef0=args.coef0, kernel_params=args.kernel_params, alpha=args.alpha, eigen_solver=args.eigen_solver, tol=args.tol, max_iter=args.max_iter, random_state=args.random_state, n_jobs=args.n_jobs, copy_X=args.copy_X) sc.save_model(kpca, args.model_output_file)
parser.add_argument( '--copy_x', type=bool, default=True, help= 'When pre-computing distances it is more numerically accurate to center the data first. If copy_x is True, then the original data is not modified. If False, the original data is modified, and put back before the function returns, but small numerical differences may be introduced by subtracting and then adding the data mean.' ) import scrape as sc from scrape import write_dict from scrape import load_file sc.all_options(parser) sc.model_options(parser) args = sc.parse_args(parser) kmeans = KMeans(n_clusters=args.n_clusters, init=args.init, n_init=args.n_init, max_iter=args.max_iter, tol=args.tol, precompute_distances=args.precompute_distances, verbose=args.verbose, random_state=args.random_state, copy_x=args.copy_x, n_jobs=args.n_jobs, algorithm=args.algorithm) sc.save_model(kmeans, args.model_output_file)