CardiovascularDisease/CVD/ML_models.py
def svc_model(X_train: pd.DataFrame, X_test: pd.DataFrame, y_train: pd.Series, y_test: pd.Series):
    """
    Support Vector Machine Classifier model: choose kernel.
    Then fit to data and predict.

    :parameter X_train: Training data.
    :parameter y_train: Target that corresponds to training data.
    :parameter X_test: Test data.
    :parameter y_test: Target that corresponds to test data.
    :return: Model object, model predictions for test dataset, and classification report (dict).
    """

    kernel = 'linear'  # can try 'rbf' --> getting similar results.
    clf = SVC(kernel=kernel, probability=True)
    model = clf.fit(X_train, y_train)  # Train the model
    y_pred = model.predict(X_test)  # Predict classes in test set
    print(f'Estimator: Support Vector Machine Classifier (kernel={kernel})\n',
          classification_report(y_test, y_pred))

    return model, y_pred, classification_report(y_test, y_pred, output_dict=True)

    Support Vector Machine Classifier model: choose kernel.
    Then fit to data and predict.

    :parameter X_train: Training data.
    :parameter y_train: Target that corresponds to training data.
    :parameter X_test: Test data.
    :parameter y_test: Target that corresponds to test data.
    :return: Model object, model predictions for test dataset, and classification report (dict).
    
Support Vector Machine Classifier model: choose kernel.
Then fit to data and predict.
Support Vector Machine Classifier model : choose kernel . Then fit to data and predict .
def svc_model(X_train: pd.DataFrame, X_test: pd.DataFrame, y_train: pd.Series, y_test: pd.Series):
    kernel = 'linear'  
    clf = SVC(kernel=kernel, probability=True)
    model = clf.fit(X_train, y_train)  
    y_pred = model.predict(X_test)  
    print(f'Estimator: Support Vector Machine Classifier (kernel={kernel})\n',
          classification_report(y_test, y_pred))
    return model, y_pred, classification_report(y_test, y_pred, output_dict=True)
def svc_model ( X_train : pd . DataFrame , X_test : pd . DataFrame , y_train : pd . Series , y_test : pd . Series ) : kernel = 'linear' clf = SVC ( kernel = kernel , probability = True ) model = clf . fit ( X_train , y_train ) y_pred = model . predict ( X_test ) print ( f'Estimator: Support Vector Machine Classifier (kernel={kernel})\n' , classification_report ( y_test , y_pred ) ) return model , y_pred , classification_report ( y_test , y_pred , output_dict = True )
Support Vector Machine Classifier model: choose kernel.
Support Vector Machine Classifier model : choose kernel .
"""
    Support Vector Machine Classifier model: choose kernel.
    Then fit to data and predict.

    :parameter X_train: Training data.
    :parameter y_train: Target that corresponds to training data.
    :parameter X_test: Test data.
    :parameter y_test: Target that corresponds to test data.
    :return: Model object, model predictions for test dataset, and classification report (dict).
    """ # can try 'rbf' --> getting similar results. # Train the model # Predict classes in test set
Model object, model predictions for test dataset, and classification report (dict).
Model object model predictions for test dataset and classification report ( dict ) .
X_train
pd.DataFrame
None
X_test
pd.DataFrame
None
y_train
pd.Series
Target that corresponds to training data.
Target that corresponds to training data .
y_test
pd.Series
Target that corresponds to test data.
Target that corresponds to test data .