<jupyter_start><jupyter_text>Machine Learning Algorithms applied to Divorce Data<jupyter_code># Import dependencies

import matplotlib.pyplot as plt
from sklearn.neighbors import KNeighborsClassifier
import pandas as pd
import numpy as np
import os


# read data from csv file into pandas data frame
df = pd.read_csv("divorce_data.csv")
df.head()<jupyter_output><empty_output><jupyter_text>Linear Support Vector Classification<jupyter_code>target = df["Class"]
target_names = ["Divorced", "Married"]
data = df.drop("Class", axis=1)
feature_names = data.columns
data.head()
from sklearn.model_selection import train_test_split
# X_train, X_test, y_train, y_test = train_test_split(data, target)
X_train, X_test, y_train, y_test = train_test_split(data, target, random_state=42)

from sklearn.svm import SVC

model = SVC(kernel='linear')
model.fit(X_train, y_train)
print('Test Acc: %.5f' % model.score(X_test, y_test))
from sklearn.metrics import classification_report
predictions = model.predict(X_test)
print(classification_report(y_test, predictions,
                            target_names=target_names))<jupyter_output>precision    recall  f1-score   support

    Divorced       0.88      1.00      0.94        23
     Married       1.00      0.88      0.93        24

    accuracy                           0.94        47
   macro avg       0.94      0.94      0.94        47
weighted avg       0.94      0.94      0.94        47
{'fraction_non_alphanumeric': 0.08571428571428572, 'fraction_numerical': 0.037630662020905925, 'mean_word_length': 3.198830409356725, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '88191', 'license': 'CC-BY-3.0', 'n_tokens_mistral': 499, 'n_tokens_neox': 468, 'n_words': 119, 'path': 'Data4Woman/LinearSVC.ipynb', 'repo_name': 'cdshary/FinalProject', 'size': '1435'}