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
def test_gini_impurity(): | |
assert round(gini_impurity([1, 1, 1, 1, 1, 1, 1, 1]), 3) == 0 | |
assert round(gini_impurity([1, 1, 1, 1, 1, 1, 1, 0]), 3) == 0.219 | |
assert round(gini_impurity([1, 1, 1, 1, 1, 1, 0, 0]), 3) == 0.375 | |
assert round(gini_impurity([1, 1, 1, 1, 1, 0, 0, 0]), 3) == 0.469 | |
assert round(gini_impurity([1, 1, 1, 1, 0, 0, 0, 0]), 3) == 0.500 | |
def test_gini_gain(): | |
assert round(gini_gain([1, 1, 1, 1, 0, 0, 0, 0], [[1, 1, 1, 1], [0, 0, 0, 0]]), 3) == 0.5 |
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
+ ------------+----------+--------+-----------------------------------------+--------+-----+-------+-------+-----------+---------+-------+----------+ | |
| PassengerId | Survived | Pclass | Name | Sex | Age | SibSp | Parch | Ticket | Fare | Cabin | Embarked | | |
+ ------------+----------+--------+-----------------------------------------+--------+-----+-------+-------+-----------+---------+-------+----------| | |
| 1 | 0 | 3 | Braund, Mr. Owen Harris | male | 22 | 1 | 0 | A/5 21171 | 7.25 | nan | S | | |
| 2 | 1 | 1 | Cumings, Mrs. John Bradley (Florence... | female | 38 | 1 | 0 | PC 17599 | 71.2833 | C85 | C | | |
| 3 | 1 | 3 | Heikkinen, Miss. Laina | female | 26 | 0 | 0 | STON/O2. | 7.925 | nan | S | | |
| 4 | 1 | 1 | Futrelle, Mrs. Jacques Heath (Lily M... | female | 35 | 1 | 0 | 113803 | |
NewerOlder