mercedestrenz.predict

Module Contents

Functions

predict_mercedes_price(→ int)

Predicts the price in USD of a Mercedes-Benz given the year, model,

export_mercedes_price_model(model_pipeline[, version])

Exports the sklearn model pipeline for mercedes price prediction

load_mercedes_price_model([version])

Loads the sklearn model for mercedes price prediction

mercedestrenz.predict.predict_mercedes_price(model: str, year: int, odometer_mi: int, condition: str, paint_color: str, version='v1') int[source]

Predicts the price in USD of a Mercedes-Benz given the year, model, condition, paint color and odometer reading.

Uses a pre-trained model built into the package to predict the price of the mercedes. The model was trained on data from 1990 to 2022.

Parameters:
  • model (str) – The model of the Mercedes-Benz.

  • year (int) – The year the Mercedes-Benz was made.

  • condition (str) – The condition of the Mercedes-Benz. Options: ‘new’, ‘like new’, ‘excellent’, ‘good’, ‘fair’, ‘salvage’.

  • odometer_mi (int) – The odometer reading in miles.

  • paint_color (str) – The color of the paint.

  • version (str, optional) – Model version to use if multiple available, by default “v1”.

Returns:

The predicted price of the Mercedes-Benz in USD.

Return type:

int

Raises:
  • ValueError – If the year is not between 1929 and 2021.

  • ValueError – If the model is not in the training set.

  • ValueError – If the condition is not one of the following: ‘new’, ‘like new’, ‘excellent’, ‘good’, ‘fair’, ‘used’, ‘salvage’.

Examples

>>> from mercedestrenz.modelling import predict_mercedes_price
>>> predict_mercedes_price("e-class", 2015, 55_000, "fair", "silver")
mercedestrenz.predict.export_mercedes_price_model(model_pipeline, version='v1')[source]

Exports the sklearn model pipeline for mercedes price prediction

Parameters:
  • model_pipeline (PipeLine) – sklearn pipeline with the model and preprocessing steps

  • version (str, optional) – What to tag the model version by. By default “v1”

mercedestrenz.predict.load_mercedes_price_model(version='v1')[source]

Loads the sklearn model for mercedes price prediction

Parameters:

version (str, optional) – Model version to use if multiple available, by default “v1”

Returns:

A sklearn pipeline with the model and preprocessing steps

Return type:

Pipeline

Raises:

FileNotFoundError – If the model version is not found.