def test_train_svm_model(self, model_type, c_val, kernel, expected): # Create new Model model_params = {} model_params['C Parameter'] = c_val model_params['Kernel Type'] = kernel model = predict.make_model(model_type, model_params) return_str = predict.train_model(model, test_run=True) self.assertEqual(expected, return_str)
def test_train_knn_model(self, model_type, n_neighbors_val, algorithm_val, expected): # Create new Model model_params = {} model_params['Number of Neighbors'] = n_neighbors_val model_params['Algorithm Type'] = algorithm_val model = predict.make_model(model_type, model_params) return_str = predict.train_model(model, test_run=True) self.assertEqual(expected, return_str)
def test_train_rf_model(self, model_type, n_estimators_val, max_depth_val, expected): # Create new Model model_params = {} model_params['Number of Estimators'] = n_estimators_val model_params['Max Depth'] = max_depth_val model = predict.make_model(model_type, model_params) return_str = predict.train_model(model, test_run=True) self.assertEqual(expected, return_str)
def test_train_nn_model(self, model_type, solver_val, activation_val, max_iter_val, expected): # Create new Model model_params = {} model_params['Solver Type'] = solver_val model_params['Activation Function Type'] = activation_val model_params['Number of Iterations'] = max_iter_val model = predict.make_model(model_type, model_params) return_str = predict.train_model(model, test_run=True) self.assertEqual(expected, return_str)
license_details = license_details.rename( columns={'LicenseNumber': 'License #'}) #labeling and feature engineering license_full_data = aggregate_permit_data(all_permits) #finding contractors with ADU historical data adu_builders = license_full_data[license_full_data['ADU_proj_count'] >= 1] adu_builders = adu_builders.merge(license_details, on='License #', how='left') #saving adu-builder data adu_builders.to_csv('./outputs/adu_builders.csv') adu_builders = pd.read_csv('./outputs/adu_builders.csv') # finding non-adu contractors to predict on non_adu_builders = license_full_data[ (license_full_data['ADU_proj_count'] < 2) & (license_full_data['non_ADU_proj_count'] >= 2)] # training the model on adu-contractors trained_model = train_model(adu_builders) # predicting for non-ADU contractors ranked_non_adu_builders = predict_adu_performance_non_ADU_builders( trained_model, non_adu_builders) ranked_non_adu_builders = ranked_non_adu_builders.merge(license_details, on='License #', how='left') ranked_non_adu_builders.to_csv('./outputs/ranked_contractors.csv')
topk = int(parse_results.topk) #--topk 5 cat_fileName = parse_results.cat_fileName #--cat_fileName cat_to_name.json image_path = parse_results.image_path #LoadData data_transforms, image_datasets, dataloaders = predict.data_transforms() #build the Model model = predict.modelSetup(arch) #froze paramter predict.frozeParameters(model) #Getting device info. device = torch.device("cuda:0" if device == 'gpu' else "cpu") #Build and trainning the classifer classifier, model, criterion, optimizer = predict.make_classifier( arch, model, device, hidden_units, dropout, learning_rate) predict.train_model(dataloaders, optimizer, model, device, epochs, criterion) #Save CheckPoint predict.saveCheckPoint(model, image_datasets, epochs, optimizer) #Accuracy predict.validation_accuracy(dataloaders["test"], model, device, learning_rate) print('Model Trained') #Get Category Name #--cat_fileName #cat_to_name = predict.label_mapping(cat_fileName)