├── FFM ├── model │ ├── gbdt │ │ ├── gbdt │ │ ├── src │ │ │ ├── timer.h │ │ │ ├── timer.cpp │ │ │ ├── gbdt.h │ │ │ ├── common.h │ │ │ ├── train.cpp │ │ │ ├── common.cpp │ │ │ └── gbdt.cpp │ │ ├── Makefile │ │ └── README │ └── libffm-1.13 │ │ ├── ffm-train │ │ ├── ffm-predict │ │ ├── Makefile │ │ ├── Makefile.win │ │ ├── COPYRIGHT │ │ ├── ffm.h │ │ ├── ffm-predict.cpp │ │ ├── ffm-train.cpp │ │ ├── README │ │ └── ffm.cpp ├── utils │ ├── make_submission.py │ ├── pre-a.py │ ├── pre-b.py │ └── data_helpers.py ├── run.py └── README.md ├── .gitignore ├── CatBoost ├── model │ └── cb.py └── utils │ └── data_helpers.py ├── README.md ├── NN └── input │ ├── validation │ └── script │ │ └── isrc_process.py │ └── training │ └── script │ ├── isrc_process.py │ ├── cnt_log_process.py │ └── id_process.py ├── LightGBM ├── utils │ └── data_helpers.py └── model │ └── lbgm.py ├── XGBoost ├── utils │ └── data_helpers.py └── model │ └── xgb.py └── LICENSE /FFM/model/gbdt/gbdt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RandolphVI/Music-Recommendation-System/HEAD/FFM/model/gbdt/gbdt -------------------------------------------------------------------------------- /FFM/model/libffm-1.13/ffm-train: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RandolphVI/Music-Recommendation-System/HEAD/FFM/model/libffm-1.13/ffm-train -------------------------------------------------------------------------------- /FFM/model/libffm-1.13/ffm-predict: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RandolphVI/Music-Recommendation-System/HEAD/FFM/model/libffm-1.13/ffm-predict -------------------------------------------------------------------------------- /FFM/model/gbdt/src/timer.h: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | class Timer 4 | { 5 | public: 6 | Timer(); 7 | void reset(); 8 | void tic(); 9 | float toc(); 10 | float get(); 11 | private: 12 | std::chrono::high_resolution_clock::time_point begin; 13 | std::chrono::milliseconds duration; 14 | }; 15 | -------------------------------------------------------------------------------- /FFM/model/gbdt/Makefile: -------------------------------------------------------------------------------- 1 | CXX = g++-7 2 | CXXFLAGS = -Wall -Wconversion -O2 -fPIC -std=c++0x -march=native -fopenmp 3 | MAIN = gbdt 4 | FILES = common.cpp timer.cpp gbdt.cpp 5 | SRCS = $(FILES:%.cpp=src/%.cpp) 6 | HEADERS = $(FILES:%.cpp=src/%.h) 7 | 8 | all: $(MAIN) 9 | 10 | gbdt: src/train.cpp $(SRCS) $(HEADERS) 11 | $(CXX) $(CXXFLAGS) -o $@ $< $(SRCS) 12 | 13 | clean: 14 | rm -f $(MAIN) 15 | -------------------------------------------------------------------------------- /FFM/model/libffm-1.13/Makefile: -------------------------------------------------------------------------------- 1 | CXX = g++-7 2 | CXXFLAGS = -Wall -O3 -std=c++0x -march=native 3 | 4 | # comment the following flags if you do not want to use OpenMP 5 | DFLAG += -DUSEOMP 6 | CXXFLAGS += -fopenmp 7 | 8 | all: ffm-train ffm-predict 9 | 10 | ffm-train: ffm-train.cpp ffm.o 11 | $(CXX) $(CXXFLAGS) -o $@ $^ 12 | 13 | ffm-predict: ffm-predict.cpp ffm.o 14 | $(CXX) $(CXXFLAGS) -o $@ $^ 15 | 16 | ffm.o: ffm.cpp ffm.h 17 | $(CXX) $(CXXFLAGS) $(DFLAG) -c -o $@ $< 18 | 19 | clean: 20 | rm -f ffm-train ffm-predict ffm.o 21 | -------------------------------------------------------------------------------- /FFM/utils/make_submission.py: -------------------------------------------------------------------------------- 1 | # -*- coding:utf-8 -*- 2 | __author__ = 'Randolph' 3 | 4 | import argparse 5 | import sys 6 | 7 | if len(sys.argv) == 1: 8 | sys.argv.append('-h') 9 | 10 | parser = argparse.ArgumentParser(description='process some integers') 11 | parser.add_argument('out_path', type=str) 12 | parser.add_argument('submission_path', type=str) 13 | args = parser.parse_args() 14 | 15 | OUT_PATH, SUB_PATH = args.out_path, args.submission_path 16 | 17 | with open(SUB_PATH, 'w') as f: 18 | f.write('id,target\n') 19 | for i, line in enumerate(open(OUT_PATH)): 20 | f.write('{0},{1}'.format(i, line)) 21 | -------------------------------------------------------------------------------- /FFM/model/libffm-1.13/Makefile.win: -------------------------------------------------------------------------------- 1 | CXX = cl.exe 2 | CFLAGS = /nologo /O2 /EHsc /D "_CRT_SECURE_NO_DEPRECATE" /D "USEOMP" /openmp 3 | 4 | TARGET = windows 5 | 6 | all: $(TARGET) $(TARGET)\ffm-train.exe $(TARGET)\ffm-predict.exe 7 | 8 | $(TARGET)\ffm-predict.exe: ffm.h ffm-predict.cpp ffm.obj 9 | $(CXX) $(CFLAGS) ffm-predict.cpp ffm.obj -Fe$(TARGET)\ffm-predict.exe 10 | 11 | $(TARGET)\ffm-train.exe: ffm.h ffm-train.cpp ffm.obj 12 | $(CXX) $(CFLAGS) ffm-train.cpp ffm.obj -Fe$(TARGET)\ffm-train.exe 13 | 14 | ffm.obj: ffm.cpp ffm.h 15 | $(CXX) $(CFLAGS) -c ffm.cpp 16 | 17 | .PHONY: $(TARGET) 18 | $(TARGET): 19 | -mkdir $(TARGET) 20 | 21 | clean: 22 | -erase /Q *.obj *.exe $(TARGET)\. 23 | -rd $(TARGET) 24 | -------------------------------------------------------------------------------- /FFM/model/gbdt/src/timer.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "timer.h" 3 | 4 | Timer::Timer() 5 | { 6 | reset(); 7 | } 8 | 9 | void Timer::reset() 10 | { 11 | begin = std::chrono::high_resolution_clock::now(); 12 | duration = 13 | std::chrono::duration_cast(begin-begin); 14 | } 15 | 16 | void Timer::tic() 17 | { 18 | begin = std::chrono::high_resolution_clock::now(); 19 | } 20 | 21 | float Timer::toc() 22 | { 23 | duration += std::chrono::duration_cast 24 | (std::chrono::high_resolution_clock::now()-begin); 25 | return (float)duration.count()/1000; 26 | } 27 | 28 | float Timer::get() 29 | { 30 | float time = toc(); 31 | tic(); 32 | return time; 33 | } 34 | -------------------------------------------------------------------------------- /FFM/model/gbdt/src/gbdt.h: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "common.h" 6 | 7 | struct TreeNode 8 | { 9 | TreeNode() : idx(0), feature(-1), threshold(0), gamma(0) {} 10 | uint32_t idx; 11 | int32_t feature; 12 | float threshold, gamma; 13 | }; 14 | 15 | class CART 16 | { 17 | public: 18 | CART() : tnodes(max_tnodes) 19 | { 20 | for(uint32_t i = 1; i <= max_tnodes; ++i) 21 | tnodes[i].idx = i; 22 | } 23 | void fit(Problem const &prob, std::vector const &R, 24 | std::vector &F1); 25 | std::pair predict(float const * const x) const; 26 | 27 | static uint32_t max_depth, max_tnodes; 28 | 29 | private: 30 | static std::mutex mtx; 31 | static bool verbose; 32 | std::vector tnodes; 33 | }; 34 | 35 | class GBDT 36 | { 37 | public: 38 | GBDT(uint32_t const nr_tree) : trees(nr_tree), bias(0) {} 39 | void fit(Problem const &Tr, Problem const &Va); 40 | float predict(float const * const x) const; 41 | std::vector get_indices(float const * const x) const; 42 | 43 | private: 44 | std::vector trees; 45 | float bias; 46 | }; 47 | -------------------------------------------------------------------------------- /FFM/model/gbdt/README: -------------------------------------------------------------------------------- 1 | Data Format 2 | =========== 3 | The input of this GBDT solver consists of a label vector (y), a dense matrix 4 | (XD), and a binary sparse matrix (XS). The input format of these two matrices 5 | are introduced in the following two sections. 6 | 7 | Dense Matrix 8 | ------------ 9 | The input format is: 10 | 11 |