original_docstring: 
      Main function for initializing SageMaker training in the hosted infrastructure.
      
      Parameters
      ----------
      args: the parsed input arguments of the script. The objects assigned as attributes of the namespace. It's the populated namespace.
      
      See: https://docs.python.org/3/library/argparse.html#argparse.ArgumentParser.parse_args
      
docstring: Main function for initializing SageMaker training in the hosted infrastructure.
  Parameters
  
  the parsed input arguments of the script. The objects assigned as attributes of the namespace. It's the populated namespace.
  
  
docstring_tokens: Main function for initializing SageMaker training in the hosted infrastructure . Parameters the parsed input arguments of the script . The objects assigned as attributes of the namespace . It ' s the populated namespace .
code: def train(args):
      '''
      Main function for initializing SageMaker training in the hosted infrastructure.
      
      Parameters
      ----------
      args: the parsed input arguments of the script. The objects assigned as attributes of the namespace. It's the populated namespace.
      
      See: https://docs.python.org/3/library/argparse.html#argparse.ArgumentParser.parse_args
      '''
  
      # Take the set of files and read them all into a single pandas dataframe
      input_files = [ os.path.join(args.train, file) for file in os.listdir(args.train) ]
      if len(input_files) == 0:
          raise ValueError(('There are no files in {}.\n' +
                            'This usually indicates that the channel ({}) was incorrectly specified,\n' +
                            'the data specification in S3 was incorrectly specified or the role specified\n' +
                            'does not have permission to access the data.').format(args.train, "train"))
      raw_data = [ pd.read_csv(file, header=None, engine="python") for file in input_files ]
      data = pd.concat(raw_data)
  
      # move from a data frame into a numpy array
      X = data.iloc[:,1:].to_numpy()
      y = data.iloc[:,0].to_numpy()
      
      # Cast to numeric types
      X = X.astype(float)
      y = y.astype(int)
  
      # Here we don't use hyperparameters. We could set this here
      # my_hyperparam = args.MY_HYPERPARM_NAME
      
      # split data in 80%-20% training/test split
      X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2)
      
      # impute mean for missing values, since we have only numerical values
      imputer = SimpleImputer(missing_values=np.nan, strategy='mean')
      X_train = imputer.fit_transform(X_train)
      X_test = imputer.transform(X_test)
  
      scaler = StandardScaler()
      X_train = scaler.fit_transform(X_train)
      X_test = scaler.transform(X_test)
      
      # evaluate a logistic regression with 5-fold cross-validation
      estimator = Pipeline([("imputer", SimpleImputer(missing_values=np.nan,
                                                strategy="mean")),
                            ('scaler', StandardScaler()),
                            ("regression", LogisticRegressionCV(cv=5,
                                                                scoring='roc_auc',
                                                                solver='lbfgs'))])
  
      # train pipeline
      estimator.fit(X_train, y_train)
  
      # predict class labels for the test set
      y_pred = estimator.predict(X_test)
  
      # generate class probabilities
      y_prob = estimator.predict_proba(X_test)
      
      # generate evaluation metrics
      logger.info('Test Accuracy: {};'.format(accuracy_score(y_test, y_pred)))
      logger.info('Test AUROC: {};'.format(roc_auc_score(y_test, y_prob[:, 1])))
                                                                
      save_model(estimator, args.model_dir)
code_tokens: def train ( args ) : input_files = [ os . path . join ( args . train , file ) for file in os . listdir ( args . train ) ] if len ( input_files ) == 0 : raise ValueError ( ( 'There are no files in {}.\n' + 'This usually indicates that the channel ({}) was incorrectly specified,\n' + 'the data specification in S3 was incorrectly specified or the role specified\n' + 'does not have permission to access the data.' ) . format ( args . train , "train" ) ) raw_data = [ pd . read_csv ( file , header = None , engine = "python" ) for file in input_files ] data = pd . concat ( raw_data ) X = data . iloc [ : , 1 : ] . to_numpy ( ) y = data . iloc [ : , 0 ] . to_numpy ( ) X = X . astype ( float ) y = y . astype ( int ) X_train , X_test , y_train , y_test = train_test_split ( X , y , test_size = 0.2 ) imputer = SimpleImputer ( missing_values = np . nan , strategy = 'mean' ) X_train = imputer . fit_transform ( X_train ) X_test = imputer . transform ( X_test ) scaler = StandardScaler ( ) X_train = scaler . fit_transform ( X_train ) X_test = scaler . transform ( X_test ) estimator = Pipeline ( [ ( "imputer" , SimpleImputer ( missing_values = np . nan , strategy = "mean" ) ) , ( 'scaler' , StandardScaler ( ) ) , ( "regression" , LogisticRegressionCV ( cv = 5 , scoring = 'roc_auc' , solver = 'lbfgs' ) ) ] ) estimator . fit ( X_train , y_train ) y_pred = estimator . predict ( X_test ) y_prob = estimator . predict_proba ( X_test ) logger . info ( 'Test Accuracy: {};' . format ( accuracy_score ( y_test , y_pred ) ) ) logger . info ( 'Test AUROC: {};' . format ( roc_auc_score ( y_test , y_prob [ : , 1 ] ) ) ) save_model ( estimator , args . model_dir )
short_docstring: Main function for initializing SageMaker training in the hosted infrastructure.
short_docstring_tokens: Main function for initializing SageMaker training in the hosted infrastructure .
comment: '''
      Main function for initializing SageMaker training in the hosted infrastructure.
      
      Parameters
      ----------
      args: the parsed input arguments of the script. The objects assigned as attributes of the namespace. It's the populated namespace.
      
      See: https://docs.python.org/3/library/argparse.html#argparse.ArgumentParser.parse_args
      '''$SEP$# Take the set of files and read them all into a single pandas dataframe$SEP$# move from a data frame into a numpy array$SEP$# Cast to numeric types$SEP$# Here we don't use hyperparameters. We could set this here$SEP$# my_hyperparam = args.MY_HYPERPARM_NAME$SEP$# split data in 80%-20% training/test split$SEP$# impute mean for missing values, since we have only numerical values$SEP$# evaluate a logistic regression with 5-fold cross-validation$SEP$# train pipeline$SEP$# predict class labels for the test set$SEP$# generate class probabilities$SEP$# generate evaluation metrics