image_output_11.png image_output_24.png image_output_25.png image_output_17.png image_output_30.png image_output_14.png image_output_28.png image_output_23.png image_output_13.png image_output_5.png image_output_18.png image_output_21.png image_output_7.png image_output_20.png image_output_4.png image_output_8.png image_output_16.png image_output_27.png image_output_6.png image_output_12.png image_output_22.png image_output_3.png image_output_29.png image_output_2.png image_output_1.png image_output_10.png image_output_15.png image_output_9.png image_output_19.png image_output_26.png
from sklearn.metrics import mean_absolute_error

from sklearn.preprocessing import LabelEncoder

from sklearn.preprocessing import StandardScaler

from sklearn.svm import SVR

import matplotlib.pyplot as plt

import numpy as np

import pandas as pd

import pandas as pd
import numpy as np
from sklearn.model_selection import train_test_split
df = pd.read_csv('../input/california-housing-value/housing.csv')
X = df.drop(columns=['median_house_value'])
y = df['median_house_value']

def preprocess_features(X):
    total_bedrooms_mean = round(X['total_bedrooms'].mean(), 3)
    X = X.fillna(total_bedrooms_mean)
    from sklearn.preprocessing import LabelEncoder
    le = LabelEncoder()
    le.fit(X['ocean_proximity'])
    transformed = le.transform(X['ocean_proximity'])
    X['ocean_proximity'] = transformed
    from sklearn.preprocessing import StandardScaler
    scale = StandardScaler()
    X = scale.fit_transform(X)
    return X
def run_reg(regressor, x_train, x_test, y_train, y_test):
    regressor.fit(x_train, y_train)
    prediction = regressor.predict(x_test)
    prediction = np.clip(prediction, 15000, 500000)
    from sklearn.metrics import mean_absolute_error
    mae = mean_absolute_error(y_test, prediction)
    import matplotlib.pyplot as plt
    return mae

from sklearn.svm import SVR
mae_array = np.zeros((5, 6))
cost = [1000, 10000, 100000, 1000000, 10000000]
epsilon = [2000, 5000, 10000, 20000, 50000, 100000]
row = 0
column = 0
for i in cost:
    column = 0
    for j in epsilon:
        svr_reg = SVR(kernel='rbf', C=i, epsilon=j)
        mae = run_reg(svr_reg, X_train, X_test, y_train, y_test)
        mae_array[row][column] = mae
        column = column + 1
    row = row + 1