<jupyter_start><jupyter_text>Database Connection<jupyter_code>from config import password
#Import dependencies
import sqlalchemy
from sqlalchemy import create_engine
import pandas as pd

##%load_ext sql
engine = create_engine(f'postgresql://postgres:{password}@localhost/ufc_project_provisional')
fight_data_pre_df = pd.read_sql('SELECT * FROM ufc_fight_data_pre',engine)
fight_data_pre_df.tail()<jupyter_output><empty_output><jupyter_text>Preliminary Machine Learning Model<jupyter_code>#import more dependencies
from sklearn.preprocessing import StandardScaler
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import confusion_matrix, accuracy_score, classification_report
classifier = LogisticRegression(solver='lbfgs', random_state=1)
classifier
fight_data_df = fight_data_pre_df.dropna()
#Define the X variables
X_pre = fight_data_df.copy()
X_pre = X_pre.drop("red_fighter",axis=1)
X_pre = X_pre.drop("blue_fighter",axis=1)
X_pre = X_pre.drop("winner",axis=1)
X_pre = X_pre.drop("b_stance",axis=1)
X_pre = X_pre.drop("r_stance",axis=1)
X = X_pre.dropna()
#Define the target set
y = fight_data_df["winner"].values
X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=1)

# Creating a StandardScaler instance.
scaler = StandardScaler()
# Fitting the Standard Scaler with the training data.
X_scaler = scaler.fit(X_train)

# Scaling the data.
X_train_scaled = X_scaler.transform(X_train)
X_test_scaled = X_scaler.transform(X_test)
#Train the data
classifier.fit(X_train_scaled,y_train)
# Predict outcomes for test data set
predictions = classifier.predict(X_test)
pd.DataFrame({"Prediction": predictions, "Actual": y_test})
# Calculating the accuracy score.
acc_score = accuracy_score(y_test, predictions)
acc_score<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.09717698154180239, 'fraction_numerical': 0.003800217155266015, 'mean_word_length': 8.751322751322752, 'pattern_counts': {'":': 2, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '385753', 'license': 'MIT', 'n_tokens_mistral': 652, 'n_tokens_neox': 635, 'n_words': 133, 'path': '.ipynb_checkpoints/preliminary_machine_learning-checkpoint.ipynb', 'repo_name': 'freddilly/UFC_Project', 'size': '1842'}