Giter Site home page Giter Site logo

create unit tests about feat HOT 17 CLOSED

cavalab avatar cavalab commented on August 16, 2024
create unit tests

from feat.

Comments (17)

lacava avatar lacava commented on August 16, 2024

see https://github.com/google/googletest

from feat.

lacava avatar lacava commented on August 16, 2024

a starting list of tests:

Fewtwo :

  • 1. test setting functions in fewtwo correctly set data members
  • 2. predict, transform, fit_predict and fit_transform return correct size vectors and matrices
  • 3. fewtwo returns a perfect training mse on a linearly separable training set

Individual:

  • 1. get_eqn returns a valid string expression
  • 2. subtree grabs correct locations of subtree in a given program
  • 3. check_dominance correctly predicts one individual dominating another
  • 4. complexity() returns correct complexity

Population:

  • 1. get_open_loc correctly returns location not in individuals.loc
  • 2. individuals are accessible via [] operators

Node:

  • 1. make sure evaluate function produces stacks with no infs or nan values. focus on edges cases, i.e. division by zero.

Parameters:

  • 1. check that set functions work
  • 2. make sure msg command works correctly with varying levels of verbosity

Evaluation:

  • 1. assign_fit produces an expected output and correct mse for a given program
  • 2. fitness produces an expected output and correct mse for a given population
  • 3. out_ml produces correct size and expected output given an input matrix and target values. test with linear regression and decision tree.
  • 4. check for nan outputs

Selection / SelectionOperator:

  • 1. check that selection operators return correct number of selected parents

Variation:

  • 1. crossover produces valid programs
  • 2. mutation produces valid programs

(you can define a "valid" program as one whose total arity is satisfied when marching from beginning to end. see these tests

The tests form the first version of few here might provide some guidelines.

from feat.

tilakhere avatar tilakhere commented on August 16, 2024

done for

Fewtwo :

  1. test setting functions in fewtwo correctly set data members

note :- predict() and transform() functions are not available in fewtwo need to implement them

Individual:

  1. get_eqn returns a valid string expression (need to check if string is valid)

Node:

  1. make sure evaluate function produces stacks with no infs or nan values. focus on edges cases, i.e. division by zero. (need to do for nodevariable and nodeConstants(both binary and floating))

commit

Issues faced :- need to move some attributes from private to public to test

from feat.

tilakhere avatar tilakhere commented on August 16, 2024

link for setting up google tests

from feat.

lacava avatar lacava commented on August 16, 2024

@tilakhere checkout https://github.com/lacava/fewtwo/blob/variation/src/population.h#L80 for an example of checking program validity. this should be re-incorporated as a unit test.

from feat.

tilakhere avatar tilakhere commented on August 16, 2024

cool.

from feat.

tilakhere avatar tilakhere commented on August 16, 2024

done for

Population:

  • get_open_loc correctly returns location not in individuals.loc

NOTE :- guess we need to put some check or assert in this function so that its not being called for more than the number of locations in the vector)

  • individuals are accessible via [] operators

Variation:

  • crossover produces valid programs
  • mutation produces valid programs

Parameters:

  • check that set functions work
  • make sure msg command works correctly with varying levels of verbosity

didn't commit them right now as there are some issues with fewtwo currently causing the tests to fail abnormally.

from feat.

lacava avatar lacava commented on August 16, 2024

with the current commit i'm getting the error

/code/fewtwo/tests$ make -C build
make: Entering directory '/code/fewtwo/tests/build'
make[1]: Entering directory '/code/fewtwo/tests/build'
make[2]: Entering directory '/code/fewtwo/tests/build'
Scanning dependencies of target runTests
make[2]: Leaving directory '/code/fewtwo/tests/build'
make[2]: Entering directory '/code/fewtwo/tests/build'
[ 50%] Building CXX object CMakeFiles/runTests.dir/gtest.cc.o
[100%] Linking CXX executable runTests
CMakeFiles/runTests.dir/gtest.cc.o: In function `__static_initialization_and_destruction_0(int, int)':
gtest.cc:(.text+0x1c0d7): undefined reference to `testing::internal::MakeAndRegisterTestInfo(char const*, char const*, char const*, char const*, void const*, void (*)(), void (*)(), testing::internal::TestFactoryBase*)'
gtest.cc:(.text+0x1c124): undefined reference to `testing::internal::MakeAndRegisterTestInfo(char const*, char const*, char const*, char const*, void const*, void (*)(), void (*)(), testing::internal::TestFactoryBase*)'
gtest.cc:(.text+0x1c171): undefined reference to `testing::internal::MakeAndRegisterTestInfo(char const*, char const*, char const*, char const*, void const*, void (*)(), void (*)(), testing::internal::TestFactoryBase*)'
gtest.cc:(.text+0x1c1be): undefined reference to `testing::internal::MakeAndRegisterTestInfo(char const*, char const*, char const*, char const*, void const*, void (*)(), void (*)(), testing::internal::TestFactoryBase*)'
gtest.cc:(.text+0x1c20b): undefined reference to `testing::internal::MakeAndRegisterTestInfo(char const*, char const*, char const*, char const*, void const*, void (*)(), void (*)(), testing::internal::TestFactoryBase*)'
CMakeFiles/runTests.dir/gtest.cc.o:gtest.cc:(.text+0x1c258): more undefined references to `testing::internal::MakeAndRegisterTestInfo(char const*, char const*, char const*, char const*, void const*, void (*)(), void (*)(), testing::internal::TestFactoryBase*)' follow
collect2: error: ld returned 1 exit status
CMakeFiles/runTests.dir/build.make:95: recipe for target 'runTests' failed
make[2]: *** [runTests] Error 1
make[2]: Leaving directory '/code/fewtwo/tests/build'
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/runTests.dir/all' failed
make[1]: *** [CMakeFiles/runTests.dir/all] Error 2
make[1]: Leaving directory '/code/fewtwo/tests/build'
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
make: Leaving directory '/code/fewtwo/tests/build'

from feat.

lacava avatar lacava commented on August 16, 2024

nvm, i reinstalled google tests via the instructions and it works fine.

from feat.

lacava avatar lacava commented on August 16, 2024

note that I pushed some changes to reflect new data members in the Parameters class

from feat.

tilakhere avatar tilakhere commented on August 16, 2024

tests done for (commit fef5f65)

Individual :-

  • subtree grabs correct locations of subtree in a given program
  • check_dominance correctly predicts one individual dominating another (FAILING currently, I think this should have >= check instead of only > according to our discussion last week. Not sure and hence didnt make any changes to the code to confirm it)
  • complexity() returns correct complexity

Evaluation

  • assign_fit produces an expected output and correct mse for a given program
  • out_ml produces correct size and expected output given an input matrix and target values. test with linear regression and decision tree.

NOTE :- out_ml is not working properly hence tests not running up correctly. Runs correctly maybe 1 time out of 20-30 tries. Throws segmentation fault (core dump) or Bus error (core dumped) sometimes.

Some error in converting eigen matrix and vectors to shogun
Evaluation.h line 146 and 147

auto features = some<CDenseFeatures<float64_t>>(SGMatrix<float64_t>(X));
auto labels = some(SGVector<float64_t>(y));

from feat.

lacava avatar lacava commented on August 16, 2024

what is the error?

from feat.

tilakhere avatar tilakhere commented on August 16, 2024

segmentation fault

from feat.

lacava avatar lacava commented on August 16, 2024

unit_test for assign_fit:
ind = Individual();
ind.loc = 0;
MatrixXd F(10,1);

for the regression case (params.classification = false)
yhat = 0,1,2,3,4,5,6,7,8,9
y = 0,0,0,0,0,0,0,0,0,0

assert (F.col(ind.loc) == [ 0., 1., 4., 9., 16., 25., 36., 49., 64., 81.])
assert ( ind.fitness = 28.5)

for classification (params.classification=true)
yhat = 0,1,2,3,4,5,6,7,8,9
y = 0,1,2,0,1,2,0,1,2,0
assert (F = [0, 0, 0, 1, 1, 1, 1, 1, 1, 1])
assert ( ind.fitness == 0.7)

from feat.

tilakhere avatar tilakhere commented on August 16, 2024

New tests added

Fewtwo :

  • predict, transform, fit_predict and fit_transform return correct size vectors and matrices

Evaluation:

  • assign_fit produces an expected output and correct mse for a given program
  • check for nan outputs

Commit fc05833

from feat.

lacava avatar lacava commented on August 16, 2024

merged to master (b15c302)

from feat.

tilakhere avatar tilakhere commented on August 16, 2024

New test added
Selection / SelectionOperator:
check that selection operators return correct number of selected parents

commit ddd3731

from feat.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.