Skip to main content

housing model

Project description

Median housing value prediction

The housing data can be downloaded from https://raw.githubusercontent.com/ageron/handson-ml/master/. The script has codes to download the data. We have modelled the median house value on given housing data.

The following techniques have been used:

  • Linear regression
  • Decision Tree
  • Random Forest

Steps performed

  • We prepar and clean the data. We check and imput for missing values.
  • Features are generated and the variables are checked for correlation.
  • Multiple sampling techinuqies are evaluated. The data set is split into train and test.
  • All the above said modelling techniques are tried and evaluated. The final metric used to evaluate is mean squared error.

To run the code

  • We have to create an environment from env.yml file which is attached in this repository .
  • Command to create environment - conda env create -f env.yml
  • Command tp see newly created environment - conda env list
  • Command to activate the environment - conda activate mle-dev
  • Now execute the python script .

To execute the python script

  • We have to open the mlflow ui . my mlflow listening at - http://127.0.0.1:5000

  • you can check your mlflow uri by mlflow ui command .

  • If your mlflow is listening at different uri then need to change the mlflowrun.py line 8 remote_server_uri .

  • Now run the python script .

  • command to run the scripts - python scripts/mlflowrun.py OR

  • We can run individual file from src -> py_packages folder

  • python src/py_packages/ingest.py <--path , --log_level, --log_path --no_console_log> python src/py_packages/train.py <--train_folder,--output_folder,--log_level,--log_path,--no_consoler_log> python src/py_packages/score.py <--model-folder,--data_folder,--log_level,--log_path,--no_consoler_log>

  1. ingest_data : To download the data and split into train and test (arguments can be passed to give download path)

    • While executing the script to terminal , data will get stored as per the default settings
    • Arguments that can be passed : <--path , --log_level, --log_path --no_console_log>
      • --path :: Specify the path for the training dataset
      • --log_level :: Specify the level of log required
      • --log_path :: Specify the location where logs to be created (If not specified no logs will be created)
      • --no_console_log :: Specify the log to console
  2. train : To fit and train different models based on the training data provided

    • Argumentd that can be passed : <--train_folder,--output_folder,--log_level,--log_path,--no_consoler_log>
      • --train_folder :: Specify path with file name where the train data is present.
      • --output_folder :: Specify the location where the trained models pkl files to save.
      • --log_level :: Specify the level of log required
      • --log_path :: Specify the location where logs to be created (If not specified no logs will be created)
      • --no_console_log :: Specify the log to console
  3. score : To check the scores of model on the new data passed.

    • Argumentd that can be passed : <--model-folder,--output-folder,--log_level,--log_path,--no_consoler_log>
      • --model_folder :: Specify the location where the models pkl file saved.
      • --data_folder :: Specify the location where test datasets are present.
      • --log_level :: Specify the level of log required
      • --log_path :: Specify the location where logs to be created (If not specified no logs will be created)
      • --no_console_log :: Specify the log to console

To execute the test python script

  • Command to execute the test script of data ingestion module- python test/test_data_ingestion.py
  • Command to execute the test script of train module - python test/test_train.py
  • Command to execute the test script of score module - python test/test_score.py
  • Command to execute the test script to check the installation - python test/test_installation.py OR
  • We can directly run all 4 test script using - pytest command .

To create html in docs using sphinx

  • To document the housing package , We need to create a folder named 'docs'.
  • Command to go to docs folder - cd docs
  • Command to generates a complete documentation directory along with a make.bat file, which will be used later to generate HTML - sphinx-quickstart
  • After running the command, accept the defaults.
  • Now ,go to conf.py file. Add 'os.path.abspath('..')' above project information. Here, it will tell sphinx that the code is residing outside of the current docs folder.
  • Next, go to the extensions part and add the extensions - ["sphinx.ext.autodoc", "sphinx.ext.viewcode", "sphinx.ext.napoleon"]
  • Lastly, go to themes and replace ‘alabaster’ with ‘sphinx_rtd_theme’.
  • Now , go to parent folder - cd ..
  • Run command - sphinx-apidoc -o docs src/housing_package/
  • It will generate housing_package.rst and modules.rst files .
  • Now, include the generated modules.rst file in your index.rst
  • Go inside the docs folder and run the command - make html
  • We can see HTML files generated inside _build folder in docs .

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

housing_package-0.0.2.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

housing_package-0.0.2-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

File details

Details for the file housing_package-0.0.2.tar.gz.

File metadata

  • Download URL: housing_package-0.0.2.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.12

File hashes

Hashes for housing_package-0.0.2.tar.gz
Algorithm Hash digest
SHA256 4fbe9443eee56373fbe4896253264b5682d9b23936c9b3ab622df4bf7c694c2f
MD5 624026003ae923c029bef403601b58d9
BLAKE2b-256 ed539131c4508d9791d6ed93f42e24d13a59d1186d99d0f3fae67a03893ec85a

See more details on using hashes here.

File details

Details for the file housing_package-0.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for housing_package-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 6e68d7f1f0a0a50e3e26e0adf365a2bf3005e144f08eec59a11056b49751024d
MD5 d4284c437663811529696f8ee15c6b82
BLAKE2b-256 501ed6451b824581ee3b1fc73d581d823be32e83fe282c2794acae327847396d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page