<jupyter_start><jupyter_text>Auto-sklearn Avocado  Goal : - Create a ML model using Auto-sklearn for the Avocado dataset- Get RMSE over the predictions of these model  Imports<jupyter_code>import pandas as pd
import sklearn.model_selection
import sklearn.datasets
import sklearn.metrics
from math import sqrt
import autosklearn.regression
import time

X_train = pd.read_csv('../../Data/avocado_price/processed/x_train.csv')
y_train = pd.read_csv('../../Data/avocado_price/processed/y_train.csv')
X_test = pd.read_csv('../../Data/avocado_price/processed/x_test.csv')
y_test = pd.read_csv('../../Data/avocado_price/processed/y_test.csv')<jupyter_output><empty_output><jupyter_text>One of the features of Auto-sklearn is to indicate if features are "categorical" or "numerical"<jupyter_code>#we took these list of feature from Script/California_house
list_of_categorical="type_organic,type_conventional,region"
list_of_categorical=list_of_categorical.split(",")
feature_types=[]
for (col_name,col_data) in X_train.iteritems():
    if (col_name in list_of_categorical):
        feature_types.append("Categorical")
    else:
        feature_types.append("Numerical")<jupyter_output><empty_output><jupyter_text>We create our model and look at the time it took for doing it.<jupyter_code>start = time.time()
automl = autosklearn.regression.AutoSklearnRegressor(
    time_left_for_this_task=120,
    per_run_time_limit=30
)
automl.fit(X_train, y_train, dataset_name='avoca',
           feat_type=feature_types)

elapsed_time=(time.time()-start)<jupyter_output>/opt/conda/lib/python3.7/site-packages/autosklearn/automl.py:917: DataConversionWarning: A column-vector y was passed when a 1d array was expected. Will change shape via np.ravel().
  y = self._check_y(y)<jupyter_text>Display of :- time it took for creating the model- RMSE of created model over the testing dataset<jupyter_code>print(automl.show_models())
predictions = automl.predict(X_test.values)
print("rmse score:", sqrt(sklearn.metrics.mean_squared_error(y_test, predictions)))
print("elapsed time:",elapsed_time)<jupyter_output>[(1.000000, SimpleRegressionPipeline({'data_preprocessing:categorical_transformer:categorical_encoding:__choice__': 'one_hot_encoding', 'data_preprocessing:categorical_transformer:category_coalescence:__choice__': 'no_coalescense', 'data_preprocessing:numerical_transformer:imputation:strategy': 'median', 'data_preprocessing:numerical_transformer:rescaling:__choice__': 'standardize', 'feature_preprocessor:__choice__': 'no_preprocessing', 'regressor:__choice__': 'ridge_regression', 'regressor:ridge_regression:alpha': 0.1265650933230963, 'regressor:ridge_regression:fit_intercept': 'True', 'regressor:ridge_regression:tol': 0.076963514229007},
dataset_properties={
  'task': 4,
  'sparse': False,
  'multilabel': False,
  'multiclass': False,
  'target_type': 'regression',
  'signed': False})),
]
rmse score: 25.481879860989096
elapsed time: 115.20937180519104<jupyter_text>Residual Plot<jupyter_code>import matplotlib.pyplot as plt

#plot residuals
plt.scatter(predictions, predictions - y_test.AveragePrice.values, c="grey", label="Testing Data")
plt.legend()
plt.hlines(y=0, xmin=y_test.min(), xmax=y_test.max())
plt.title("Residual Plot")
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12091603053435114, 'fraction_numerical': 0.026564885496183206, 'mean_word_length': 7.553524804177545, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '12737', 'license': 'Apache-2.0', 'n_tokens_mistral': 1211, 'n_tokens_neox': 1116, 'n_words': 204, 'path': 'Auto_scripts/Avocado/Auto-sklearn-Avocado.ipynb', 'repo_name': 'Thomas92330/automlbench', 'size': '3275'}