| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
In K-fold cross-validation, the aim is to generate K training/validation set pair, where training and validation sets on fold i do no overlap. First, we divide the dataset X into K parts as X1; X2; ... ; XK. Then for each fold i, we use Xi as the validation set and the remaining as the training set.
Possible values of K are 10 or 30. One extreme case of K-fold cross-validation is leave-one-out, where K = N and each validation set has only one instance. If we have more computation power, we can have multiple runs of K-fold cross-validation, such as 10 x 10 cross-validation or 5 x 2 cross-validation.
If we have very small datasets, we do not insist on the non-overlap of training and validation sets. In bootstrapping, we generate K multiple training sets, where each training set contains N examples (like the original dataset). To get N examples, we draw examples with replacement. For the validation set, we use the original dataset. The drawback of bootstrapping is that the bootstrap samples overlap more than the cross-validation sample, hence they are more dependent.
You can also see Java, Python, Cython, Swift, C, Js, Php, or C# repository.
To check if you have compatible C++ Compiler installed,
Install the latest version of Git.
In order to work on code, create a fork from GitHub page. Use Git for cloning the code to your local or below line for Ubuntu:
git clone <your-fork-git-link>
A directory called Classification-CPP will be created. Or you can use below link for exploring the code:
git clone https://github.com/starlangsoftware/Classification-CPP.git
To import projects from Git with version control:
Open CLion IDE , select Get From Version Control.
In the Import window, click URL tab and paste github URL.
Click open as Project.
Result: The imported project is listed in the Project Explorer view and files are loaded.
From IDE
After being done with the downloading and opening project, select Build Project option from Build menu. After compilation process, user can run TestClassification.cpp .
k. eğitim kümesini elde etmek için
ArrayList<T> getTrainFold(int k)
k. test kümesini elde etmek için
ArrayList<T> getTestFold(int k)
Bootstrap için BootStrap sınıfı
Bootstrap(ArrayList<T> instanceList, int seed)
Örneğin elimizdeki veriler a adlı ArrayList'te olsun. Bu veriler üstünden bir bootstrap örneklemi tanımlamak için (5 burada rasgelelik getiren seed'i göstermektedir. 5 değiştirilerek farklı samplelar elde edilebilir)
bootstrap = Bootstrap(a, 5);
ardından üretilen sample'ı çekmek için ise
sample = bootstrap.getSample();
yazılır.
K kat çapraz geçerleme için KFoldCrossValidation sınıfı
KFoldCrossValidation(List<T> instanceList, int K, int seed)
Örneğin elimizdeki veriler a adlı ArrayList'te olsun. Bu veriler üstünden 10 kat çapraz geçerleme yapmak için (2 burada rasgelelik getiren seed'i göstermektedir. 2 değiştirilerek farklı samplelar elde edilebilir)
kfold = KFoldCrossValidation(a, 10, 2);
ardından yukarıda belirtilen getTrainFold ve getTestFold metodları ile sırasıyla i. eğitim ve test kümeleri elde edilebilir.
Stratified K kat çapraz geçerleme için StratifiedKFoldCrossValidation sınıfı
StratifiedKFoldCrossValidation(ArrayList<T>[] instanceLists, int K, int seed)
Örneğin elimizdeki veriler a adlı ArrayList of listte olsun. Stratified bir çapraz geçerlemede sınıflara ait veriler o sınıfın oranında temsil edildikleri için her bir sınıfa ait verilerin ayrı ayrı ArrayList'te olmaları gerekmektedir. Bu veriler üstünden 30 kat çapraz geçerleme yapmak için (4 burada rasgelelik getiren seed'i göstermektedir. 4 değiştirilerek farklı samplelar elde edilebilir)
stratified = StratifiedKFoldCrossValidation(a, 30, 4);
ardından yukarıda belirtilen getTrainFold ve getTestFold metodları ile sırasıyla i. eğitim ve test kümeleri elde edilebilir.
pip install conan
Instructions are given in the following page:
https://docs.conan.io/2/installation.html
conan remote add ozyegin http://104.247.163.162:8081/artifactory/api/conan/conan-local --insert
conan list
requires = ["math/1.0.0", "classification/1.0.0"]
settings = "os", "compiler", "build_type", "arch"
options = {"shared": [True, False], "fPIC": [True, False]}
default_options = {"shared": True, "fPIC": True}
exports_sources = "src/*", "Test/*"
def layout(self):
cmake_layout(self, src_folder="src")
def generate(self):
tc = CMakeToolchain(self)
tc.generate()
deps = CMakeDeps(self)
deps.generate()
def build(self):
cmake = CMake(self)
cmake.configure()
cmake.build()
def package(self):
copy(conanfile=self, keep_path=False, src=join(self.source_folder), dst=join(self.package_folder, "include"), pattern="*.h")
copy(conanfile=self, keep_path=False, src=self.build_folder, dst=join(self.package_folder, "lib"), pattern="*.a")
copy(conanfile=self, keep_path=False, src=self.build_folder, dst=join(self.package_folder, "lib"), pattern="*.so")
copy(conanfile=self, keep_path=False, src=self.build_folder, dst=join(self.package_folder, "lib"), pattern="*.dylib")
copy(conanfile=self, keep_path=False, src=self.build_folder, dst=join(self.package_folder, "bin"), pattern="*.dll")
def package_info(self):
self.cpp_info.libs = ["ComputationalGraph"]
set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_FLAGS "-O3")
find_package(util_c REQUIRED) find_package(data_structure_c REQUIRED)
add_library(Math src/Distribution.cpp src/Distribution.h src/DiscreteDistribution.cpp src/DiscreteDistribution.h src/Vector.cpp src/Vector.h src/Eigenvector.cpp src/Eigenvector.h src/Matrix.cpp src/Matrix.h src/Tensor.cpp src/Tensor.h) target_link_libraries(Math util_c::util_c data_structure_c::data_structure_c m)
add_executable(DiscreteDistributionTest src/Distribution.cpp src/Distribution.h src/DiscreteDistribution.cpp src/DiscreteDistribution.h src/Vector.cpp src/Vector.h src/Eigenvector.cpp src/Eigenvector.h src/Matrix.cpp src/Matrix.h src/Tensor.cpp src/Tensor.h Test/DiscreteDistributionTest.cpp) target_link_libraries(DiscreteDistributionTest util_c::util_c data_structure_c::data_structure_c m)
bool operator==(const Word &anotherWord) const{
return (name == anotherWord.name);
}
bool operator<(const Word &anotherWord) const{
return (name < anotherWord.name);
}
/**
* A constructor of Word class which gets a String name as an input and assigns to the name variable.
*
* @param _name String input.
*/
Word::Word(const string &_name) {
int Word::charCount() const
string Word::getName() const void Word::setName(const string &_name)
#define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one cpp file
line in only one of the test files. Add
#include "catch.hpp"
line in all test files. Example test file is given below:
TEST_CASE("DictionaryTest") {
TxtDictionary lowerCaseDictionary = TxtDictionary("lowercase.txt", "turkish_misspellings.txt");
TxtDictionary mixedCaseDictionary = TxtDictionary("mixedcase.txt", "turkish_misspellings.txt");
TxtDictionary dictionary = TxtDictionary();
SECTION("testSize"){
REQUIRE(29 == lowerCaseDictionary.size());
REQUIRE(58 == mixedCaseDictionary.size());
REQUIRE(62113 == dictionary.size());
}
SECTION("testGetWord"){
for (int i = 0; i < dictionary.size(); i++){
REQUIRE_FALSE(nullptr == dictionary.getWord(i));
}
}
SECTION("testLongestWordSize"){
REQUIRE(1 == lowerCaseDictionary.longestWordSize());
REQUIRE(1 == mixedCaseDictionary.longestWordSize());
REQUIRE(21 == dictionary.longestWordSize());
}
enum class Pos {
ADJECTIVE,
NOUN,
VERB,
ADVERB,
#ifndef MATH_DISTRIBUTION_H #define MATH_DISTRIBUTION_H
and end with
#endif //MATH_DISTRIBUTION_H
void Word::setName(const string &_name);
[[nodiscard]] bool isPunctuation() const;
auto* doc = new XmlDocument("test.xml");
doc->parse();
XmlElement* root = doc->getFirstChild();
XmlElement* firstChild = root->getFirstChild();
| Back | FazBrowse Home | New Git URL |