<jupyter_start><jupyter_text>CHAOS<jupyter_code># train_data = TabularDataset( 'drive/MyDrive/KaggleComp/train.csv')
# train_data = train_data.drop(columns='id')
# train_data.head()
# test_data = TabularDataset( 'drive/MyDrive/KaggleComp/test.csv')
# test_data = test_data.drop(columns='id')
# test_data.head()
time_limit = 6000  #seconds the experiment will run for
metric = 'roc_auc'  

label = 'song_popularity'

predictor = TabularPredictor(label, eval_metric=metric).fit(train_data, time_limit=time_limit, presets='best_quality')
print("AutoGluon infers problem type is: ", predictor.problem_type)
print("AutoGluon identified the following types of features:")
print(predictor.feature_metadata)
results = predictor.fit_summary(show_plot=True)
# randomly sampling 30% rows
val_data_lab = train_data.sample(n=int(len(train_data)*0.3), random_state=0)
predictor.leaderboard(val_data_lab, silent=True)
# predictor = TabularPredictor.load(save_path) 
val_data = val_data_lab.drop(columns = ['song_popularity'])
y_test = val_data_lab['song_popularity']
y_pred = predictor.predict(val_data)
print("Predictions:  \n", y_pred)
y_pred.value_counts()<jupyter_output><empty_output><jupyter_text>testfile creation<jupyter_code>import pandas as pd


y_predproba = predictor.predict_proba(test_data, as_multiclass=False)
submission = pd.read_csv('drive/MyDrive/KaggleComp/'+'sample_submission.csv')
submission['song_popularity'] = y_predproba
submission.to_csv('Auto_gmy_submission.csv', index=False)
submission.head()<jupyter_output><empty_output><jupyter_text>Pycaret<jupyter_code>!pip install pycaret[full]
!pip install scikit-learn==0.23.2

import sklearn
sklearn.__version__
import numpy as np
import pandas as pd 
import matplotlib as mpl
import matplotlib.pyplot as plt
from pycaret.classification import *
train_set= pd.read_csv('drive/MyDrive/KaggleComp/train.csv',index_col= 'id')
test_set = pd.read_csv('drive/MyDrive/KaggleComp/test.csv', index_col= 'id')
sample_submission = pd.read_csv('drive/MyDrive/KaggleComp/sample_submission.csv')
train_set.head()
setup(data = train_set, 
      target = 'song_popularity',
      numeric_imputation = 'median',
      fold=5,
      silent = True, 
     )
best_model = compare_models(sort = 'AUC', n_select = 3, use_gpu = True)
# single model tuning
lightgbm = create_model('lightgbm')
lightgbm = tune_model(lightgbm, optimize='AUC' )
plot_model(lightgbm, plot = 'auc')<jupyter_output><empty_output><jupyter_text>Blendtest<jupyter_code>blended = blend_models(estimator_list = best_model, fold = 5, method = 'soft')
# Well calibrated classifiers are probabilistic classifiers for which the probability output can be directly interpreted as a confidence level.

calibrated_blended = calibrate_model(blended)
plot_model(calibrated_blended, plot = 'auc')
### Submission
predictions = predict_model(lightgbm, data = test_set, raw_score=True,)
predictions.head()
predictions['Score_0']
lightgbm.predicted_probability (test_set )
sample_submission['song_popularity'] = predictions['Score_1']
sample_submission.to_csv(f'lgbmpycaret_submission.csv',index=False)<jupyter_output><empty_output><jupyter_text>Stacking randomly:<jupyter_code>from pycaret.classification import *


# creating individual models for stacking
adaboost = create_model('ada')
catboost = create_model('catboost')
gbc = create_model('gbc')
lightgbm = create_model('lightgbm')
rf = create_model('rf')

# meta model using preds from above 4
xgboost = create_model('xgboost')

# stacking models
stacker = stack_models(estimator_list = [adaboost,catboost,gbc,lightgbm, rf], meta_model = xgboost)

# stack models dynamically
top5 = compare_models(n_select = 5)
stacker = stack_models(estimator_list = top5[1:], meta_model = top5[0])
import xgboost
import catboost<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11556728232189974, 'fraction_numerical': 0.006596306068601583, 'mean_word_length': 7.983412322274882, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, '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': '474965', 'license': 'Apache-2.0', 'n_tokens_mistral': 1383, 'n_tokens_neox': 1312, 'n_words': 239, 'path': 'Scripts/AutoMLTabular.ipynb', 'repo_name': 'mainadwitiya/Kaggle-song-popularity', 'size': '3790'}