text_html_output_1.png
from sklearn.linear_model import LinearRegression as LR, Perceptron

from sklearn.model_selection import cross_val_score

from sklearn.preprocessing import StandardScaler

from sklearn.svm import SVR

train = pd.read_csv('../input/car-price/train set.csv')

names = [x.split(' ')[0] for x in list(train['name'])]

train.insert(0, 'brand', names)

train = train.drop(['name', 'seller_type', 'owner', 'torque', 'fuel'], axis=1)

train['engine'] = [int(x.split(' ')[0]) for x in list(train['engine'])]

train['mileage'] = [float(x.split(' ')[0]) for x in list(train['mileage'])]
train['max_power'] = [float(x.split(' ')[0]) for x in list(train['max_power'])]

num_features = [x for x in train.columns if type(train[x][0]) is not str]
cat_features = [x for x in train.columns if x not in num_features]

X_train = train.drop('selling_price', axis=1).values[0:6850]
y_train = train['selling_price'].values[0:6850]

from sklearn.preprocessing import StandardScaler
scaler = StandardScaler()
scaled_X_train = scaler.fit_transform(X_train)

from sklearn.model_selection import KFold
from sklearn.model_selection import cross_val_score
from sklearn.metrics import *
from math import sqrt
mcc = make_scorer(mean_absolute_error)

def evaluate_model(model):
    model = model
    import sklearn
    scores = cross_val_score(model, scaled_X_train, y_train, scoring=mcc, cv=5, n_jobs=-1)
    return scores.mean()

models = [KNR(), RNR(), LR(), RFR(n_estimators=300), Perceptron(), SVR(), MLPR()]
models_names = ['K_neighbors', 'radius_neighbors', 'linear_regression', 'random_forest_regressor', 'perceptron', 'SVR', 'MLP_Regression']
scores = list()
for clf, clf_name in zip(models, models_names):
    k_mean = evaluate_model(clf)
    scores.append(k_mean)

model = models[3]
print(model)