diff --git a/predihood/classes/Classifier.py b/predihood/classes/Classifier.py index 11bdb62582a0dd9c8629dcb9fcad3debd60b4412..9be06c35c7b3b41fdd35e1e95522f1fe3e852d73 100644 --- a/predihood/classes/Classifier.py +++ b/predihood/classes/Classifier.py @@ -13,4 +13,4 @@ class Classifier: def set_params(self, **parameters): for parameter, value in parameters.items(): setattr(self, parameter, value) - return self \ No newline at end of file + return self diff --git a/predihood/static/css/styles.css b/predihood/static/css/styles.css index b9ba52570170460290354ca2d4a45829f85004f0..02f6de538a1e22ed1e6a164d539b1f2a0d0374a8 100644 --- a/predihood/static/css/styles.css +++ b/predihood/static/css/styles.css @@ -2,8 +2,6 @@ html, body { width: 100%; height: 100%; padding: 0; - overflow-x: scroll; - overflow-y: scroll; } header { @@ -77,7 +75,6 @@ h3 { } */ - .fa-angle-double-down, .fa-angle-double-up { margin-left: 0.5rem; } @@ -85,53 +82,16 @@ h3 { /**************************************************/ -/*.vertical-nav {*/ -/* min-width: 17rem;*/ -/* width: 17rem;*/ -/* height: 100vh;*/ -/* position: fixed;*/ -/* top: 0;*/ -/* left: 0;*/ -/* box-shadow: 3px 3px 10px rgba(0, 0, 0, 0.1);*/ -/* transition: all 0.4s;*/ -/* overflow-x: scroll; !* allow to scroll in the menu *!*/ -/*}*/ - .page-content { width: calc(100% - 17rem); margin-left: 17rem; transition: all 0.4s; } -/* for toggle behavior */ -/*#sidebar.active {*/ -/* margin-left: -17rem;*/ -/*}*/ - -/*#content.active {*/ -/* width: 100%;*/ -/* margin: 0;*/ -/*}*/ - -/*@media (max-width: 768px) {*/ -/* !* small devices *!*/ -/* #sidebar {*/ -/* margin-left: -17rem;*/ -/* }*/ - -/* #sidebar.active {*/ -/* margin-left: 0;*/ -/* }*/ - #content { text-align: left; } -/* #content.active {*/ -/* margin-left: 17rem;*/ -/* width: calc(100% - 17rem);*/ -/* }*/ -/*}*/ .separator { margin: 3rem 0; @@ -146,7 +106,6 @@ h3 { font-size: 0.9rem; } - .table-hover tbody tr:hover { background-color: lightgray; } diff --git a/predihood/static/img/logo-imu.png b/predihood/static/img/logo-imu.png new file mode 100644 index 0000000000000000000000000000000000000000..686bd5285a2d9f45831b7a72e97eb51b9d8f72b6 Binary files /dev/null and b/predihood/static/img/logo-imu.png differ diff --git a/predihood/static/img/logo-insee.jpg b/predihood/static/img/logo-insee.jpg new file mode 100644 index 0000000000000000000000000000000000000000..0352fa97a0f9234cbb7830af908f05ddbd952a60 Binary files /dev/null and b/predihood/static/img/logo-insee.jpg differ diff --git a/predihood/static/img/liris.png b/predihood/static/img/logo-liris.png similarity index 100% rename from predihood/static/img/liris.png rename to predihood/static/img/logo-liris.png diff --git a/predihood/templates/footer.html b/predihood/templates/footer.html index 78d0124f734989996f8ade5fec6ae6693dfc4195..62198f2df72c6d89e3d3310af33fa8cf05eba1a4 100644 --- a/predihood/templates/footer.html +++ b/predihood/templates/footer.html @@ -1,18 +1,8 @@ <footer> <hr> <div style="display: flex; justify-content: space-around;"> - <a href="https://liris.cnrs.fr/"><img src="{{url_for('static', filename='img/liris.png')}}" width="111px" height="50px" alt="Laboratoire d'InfoRmatique en Imagerie et Systèmes d'information"/></a> - <a href="http://imu.universite-lyon.fr/projet/hil-intelligence-artificielle-pour-faciliter-la-recherche-immobiliere-systeme-de-recommandation-avec-visualisation-spatiale-et-non-spatiale-pour-la-recherche-immobiliere-2017/"> - <img src="{{url_for('static', filename='img/imu.jpg')}}" width="126px" height="50px" alt="Laboratoire d'Excellence - Intelligence des Mondes Urbains"/> - </a> - </div> - <hr> - <div style="display: flex; justify-content: space-around;"> - {% if language == "french" %} - <span>Sources de données<br>(statistiques, IRIS)</span> - {% else %} - <span>Data sources<br>(statistics, IRIS)</span> - {% endif %} - <a href="http://www.insee.fr/"><img src="{{url_for('static', filename='img/insee.jpg')}}" width="43px" height="50px" alt="INSEE"/></a> + <a href="https://liris.cnrs.fr/"><img src="{{url_for('static', filename='img/logo-liris.png')}}" height="50px" alt="LIRIS"/></a> + <a href="http://imu.universite-lyon.fr/projet/hil-intelligence-artificielle-pour-faciliter-la-recherche-immobiliere-systeme-de-recommandation-avec-visualisation-spatiale-et-non-spatiale-pour-la-recherche-immobiliere-2017/"><img src="{{url_for('static', filename='img/logo-imu.png')}}" height="50px" alt="LabEx IMU"/></a> + <a href="http://www.insee.fr/"><img src="{{url_for('static', filename='img/logo-insee.jpg')}}" height="50px" alt="INSEE"/></a> </div> </footer> \ No newline at end of file diff --git a/predihood/templates/index.html b/predihood/templates/index.html index 4724c4b9040a79f9e70f744cd030c2aa7f1ba438..472d1cb9577851622e4b926a451f369dc2770d92 100644 --- a/predihood/templates/index.html +++ b/predihood/templates/index.html @@ -31,7 +31,7 @@ <button id="btnSearch" class="btn btn-success"><a href="cartographic-interface.html" style="color: black">Rechercher un quartier</a></button> {% else %} <p>I'm looking for a new living place</p><br> - <button id="btnSearch" class="btn btn-success"><a href="cartographic-interface.html" style="color: black">Search a neighbourhood</a></button> + <button id="btnSearch" class="btn btn-success"><a href="cartographic-interface.html" style="color: black">Search neighbourhoods</a></button> {% endif %} </div> </div> @@ -44,8 +44,8 @@ <p>Je souhaite paramétrer mes algorithmes</p><br> <button id="btnTune" class="btn btn-success"><a href="algorithmic-interface.html" style="color: black">Paramétrer mes algorithmes</a></button> {% else %} - <p>I want to tune my classifier</p><br> - <button id="btnTune" class="btn btn-success"><a href="algorithmic-interface.html" style="color: black">Tune my classifiers</a></button> + <p>I want to tune and run classifiers</p><br> + <button id="btnTune" class="btn btn-success"><a href="algorithmic-interface.html" style="color: black">Run classifiers</a></button> {% endif %} </div> </div> diff --git a/predihood/tests_selection.py b/predihood/tests_selection.py index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..1e5640fd2331512da69620dce814923640fe3087 100644 --- a/predihood/tests_selection.py +++ b/predihood/tests_selection.py @@ -0,0 +1,30 @@ +#!/usr/bin/env python +# encoding: utf-8 +# ============================================================================= +# Unit tests for predihood. +# ============================================================================= +import os + +import pandas as pd +import unittest + +from predihood.config import FOLDER_DATASETS, ENVIRONMENT_VALUES + + +class TestCase(unittest.TestCase): + """ + A class for Predihood unit tests. + """ + + def test_values_dataset(self): + # test if values used in dataset are the same than the one declared by social science researchers + filename = os.path.join(FOLDER_DATASETS, "data_density.csv") + dataset = pd.read_csv(filename) + values_for_building_type = set([value for key, value in ENVIRONMENT_VALUES["building_type"].items()]) + + assert set(dataset["building_type"].tolist()) == values_for_building_type + + +if __name__ == "__main__": + unittest.main(verbosity=2) # run all tests with verbose mode + diff --git a/predihood/tests_utility_functions.py b/predihood/tests_utility_functions.py index f945fb1165452fd0c590d476a99a83e740c70e6a..e7a60c59cdaf05f12fd31c282f321e8083b18157 100644 --- a/predihood/tests_utility_functions.py +++ b/predihood/tests_utility_functions.py @@ -18,26 +18,31 @@ class TestCase(unittest.TestCase): """ def test_address_to_code(self): + # test if converting an address into a code gives the correct code address = "46 avenue Victor Hugo Tassin" code = address_to_code(address) assert code == "692440201" assert 1 != "1" + # test if converting an address not located in France returns None address = "Westminster, London SW1A 0AA, United Kingdom" code = address_to_code(address) assert code is None def test_address_to_city(self): + # test if converting an address into a city gives the correct city address = "46 avenue Victor Hugo Tassin" city = address_to_city(address) assert city == "Tassin-la-Demi-Lune" def test_indicator_full_to_short_label(self): + # test if converting a full label of an indicator into its short label gives the correct short label full_label = "Pop 11-17 ans en 2014 (princ)" short_label = indicator_full_to_short_label(full_label) assert short_label == "P14_POP1117" def test_indicator_short_to_full_label(self): + # test if converting a short label of an indicator into its full label gives the correct full label short_label = "P14_POP1117" full_label = indicator_short_to_full_label(short_label) assert full_label == "Pop 11-17 ans en 2014 (princ)" @@ -46,12 +51,14 @@ class TestCase(unittest.TestCase): assert True == True # TODO def test_get_classifier(self): + # test if selecting a classifier gives the correct object classifier_name = "KNeighbors Classifier" classifier = get_classifier(classifier_name) # classifier == KNeighborsClassifier() fails because they are different objects assert type(classifier) == type(KNeighborsClassifier()) def test_set_classifier(self): + # test if setting the parameters of a classifier changes its internal parameters classifier_name = "KNeighbors Classifier" classifier = get_classifier(classifier_name) assert classifier.n_neighbors == 5 # default is 5 @@ -61,6 +68,7 @@ class TestCase(unittest.TestCase): assert classifier.n_neighbors == 10 def test_signature(self): + # test if the signature function is able to pick correct parameters classifier_name = "KNeighbors Classifier" classifier_signature = signature(classifier_name) assert "n_neighbors" in classifier_signature @@ -68,6 +76,11 @@ class TestCase(unittest.TestCase): assert classifier_signature["n_neighbors"]["default"] == "5" def test_train_test_percentages(self): + # test if train and test sizes are correctly changed if needed + train_size, test_size = check_train_test_percentages(0.7, 0.3) + assert train_size == 0.7 + assert test_size == 0.3 + train_size, test_size = check_train_test_percentages(40, 60) assert 0 < train_size < 1 assert 0 < test_size < 1 @@ -79,18 +92,21 @@ class TestCase(unittest.TestCase): assert train_size + test_size == 1 def test_intersection(self): + # test if intersection gives the correct output l1 = [1, 2, 3] l2 = [2, 3, 4] result = intersection(l1, l2) assert result == [2, 3] def test_union(self): + # test if union gives the correct output l1 = [1, 2, 3] l2 = [2, 3, 4] result = union(l1, l2) assert result == [1, 2, 3, 4] def test_similarity(self): + # test if a given value is correctly compared to already added values by checking the returned index value = "Countyside" lst = [["Houses", "House"], ["Countryside", "Countrysid"], ["Green areas"]] index = similarity(value, lst) @@ -107,12 +123,14 @@ class TestCase(unittest.TestCase): assert index == -2 def test_get_most_frequent(self): + # test if the most frequent function gives the correct value and count correctly the number of occurrences lst = ["Houses", "Houses", "Towers", "Housing estate", "Houses"] result = get_most_frequent(lst) assert result["most_frequent"] == "Houses" assert result["count_frequent"] == 3 def test_add_assessment_to_file(self): + # test if an IRIS is correctly added to the dataset and if it is not appended twice code_iris = "692440201" values = ["Houses", "Housing", "Green areas", "Peri-urban", "West", "Upper middle"] add_assessment_to_file(code_iris, values)