text_plain_output_1.png
from sklearn.metrics import mean_squared_error, mean_absolute_error, r2_score

import pandas as pd

import seaborn as sns

import warnings

import pandas as pd
import numpy as np
from matplotlib import pyplot as plt
plt.rcParams.update({'figure.max_open_warning': 0})
import seaborn as sns
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LinearRegression
from sklearn import linear_model
from statsmodels.stats.outliers_influence import variance_inflation_factor
from sklearn.preprocessing import RobustScaler
from sklearn.metrics import mean_squared_error, mean_absolute_error, r2_score
import warnings
warnings.filterwarnings('ignore')

def visualize(data):
    for c in data.columns:
        plt.figure()
        plt.tight_layout()
        sns.set(rc={"figure.figsize":(8, 5)})
        if data[c].dtype=='int64' or data[c].dtype=='float64':
            f, (ax_box, ax_hist) = plt.subplots(2, sharex=True)
            plt.gca().set(xlabel= c,ylabel='Frequency')
            sns.boxplot(data[c], ax=ax_box , linewidth= 1.0)
            sns.histplot(data[c], ax=ax_hist , bins = 10,kde=True)
        else:
            plt.gca().set(xlabel= c,ylabel='Frequency')
            sns.histplot(data[c], bins = 10)
            
            
def evaluate(model,x_train , y_train, x_test , y_test, y_predict):
    print(f'score x_train , y_train : {model.score(x_train , y_train)}')
    print(f'score x_test , y_test : {model.score(x_test , y_test)}')
    print(f'r2_score : {r2_score(y_test, y_predict)}')
    print(f'mean absolute err : {mean_absolute_error(y_predict, y_test)}')
    print(f'mean squared err : {mean_squared_error(y_test, y_predict)}')

df = pd.read_csv('../input/car-price-prediction/CarPrice_Assignment.csv')

df.columns

pd.set_option('display.max_columns', None)

df.isnull().sum()

df.duplicated().sum()

visualize(df.drop(['car_ID', 'CarName'], axis=1))