Kaggle sushida

関連タイピング
-
Pythonプログラムを打ちまくる
プレイ回数6874英語長文60秒 -
pythonコードで、現れたタイピングです。
プレイ回数1897英語60秒 -
python 基本
プレイ回数222英字120打 -
プログラミングで良く使う英単語、構文のタイピングです!
プレイ回数3217短文英字429打 -
python
プレイ回数298英字60秒 -
python(辞書関連のメソッド)
プレイ回数879英語152打 -
Pythonで初心者が使いそうなワードのタイピング
プレイ回数468英語30秒 -
pandas
プレイ回数1431英語173打
問題文
(import pandas as pd)
import pandas as pd
(import numpy as np)
import numpy as np
(import pdb; pdb.set_trace())
import pdb; pdb.set_trace()
(sub.to_csv('submission.csv', index=False))
sub.to_csv('submission.csv', index=False)
(pd.DataFrame())
pd.DataFrame()
(seed_everything(42))
seed_everything(42)
(torch.cuda.is_available())
torch.cuda.is_available()
(class MyDataset(Dataset):)
class MyDataset(Dataset):
(%matplotlib inline)
%matplotlib inline
(from sklearn.model_selection import StratifiedKFold)
from sklearn.model_selection import StratifiedKFold
(fig, axes = plt.subplots(2, 2))
fig, axes = plt.subplots(2, 2)
(import xgboost as xgb)
import xgboost as xgb
(from lightgbm import LGBMClassifier)
from lightgbm import LGBMClassifier
(for _, test_index in kf.split(x, y):)
for _, test_index in kf.split(x, y):
(train.head())
train.head()
(model = timm.create_model("resnet50"))
model = timm.create_model("resnet50")
(torch.cuda.empty_cache())
torch.cuda.empty_cache()
(img = cv2.imread(image_path))
img = cv2.imread(image_path)
(img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB))
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
(from transformers import BertModel)
from transformers import BertModel
(import albumentations as A)
import albumentations as A
(os.environ["CUDA_VISIBLE_DEVICES"] = "")
os.environ["CUDA_VISIBLE_DEVICES"] = ""
(for i, j in enumerate(tqdm(range(100))):)
for i, j in enumerate(tqdm(range(100))):
(plt.rcParams['figure.figsize'] = 30, 30)
plt.rcParams['figure.figsize'] = 30, 30
(df['target'].value_counts())
df['target'].value_counts()
(for i, row in tqdm(df.iterrows(), total=len(df)):)
for i, row in tqdm(df.iterrows(), total=len(df)):
(!nvidia-smi)
!nvidia-smi
(import tensorflow as tf)
import tensorflow as tf
(model.compile(optimizer='adam'))
model.compile(optimizer='adam')
(gc.collect())
gc.collect()
(from sklearn.metrics import roc_auc_score)
from sklearn.metrics import roc_auc_score
(kaggle competitions download -c titanic)
kaggle competitions download -c titanic
(os.makedirs(save_dir, exist_ok=True))
os.makedirs(save_dir, exist_ok=True)
(df.reset_index(drop=True))
df.reset_index(drop=True)
(df = pd.read_csv(file_name))
df = pd.read_csv(file_name)
(vectorizer = TfidfVectorizer())
vectorizer = TfidfVectorizer()
(warnings.filterwarnings('ignore'))
warnings.filterwarnings('ignore')
(plt.figure(figsize=(14,6)))
plt.figure(figsize=(14,6))
(from sklearn.ensemble import RandomForestRegressor)
from sklearn.ensemble import RandomForestRegressor
(model.fit(train_X, train_y))
model.fit(train_X, train_y)
(print(1, 2, 3, sep=' < '))
print(1, 2, 3, sep=' < ')
(np.random.randint(low=1, high=6, size=10))
np.random.randint(low=1, high=6, size=10)
(np.zeros_like(img, dtype=np.float32))
np.zeros_like(img, dtype=np.float32)
(from xgboost import XGBClassifier)
from xgboost import XGBClassifier
(df.iloc[100:200])
df.iloc[100:200]
(print("{}: {}".format(key, value)))
print("{}: {}".format(key, value))
(docker run --rm -it kaggle/python-build /bin/bash)
docker run --rm -it kaggle/python-build /bin/bash
(docker-compose up)
docker-compose up
(git push origin master)
git push origin master
(s = pd.Series([1, 3, 5, np.nan, 6, 8]))
s = pd.Series([1, 3, 5, np.nan, 6, 8])
(df.sort_index(axis=1, ascending=False))
df.sort_index(axis=1, ascending=False)
(df.iloc[[1, 2, 4], [0, 2]])
df.iloc[[1, 2, 4], [0, 2]]
(df[df["A"] > 0])
df[df["A"] > 0]
(df.dropna(how="any"))
df.dropna(how="any")
(df.fillna(value=5))
df.fillna(value=5)
(df.apply(np.cumsum))
df.apply(np.cumsum)
(df.groupby("target").sum())
df.groupby("target").sum()
(np.arange(15).reshape(3, 5))
np.arange(15).reshape(3, 5)
(np.array([1, 2, 3, 4]))
np.array([1, 2, 3, 4])
(np.transpose(x, (1, 0, 2)).shape)
np.transpose(x, (1, 0, 2)).shape
(nn.Linear(512, 512))
nn.Linear(512, 512)
(nn.CrossEntropyLoss())
nn.CrossEntropyLoss()
(torch.optim.SGD(model.parameters(), lr=1e-3))
torch.optim.SGD(model.parameters(), lr=1e-3)
(optimizer.zero_grad())
optimizer.zero_grad()
(loss.backward())
loss.backward()
(optimizer.step())
optimizer.step()
(model.eval())
model.eval()
(torch.save(model.state_dict(), "model.pth"))
torch.save(model.state_dict(), "model.pth")
(with torch.no_grad():)
with torch.no_grad():
(nn.Parameter(torch.zeros(10)))
nn.Parameter(torch.zeros(10))
(nn.Conv2d(3, 32, kernel_size=3, stride=1, padding=1))
nn.Conv2d(3, 32, kernel_size=3, stride=1, padding=1)
(lambda x: x.view(x.size(0), -1))
lambda x: x.view(x.size(0), -1)
(x = np.linspace(-math.pi, math.pi, 2000))
x = np.linspace(-math.pi, math.pi, 2000)
(y = np.sin(x))
y = np.sin(x)
(torch.nn.MSELoss(reduction='sum'))
torch.nn.MSELoss(reduction='sum')
(boxes.append([xmin, ymin, xmax, ymax]))
boxes.append([xmin, ymin, xmax, ymax])
(img, target = self.transforms(img, target))
img, target = self.transforms(img, target)
(if __name__ == "__main__":)
if __name__ == "__main__":
(import os)
import os
(import collections)
import collections
(import json)
import json
(import numpy as np)
import numpy as np
(import tensorflow as tf)
import tensorflow as tf
(from tensorflow import keras)
from tensorflow import keras
(from tensorflow.keras import layers)
from tensorflow.keras import layers
(import tensorflow_hub as hub)
import tensorflow_hub as hub
(import tensorflow_text as text)
import tensorflow_text as text
(import tensorflow_addons as tfa)
import tensorflow_addons as tfa
(import matplotlib.pyplot as plt)
import matplotlib.pyplot as plt
(import matplotlib.image as mpimg)
import matplotlib.image as mpimg
(from tqdm import tqdm)
from tqdm import tqdm
(metric = "sparse_categorical_accuracy")
metric = "sparse_categorical_accuracy"
(plt.figure())
plt.figure()
(plt.plot(history.history[metric]))
plt.plot(history.history[metric])
(plt.plot(history.history["val_" + metric]))
plt.plot(history.history["val_" + metric])
(plt.title("model " + metric))
plt.title("model " + metric)
(plt.ylabel(metric, fontsize="large"))
plt.ylabel(metric, fontsize="large")
(plt.xlabel("epoch", fontsize="large"))
plt.xlabel("epoch", fontsize="large")
(plt.legend(["train", "val"], loc="best"))
plt.legend(["train", "val"], loc="best")
(plt.show())
plt.show()