SHARE
TWEET

Untitled

a guest Dec 15th, 2018 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import numpy as np
  2. import pandas as pd
  3. import os
  4.  
  5. def load_data(base_dir):
  6.     print(f"base_dir = {base_dir}")
  7.     print(os.listdir(f"{base_dir}"))
  8.     x_train = None
  9.     for i in range(1, 5):
  10.         filename = f"{base_dir}/x_train_{i}.npz"
  11.         with np.load(filename) as data:
  12.             print(f"files in {filename}: {data.files}")
  13.             temp_data = data[data.files[0]]
  14.             if x_train is None:
  15.                 x_train = temp_data
  16.             else:
  17.                 x_train = np.concatenate((x_train, temp_data))
  18.  
  19.  
  20.     with np.load(f'{base_dir}/y_train.npz') as data:
  21.         print(f"files in {base_dir}/y_train.npz: {data.files}")
  22.         y_train = data[data.files[0]]
  23.  
  24.     with np.load(f'{base_dir}/x_test.npz') as data:
  25.         print(f"files in {base_dir}/x_test.npz: {data.files}")
  26.         x_test = data[data.files[0]]
  27.     return x_train, y_train, x_test
  28.    
  29. def save_submission(submission, name="prediction.csv"):
  30.     result = pd.DataFrame(submission)
  31.     result = result.rename({0: "Label", }, axis=1)
  32.     result.index.name = "Id"
  33.     result.index += 1
  34.     result.to_csv(name)
  35.    
  36. x, y, t = load_data("../input")
  37.  
  38.  
  39. import catboost as cb
  40.  
  41. model = cb.CatBoostRegressor(loss_function='RMSE', iterations=2500, learning_rate=0.1, depth=7, l2_leaf_reg=0.07, task_type="GPU")
  42.                        
  43. model.fit(x, y * 5)
  44. submission -= np.min(submission)
  45. submission /= np.max(submission)
  46. submission *= 20
  47. save_submission(submission)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top