text_html_output_1.png
from sklearn.model_selection import train_test_split,cross_val_score,KFold,cross_val_predict,GridSearchCV

from xgboost import XGBRegressor

import matplotlib.pyplot as plt

import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)

import seaborn as sns

def plot_bar_vertical(df, figsize=(10, 15), xlabel='Count Number'):
    ax = df.plot.barh(figsize=figsize)
    for p in ax.patches:
        ax.text(p.get_x() + p.get_width(), p.get_y() + p.get_height() / 2, f'{int(p.get_width())}')

car_us_df = pd.read_csv('/kaggle/input/usa-cers-dataset/USA_cars_datasets.csv', index_col=0)

special_cases_price_zero = car_us_df[car_us_df.price == 0]
special_cases_price_zero.shape

special_cases_price_great = car_us_df[car_us_df.price >= 30000]

car_us_df[car_us_df.price == car_us_df.price.max()]

price_estimator_df = car_us_df.copy()
features_to_drop = ['vin', 'lot', 'country', 'condition']
price_estimator_df.drop(features_to_drop, axis=1, inplace=True)
price_estimator_df

cat_features = [col for col in price_estimator_df.select_dtypes('object')]
cat_features

price_estimator_df.isnull().any()

train = price_estimator_df.drop('price', axis=1)
target = price_estimator_df.price

params = {'n_estimator': [1, 1000, 50], 'n_jobs': [1, 5, 1]}
model = XGBRegressor()
result = abs(cross_val_score(model, train, target, cv=KFold(n_splits=10), scoring='r2')).mean()
result