Skip to main content

A custom package for the House Price Prediction project

Project description

MLE-TRAINING

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 prepare and clean the data. We check and impute for missing values.
  • The dataset is consisting of several missing values like. the total_bedrooms column in possing around 150 missing values and the income category column is containing 207 missing values
  • We handled the missing values in 'total_bedrooms' by using the mean value for the column and used the mode (most repeated) value of the 'income_cat' column to treat its 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.

Execution of the script

  • Inorder to set up the conda environment and make the execution process isolated, a special environment 'mle-dev' was created with the help of env.yml file generated. The folowing is the command to create the environment using env.yml file

    conda env create -f env.yml

  • After creating the environment, the bug free file nonstandardcode.py was executed with the help of the following command.

    python3 nonstandardcode.py

  • The screenshot of the output from running the nonstandardcode.py successfully in the mle-dev environment was attached as part of PR description

Packaging and Testing

Breaking the nonstandardcode.py file into three files

  • The nonstandardcode.py file was converted into three seperate files namely ingest_data.py, train.py and score.py
  • The ingest_data.py file is responsible for preprocessing the data and creation of valid test and train datasets that are ready for training the model
  • The ingest_data.py file was run by giving the path to the output folder where the processed files are to be stored using the command prompt.
  • The train.py file is solely responsible for training the models. It uses different algorithms to train using the datasets and as an output,it generates the pickle files which are stored in the artifacts folder of the project
  • The score.py file is responsible for evaluating the performance of the models by considering the pickle files and prints the scores to the terminal

Running Tests

  • Created two unit tests in the tests folder of the project root folder and in that folder, two seperate folders were created, one for unit testing and one for functional testing.
  • Ran unit tests for two file, ingest_data.py and train.py files, evaluating whether the the generated outputs are valid
  • Ran functional test for the proper installation of the package in a virtualenvironment created using the subprocess inbuilt package in python

Packaging

  • Created the pyproject.toml file to create the package.The following command is used to create the package

         **python -m build** 
    
  • After converting it to a package, sphinx - a python documentation generating tool is used to create the proper documentation and to generate html document to the prepared package.

  • The following are the commands used for generating html content

           **conda install sphinx**
    
           **sphinx-quickstart**
    
  • The paths to the source code of the package are included in the conf.py file in the source directory generated by the sphinx.

  • Included the 'index.rst' file as master_doc in the conf.py file

  • The following is the command used for generating the html

           **sphinx -b html <source code folder path of the package> <source folder generated by the sphinx>**
    
  • The package can be installed by using the .whl file which was created while building the package

  • The package name is "packaged_non_std" and it can be installed as

            **from packaged_non_std import * **
    
  • Inorder to test the successfull installation of the package, try running it using the following steps

    • create a similar kind of environment with the dependencies of the packaged_non_std mentioned in the env.yml file situated in the deploy folder using the following command

      ** conda env create --name <new_env_name> --file

    • after successful installation, test the proper functioning of the package using functional tests mentioned in the tests directory of the project root folder.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

packaged_non_std_sai_bandaru-0.0.1-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

packaged_non_std_sai.bandaru-0.0.1-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file packaged_non_std_sai_bandaru-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for packaged_non_std_sai_bandaru-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 25f4510b05ef9fbc32cdf08083d3f51a646442e2fd4615961bd37c1cac39a031
MD5 31160a9ff0008fa96dbbd73dc3d0ec47
BLAKE2b-256 eea5f9d0ec06efeb0c4c82769f879d30ed66eafee7c3e4786bf130a731a7fd37

See more details on using hashes here.

File details

Details for the file packaged_non_std_sai.bandaru-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for packaged_non_std_sai.bandaru-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ec1c2d0d62f3e4bed1d91bac737ca0e28c7f1c118e0d07eb000a1f7df5d04734
MD5 2e706c08f484884273c51e88b14a5097
BLAKE2b-256 944b8af5ec899af88c3f2c85088dabe1870726b3337a6a714afa5a52bdb90e55

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