<jupyter_start><jupyter_text>StrategyThis notebook strategy- Preprocessing- Model- Training- Prediction  Change Log- v1    - Create new notebook.  Setup  Kaggle Env for Google Colab<jupyter_code>import sys
IN_COLAB = 'google.colab' in sys.modules
COMPETE = "lish-moa"
DATASETS = [
    "yasufuminakama/iterative-stratification",
]
KERNEL_OUTPUTS = []
PACKAGES = [
    "optuna"
]
if IN_COLAB:
    # Work around for python2 exception.
    !python2 -m pip uninstall kaggle -y
    !python3 -m pip uninstall kaggle -y
    !python3 -m pip install -U -q kaggle

    !pip install -q -U git+https://github.com/IMOKURI/kaggle_on_google_colab.git

    from kaggle_on_google_colab import setup
    kaggle = setup.Setup()
    kaggle.dirs(COMPETE)

    !kaggle competitions download -p /content/zip {COMPETE}
    !unzip -q -n /content/zip/{COMPETE}.zip -d /content/{COMPETE}/input/{COMPETE}
    #for line in setup.exec_get_lines(cmd=f"kaggle competitions files --csv {COMPETE} | egrep -v \"Warning: Looks like you're using an outdated API Version|name,size,creationDate\" | cut -d , -f 1"):
    #    !unzip -q -n /content/zip/{line.decode().strip()}.zip -d /content/{COMPETE}/input/{COMPETE}

    for dataset in DATASETS:
        dataset_name = dataset.split("/")[-1]

        !kaggle datasets download -p /content/zip {dataset}
        !unzip -q -n /content/zip/{dataset_name}.zip -d /content/{COMPETE}/input/{dataset_name}

    for kernel in KERNEL_OUTPUTS:
        kernel_name = kernel.split("/")[-1]

        !kaggle kernels output -p /content/{COMPETE}/input/{kernel_name} {kernel}

    for package in PACKAGES:
        !pip install -q {package}

    # Add notebook specific setup.
    #!pip install -q -U tensorflow-addons
    #!mv /content/zip/train_drug.csv /content/{COMPETE}/input/{COMPETE}/

    %cd /content/{COMPETE}/output<jupyter_output>Building wheel for kaggle-on-google-colab (setup.py) ... [?25l[?25hdone
Download 100%.
Warning: Looks like you're using an outdated API Version, please consider updating (server 1.5.9 / client 1.5.4)
Downloading train_targets_nonscored.csv.zip to /content/zip
  0% 0.00/233k [00:00<?, ?B/s]
100% 233k/233k [00:00<00:00, 34.7MB/s]
Downloading train_drug.csv to /content/zip
  0% 0.00/535k [00:00<?, ?B/s]
100% 535k/535k [00:00<00:00, 35.9MB/s]
Downloading train_targets_scored.csv.zip to /content/zip
  0% 0.00/257k [00:00<?, ?B/s]
100% 257k/257k [00:00<00:00, 85.7MB/s]
Downloading sample_submission.csv.zip to /content/zip
  0% 0.00/38.9k [00:00<?, ?B/s]
100% 38.9k/38.9k [00:00<00:00, 40.4MB/s]
Downloading test_features.csv.zip to /content/zip
 98% 9.00M/9.16M [00:01<00:00, 9.03MB/s]
100% 9.16M/9.16M [00:01<00:00, 7.58MB/s]
Downloading train_features.csv.zip to /content/zip
 84% 46.0M/54.8M [00:03<00:01, 8.55MB/s]
100% 54.8M/54.8M [00:03<00:00, 18.1MB/s]
unzip:  cannot find or open /conte[...]<jupyter_text>Libraries<jupyter_code>import warnings
warnings.filterwarnings("ignore")
import os
import random

import numpy as np
import pandas as pd

import tensorflow as tf

import torch<jupyter_output><empty_output><jupyter_text>Environment<jupyter_code>MIXED_PRECISION = False
XLA_ACCELERATE = True

if MIXED_PRECISION:
    from tensorflow.keras.mixed_precision import experimental as mixed_precision

    if tpu:
        policy = tf.keras.mixed_precision.experimental.Policy("mixed_bfloat16")
    else:
        policy = tf.keras.mixed_precision.experimental.Policy("mixed_float16")
    mixed_precision.set_policy(policy)
    print("Mixed precision enabled")

if XLA_ACCELERATE:
    tf.config.optimizer.set_jit(True)
    print("Accelerated Linear Algebra enabled")
os.environ["CUDA_LAUNCH_BLOCKING"] = "1"
def fix_seed(seed=2020):
    random.seed(seed)
    os.environ["PYTHONHASHSEED"] = str(seed)
    np.random.seed(seed)
    tf.random.set_seed(seed)
    torch.manual_seed(seed)

    if torch.cuda.is_available():
        torch.cuda.manual_seed(seed)
        torch.cuda.manual_seed_all(seed)
        torch.backends.cudnn.deterministic = True
        torch.backends.cudnn.benchmark = False


random_seed = 22
fix_seed(random_seed)<jupyter_output><empty_output><jupyter_text>Load Data<jupyter_code>#train_df = pd.read_csv("../input/lish-moa/train_features.csv")
#test_df = pd.read_csv("../input/lish-moa/test_features.csv")
#target_df = pd.read_csv("../input/lish-moa/train_targets_scored.csv")
#submit_df = pd.read_csv("../input/lish-moa/sample_submission.csv")<jupyter_output><empty_output><jupyter_text>Preprocessing<jupyter_code><jupyter_output><empty_output><jupyter_text>Model<jupyter_code><jupyter_output><empty_output><jupyter_text>Training<jupyter_code><jupyter_output><empty_output><jupyter_text>Cross Validation<jupyter_code><jupyter_output><empty_output><jupyter_text>Postprocessing<jupyter_code><jupyter_output><empty_output><jupyter_text>Output<jupyter_code>#submit_df.to_csv("submission.csv", index=False)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1373109930527176, 'fraction_numerical': 0.047813649366571315, 'mean_word_length': 4.3673245614035086, 'pattern_counts': {'":': 0, '<': 52, '<?xml version=': 0, '>': 40, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 9, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '10', 'dir': 'jupyter-structured-clean-dedup', 'id': '586333', 'license': 'MIT', 'n_tokens_mistral': 2058, 'n_tokens_neox': 1873, 'n_words': 344, 'path': 'kaggle_basic.ipynb', 'repo_name': 'IMOKURI/kaggle_on_google_colab', 'size': '4894'}