# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3 (ipykernel)
#     language: python
#     name: python3
# ---

# import cell
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
import sklearn as sl
import tensorflow as tf
import xgboost as xgb

# load dataframe and print head
df = pd.read_csv("movies.csv")
df.head()

# basic info
df.info()

# convert percentage column to float
df["RatingTomatometer"] = df["RatingTomatometer"].str.strip("%").astype("float") / 100

df.head()

# ohe genre
dummies = pd.get_dummies(df["Genre"])
dummies

df = df.join(dummies)

# drop text columns
df = df.drop(["Genre", "Title"], axis = 1)

df.head()

# plot correlation
sns.heatmap(df.corr())

df.corr()

# our target is the rating
target = "RatingTomatometer"
X = df.drop(target, axis = 1)
y = df[target]
X_train, X_test, y_train, y_test = sl.model_selection.train_test_split(X, y)

# start with the xgboost model
model = xgb.XGBRegressor().fit(X_train, y_train)
model.predict(X_test)
X_test_results = pd.DataFrame(model.predict(X_test))
X_test_results

X_test_results["actual"] = y_test

X_test_results



StarcoderdataJupyterScriptsDedupFiltered