<jupyter_start><jupyter_text>Data Profiling<jupyter_code>## Install as needed
#!pip install -U pandas-profiling
import pandas as pd 
import pandas_profiling 
# Local data cache
datadir = '../common-data/covid/'
datafile = datadir + "data.csv"
# Read data from local file
data = pd.read_csv(datafile, parse_dates=['date'])
data.head()
# Run the profile report 
profile = data.profile_report(title='Pandas Profiling Report') 
# Saving the report as html file 
profile.to_file(output_file="data/coviddata_profiling.html")<jupyter_output><empty_output><jupyter_text>Lale - select method and tune paramaters<jupyter_code>## Install if needed
#! pip install lale
# Import the datasets
import lale.datasets
# Load a data and see inside
(train_X, train_y), (test_X, test_y) = lale.datasets.california_housing_df()
data = pd.concat([train_X.head(), train_y.head()], axis=1)
data.describe()
import numpy as np

import sklearn.metrics
from sklearn.decomposition import PCA
from sklearn.tree import DecisionTreeRegressor as Tree
from sklearn.pipeline import Pipeline

from lale.lib.lale import Hyperopt
lale.wrap_imported_operators()
pca_tree_planned = Pipeline(steps=[('tfm', PCA), ('estim', Tree)])
%%time
pca_tree_trained = pca_tree_planned.auto_configure(
    train_X, train_y, optimizer=Hyperopt, cv=3, max_evals=10, verbose=True)
# Predictions
predicted = pca_tree_trained.predict(test_X)
print(f'R2 score {sklearn.metrics.r2_score(test_y, predicted):.2f}')<jupyter_output>R2 score 0.37<jupyter_text>Automated Algo Selection<jupyter_code>## Install and other issues
# !pip install auto-sklearn
## Note: If you face issue with swig, install with brew install swig
#!pip install -U scikit-learn
#!pip install auto-sklearn
import sklearn.datasets
import sklearn.metrics

import autosklearn.classification
X, y = sklearn.datasets.load_breast_cancer(return_X_y=True)
X_train, X_test, y_train, y_test = \
    sklearn.model_selection.train_test_split(X, y, random_state=1)
automl = autosklearn.classification.AutoSklearnClassifier(
    time_left_for_this_task=120,
    per_run_time_limit=30,
    tmp_folder='data/autosklearn_classification_example_tmp',
    output_folder='data/autosklearn_classification_example_out',
)
automl.fit(X_train, y_train, dataset_name='breast_cancer')
# Print the model
print(automl.show_models())
# Performance metric
predictions = automl.predict(X_test)
print("Accuracy score:", sklearn.metrics.accuracy_score(y_test, predictions))<jupyter_output>Accuracy score: 0.9440559440559441
{'fraction_non_alphanumeric': 0.10448358686949559, 'fraction_numerical': 0.013610888710968775, 'mean_word_length': 6.984025559105431, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '509060', 'license': 'MIT', 'n_tokens_mistral': 911, 'n_tokens_neox': 864, 'n_words': 194, 'path': 'sample-code/l12-explanability-autoai/auto ai exploration.ipynb', 'repo_name': 'biplav-s/course-d2d-ai', 'size': '2498'}