We get a little further on the azml_02 but it seems to fail still
This commit is contained in:
		
							parent
							
								
									032b05b9c3
								
							
						
					
					
						commit
						1acf43fa82
					
				
					 2 changed files with 31 additions and 29 deletions
				
			
		| 
						 | 
				
			
			@ -17,28 +17,28 @@ def main():
 | 
			
		|||
    # Input and output arguments
 | 
			
		||||
 | 
			
		||||
    # Get script arguments
 | 
			
		||||
    parser = XXXX()
 | 
			
		||||
    parser = argparse()
 | 
			
		||||
 | 
			
		||||
    # Input dataset
 | 
			
		||||
    parser.add_argument(
 | 
			
		||||
        "XXXX",
 | 
			
		||||
        "--data",
 | 
			
		||||
        type=str,
 | 
			
		||||
        help="path to input data",
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
    # Model name
 | 
			
		||||
    parser.add_argument("XXXX", type=str, help="model name")
 | 
			
		||||
    parser.add_argument("--registered_model_name", type=str, help="model name")
 | 
			
		||||
 | 
			
		||||
    # Hyperparameters
 | 
			
		||||
    parser.add_argument(
 | 
			
		||||
        "XXXX",
 | 
			
		||||
        "--learning_rate",
 | 
			
		||||
        type=float,
 | 
			
		||||
        dest="learning_rate",
 | 
			
		||||
        default=0.1,
 | 
			
		||||
        help="learning rate",
 | 
			
		||||
    )
 | 
			
		||||
    parser.add_argument(
 | 
			
		||||
        "XXXX",
 | 
			
		||||
        "--n_estimators",
 | 
			
		||||
        type=int,
 | 
			
		||||
        dest="n_estimators",
 | 
			
		||||
        default=100,
 | 
			
		||||
| 
						 | 
				
			
			@ -50,10 +50,10 @@ def main():
 | 
			
		|||
    print(" ".join(f"{k}={v}" for k, v in vars(args).items()))
 | 
			
		||||
 | 
			
		||||
    # Start Logging
 | 
			
		||||
    mlflow.XXXX()
 | 
			
		||||
    mlflow.start_run()
 | 
			
		||||
 | 
			
		||||
    # enable autologging
 | 
			
		||||
    mlflow.XXXX()
 | 
			
		||||
    mlflow.sklearn.autolog()
 | 
			
		||||
 | 
			
		||||
    # load the diabetes data (passed as an input dataset)
 | 
			
		||||
    print("input data:", args.data)
 | 
			
		||||
| 
						 | 
				
			
			@ -78,32 +78,32 @@ def main():
 | 
			
		|||
    )
 | 
			
		||||
 | 
			
		||||
    # Split data into training set and test set
 | 
			
		||||
    X_train, X_test, y_train, y_test = XXXX(
 | 
			
		||||
    X_train, X_test, y_train, y_test = train_test_split(
 | 
			
		||||
        X, y, test_size=0.30, random_state=0
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
    # Train a Gradient Boosting classification model
 | 
			
		||||
    # with the specified hyperparameters
 | 
			
		||||
    print("Training a classification model")
 | 
			
		||||
    model = XXXX(
 | 
			
		||||
        learning_rate=XXXX, n_estimators=XXXX
 | 
			
		||||
    model = GradientBoostingClassifier(
 | 
			
		||||
        learning_rate=args.learning_rate, n_estimators=args.n_estimators
 | 
			
		||||
    ).fit(X_train, y_train)
 | 
			
		||||
 | 
			
		||||
    # calculate accuracy
 | 
			
		||||
    y_hat = model.XXXX(X_test)
 | 
			
		||||
    y_hat = model.predict(X_test)
 | 
			
		||||
    accuracy = np.average(y_hat == y_test)
 | 
			
		||||
    print("Accuracy:", accuracy)
 | 
			
		||||
    mlflow.log_metric("Accuracy", float(accuracy))
 | 
			
		||||
 | 
			
		||||
    # calculate AUC
 | 
			
		||||
    y_scores = model.XXXX(X_test)
 | 
			
		||||
    y_scores = model.predict_proba(X_test)
 | 
			
		||||
    auc = roc_auc_score(y_test, y_scores[:, 1])
 | 
			
		||||
    print("AUC: " + str(auc))
 | 
			
		||||
    mlflow.log_metric("AUC", float(auc))
 | 
			
		||||
 | 
			
		||||
    # Registering the model to the workspace
 | 
			
		||||
    print("Registering the model via MLFlow")
 | 
			
		||||
    mlflow.XXXX(
 | 
			
		||||
    mlflow.sklearn.log_model(
 | 
			
		||||
        sk_model=model,
 | 
			
		||||
        registered_model_name=args.registered_model_name,
 | 
			
		||||
        artifact_path=args.registered_model_name,
 | 
			
		||||
| 
						 | 
				
			
			@ -116,7 +116,7 @@ def main():
 | 
			
		|||
    )
 | 
			
		||||
 | 
			
		||||
    # Stop Logging
 | 
			
		||||
    mlflow.XXXX()
 | 
			
		||||
    mlflow.end_run()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
if __name__ == "__main__":
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue