{"metadata":{"kernelspec":{"language":"python","display_name":"Python 3","name":"python3"},"language_info":{"pygments_lexer":"ipython3","nbconvert_exporter":"python","version":"3.6.4","file_extension":".py","codemirror_mode":{"name":"ipython","version":3},"name":"python","mimetype":"text/x-python"}},"nbformat_minor":4,"nbformat":4,"cells":[{"cell_type":"code","source":"n1,n2 = 1800,1900 # not yet launched \nprint(n1,'-',n2)","metadata":{"execution":{"iopub.status.busy":"2023-05-14T07:00:00.334761Z","iopub.execute_input":"2023-05-14T07:00:00.335249Z","iopub.status.idle":"2023-05-14T07:00:00.344799Z","shell.execute_reply.started":"2023-05-14T07:00:00.335206Z","shell.execute_reply":"2023-05-14T07:00:00.342708Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"# This Python 3 environment comes with many helpful analytics libraries installed\n# It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python\n# For example, here's several helpful packages to load\n\nimport time\nt0start = time.time()\n\nimport matplotlib.pyplot as plt\nimport seaborn as sns\n\nimport numpy as np # linear algebra\nimport pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)\n\n# Input data files are available in the read-only \"../input/\" directory\n# For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory\n\nimport os\nfor dirname, _, filenames in os.walk('/kaggle/input'):\n    for filename in filenames:\n        print(os.path.join(dirname, filename))\n\n# You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using \"Save & Run All\" \n# You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session","metadata":{"_uuid":"8f2839f25d086af736a60e9eeb907d3b93b6e0e5","_cell_guid":"b1076dfc-b9ad-4769-8c92-a6c4dae69d19","execution":{"iopub.status.busy":"2023-05-13T20:33:19.301687Z","iopub.execute_input":"2023-05-13T20:33:19.302238Z","iopub.status.idle":"2023-05-13T20:33:19.377258Z","shell.execute_reply.started":"2023-05-13T20:33:19.302178Z","shell.execute_reply":"2023-05-13T20:33:19.375594Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"%%time\n# import scipy\nimport scipy.sparse\nY = scipy.sparse.load_npz('/kaggle/input/cafa5-data-selected/Y_31466_sparse_float32.npz')\nprint(Y.shape)\n# Y = Y[:,:n_labels_to_consider].toarray()\nY","metadata":{"execution":{"iopub.status.busy":"2023-05-13T20:37:18.746431Z","iopub.execute_input":"2023-05-13T20:37:18.746969Z","iopub.status.idle":"2023-05-13T20:37:19.111064Z","shell.execute_reply.started":"2023-05-13T20:37:18.746926Z","shell.execute_reply":"2023-05-13T20:37:19.109834Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"features = 'T5'\nif features == 'T5':  \n    fn = '/kaggle/input/t5embeds/train_embeds.npy'\n    fn4submit = '/kaggle/input/t5embeds/test_embeds.npy'\n    str_data_inf = 'CAFA5 T5 embeddings train'\n    \ndef load_features(fn ):\n    if '.csv' in fn:\n        df = pd.read_csv(fn, index_col = 0)\n    #     df = df.rank(axis = 1 )\n        X = df.values\n    elif '.npy' in fn:\n        X = np.load(fn)\n    print(X.shape)\n\n    return X\n\nX =     load_features(fn )\nprint(X.shape)\nX_submit =     load_features(fn4submit )\nprint(X_submit.shape)\n\n        ","metadata":{"execution":{"iopub.status.busy":"2023-05-13T20:37:20.202233Z","iopub.execute_input":"2023-05-13T20:37:20.203145Z","iopub.status.idle":"2023-05-13T20:37:42.297376Z","shell.execute_reply.started":"2023-05-13T20:37:20.203095Z","shell.execute_reply":"2023-05-13T20:37:42.295949Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"%%time\nimport lightgbm as lgbm\nfrom sklearn.linear_model import Ridge\n\n# model = Ridge(alpha = 10 )\n\nparams = {'n_estimators': 500, 'reg_alpha': 6.734991732483901, 'reg_lambda': 3.0151837674804667, \n          'colsample_bytree': 0.9, 'subsample': 1.0, 'max_depth': 6, 'learning_rate': 0.03814860248977263, \n          'num_leaves': 859, 'min_child_samples': 13,\n         'random_state':np.random.randint(0,10_000)#117\n         }\nmodel = lgbm.LGBMRegressor( **params ) \n\nprint(model)","metadata":{"execution":{"iopub.status.busy":"2023-05-13T20:48:11.798654Z","iopub.execute_input":"2023-05-13T20:48:11.799153Z","iopub.status.idle":"2023-05-13T20:48:11.808825Z","shell.execute_reply.started":"2023-05-13T20:48:11.799111Z","shell.execute_reply":"2023-05-13T20:48:11.807576Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"%%time\nimport gc\nimport time\nt00 = time.time()\nfor i_tg in range(n1,n2):\n    y = np.asarray(Y[:,i_tg].toarray()).ravel()\n    t0 = time.time()\n    model.fit(X, y)\n    time_fit = np.round(time.time() - t0,2)\n    \n    t0 = time.time()\n    y_pred = model.predict(X_submit)\n    time_predict = np.round(time.time() - t0,2)\n    \n    print(i_tg,time_fit, time_predict, y_pred.shape, np.round(y_pred[:3],3)  )\n    np.save('y_pred_'+str(i_tg), y_pred  )\n    \n    gc.collect()\n    ","metadata":{"execution":{"iopub.status.busy":"2023-05-13T20:48:19.289798Z","iopub.execute_input":"2023-05-13T20:48:19.290227Z","iopub.status.idle":"2023-05-13T20:58:23.198188Z","shell.execute_reply.started":"2023-05-13T20:48:19.29019Z","shell.execute_reply":"2023-05-13T20:58:23.197194Z"},"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{"trusted":true},"execution_count":null,"outputs":[]},{"cell_type":"code","source":"","metadata":{},"execution_count":null,"outputs":[]}]}