-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from j0tunn/feat/prj.13
ДЗ-13 (12). Недвижимость
- Loading branch information
Showing
12 changed files
with
18,213 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
cmake_minimum_required(VERSION 3.10) | ||
|
||
include(${CMAKE_CURRENT_SOURCE_DIR}/../../common/CMakeLists.txt) | ||
|
||
project(fashion_mnist VERSION ${PROJECT_VERSION}) | ||
|
||
add_library(utils_lib | ||
utils.cpp | ||
) | ||
|
||
# catboost | ||
include_directories(${CMAKE_CURRENT_BINARY_DIR}) | ||
target_link_directories(utils_lib PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/catboost/static) | ||
target_link_libraries(utils_lib PUBLIC catboostmodel) | ||
|
||
add_executable(${PROJECT_NAME} | ||
main.cpp | ||
) | ||
target_link_libraries(${PROJECT_NAME} utils_lib) | ||
|
||
# Tests | ||
add_executable(test | ||
model_test.cc | ||
fixtures | ||
) | ||
target_link_libraries(test PUBLIC utils_lib) | ||
|
||
add_custom_command( | ||
OUTPUT fixtures | ||
COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_CURRENT_SOURCE_DIR}/fixtures ${CMAKE_CURRENT_BINARY_DIR}/fixtures | ||
) | ||
|
||
setupGTest(test) | ||
|
||
# Package | ||
setupCPack(${PROJECT_NAME}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
diff --git a/catboost/libs/model/ya.make b/catboost/libs/model/ya.make | ||
index 7f97b04542..f5a627da48 100644 | ||
--- a/catboost/libs/model/ya.make | ||
+++ b/catboost/libs/model/ya.make | ||
@@ -3,8 +3,8 @@ LIBRARY() | ||
|
||
|
||
SRCS( | ||
- GLOBAL cpu/formula_evaluator.cpp | ||
- GLOBAL model_import_interface.cpp | ||
+ cpu/formula_evaluator.cpp | ||
+ model_import_interface.cpp | ||
cpu/evaluator_impl.cpp | ||
cpu/quantization.cpp | ||
ctr_data.cpp | ||
diff --git a/library/cpp/logger/ya.make b/library/cpp/logger/ya.make | ||
index 14dfaf820a..956532ef13 100644 | ||
--- a/library/cpp/logger/ya.make | ||
+++ b/library/cpp/logger/ya.make | ||
@@ -17,12 +17,12 @@ SRCS( | ||
GLOBAL composite_creator.cpp | ||
element.cpp | ||
file.cpp | ||
- GLOBAL file_creator.cpp | ||
+ file_creator.cpp | ||
filter.cpp | ||
filter_creator.cpp | ||
log.cpp | ||
null.cpp | ||
- GLOBAL null_creator.cpp | ||
+ null_creator.cpp | ||
priority.h | ||
record.h | ||
rotating_file.cpp | ||
@@ -35,7 +35,7 @@ SRCS( | ||
GLOBAL system_creator.cpp | ||
thread.cpp | ||
thread_creator.cpp | ||
- GLOBAL uninitialized_creator.cpp | ||
+ uninitialized_creator.cpp | ||
reopen.h | ||
) | ||
|
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#include <iostream> | ||
#include <string> | ||
#include <fstream> | ||
#include <catboost/wrapped_calcer.h> | ||
#include "utils.h" | ||
|
||
using namespace std; | ||
|
||
int main(int argc, char* argv[]) { | ||
if (argc != 3) { | ||
cerr << "Usage: fashion_mnist <test-file> <model-file>\n"; | ||
return 1; | ||
} | ||
|
||
const string testFile(argv[1]); | ||
const string modelFile(argv[2]); | ||
|
||
ModelCalcerWrapper calcer(modelFile); | ||
ifstream testData(testFile); | ||
|
||
unsigned total = 0; | ||
unsigned correct = 0; | ||
for (string line; getline(testData, line);) { | ||
const auto [expected, features] = parseTestData(line); | ||
const auto actual = predict(calcer, features); | ||
|
||
++total; | ||
if (actual == expected) { | ||
++correct; | ||
} | ||
} | ||
|
||
cout << static_cast<double>(correct)/total << endl; | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#include <fstream> | ||
#include <iostream> | ||
#include <gtest/gtest.h> | ||
#include <catboost/wrapped_calcer.h> | ||
|
||
#include "utils.h" | ||
|
||
using namespace std; | ||
|
||
TEST(CatboostClassifier, testModel) { | ||
ModelCalcerWrapper calcer("fixtures/model.cbm"); | ||
ifstream testData{"fixtures/test_data_catboost.txt"}; | ||
|
||
for (string line; getline(testData, line);) { | ||
auto [expected, features] = parseTestData(line); | ||
EXPECT_EQ(predict(calcer, features), expected); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/bash | ||
|
||
mkdir deps | ||
cd deps | ||
|
||
git clone --depth 1 --branch v1.1.1 https://github.com/catboost/catboost.git | ||
cd catboost | ||
|
||
# fix static build | ||
# https://github.com/catboost/catboost/issues/2187 | ||
git apply ../../catboost-fix.diff | ||
|
||
# Looks like by default c-object build with -fPIC and cxx-objects with -fPIE | ||
# build with the same flags | ||
./ya make -DCXXFLAGS=-fPIE -DCFLAGS=-fPIE -r catboost/libs/model_interface/static | ||
|
||
cd ../../ | ||
ln -s deps/catboost/catboost/libs/model_interface catboost |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#include <sstream> | ||
#include <algorithm> | ||
#include <iterator> | ||
#include <locale> | ||
#include <memory> | ||
#include "utils.h" | ||
|
||
using namespace std; | ||
|
||
struct CommaIsSpace : ctype<char> { | ||
CommaIsSpace() : ctype<char>(get_table()) {} | ||
|
||
static mask const* get_table() { | ||
static mask rc[table_size]; | ||
|
||
rc[','] = ctype_base::space; | ||
rc[' '] = ctype_base::space; | ||
rc['\n'] = ctype_base::space; | ||
|
||
return &rc[0]; | ||
} | ||
}; | ||
|
||
pair<unsigned, vector<float> > parseTestData(const string& src) { | ||
istringstream lineStream(src); | ||
lineStream.imbue(locale(lineStream.getloc(), new CommaIsSpace)); | ||
|
||
unsigned expected; | ||
lineStream >> expected; | ||
|
||
vector<float> features; | ||
copy(istream_iterator<float>(lineStream), istream_iterator<float>(), back_inserter(features)); | ||
|
||
return make_pair(move(expected), move(features)); | ||
} | ||
|
||
unsigned predict(ModelCalcerWrapper& calcer, const vector<float>& features) { | ||
auto res = calcer.CalcMulti(features); | ||
return distance(res.begin(), max_element(res.begin(), res.end())); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#pragma once | ||
|
||
#include <vector> | ||
#include <string> | ||
#include <utility> | ||
#include <catboost/wrapped_calcer.h> | ||
|
||
std::pair<unsigned, std::vector<float> > parseTestData(const std::string& inputStream); | ||
unsigned predict(ModelCalcerWrapper& calcer, const std::vector<float>& features); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
12 | ||
13 |