README.md

AutoInsight Backend

This project is a backend application built with FastAPI for predicting customer preferences for hybrid vehicle technologies. The project includes a machine learning model trained on customer data and provides predictions based on age, income, and preferred features.

Features

  • REST API for predicting customer preferences.
  • Machine learning model trained using scikit-learn.
  • Handles customer data input including age, income, and preferred features.
  • Predicts suitable hybrid technologies for vehicles (electric, hybrid, diesel, gasoline).
  • Apache Spark is now used for processing large datasets in the project.

Requirements

  • Python 3.8+
  • FastAPI
  • Uvicorn
  • scikit-learn
  • pandas
  • numpy
  • Apache Spark (if working with large datasets)
  • Java 8+ (required for Apache Spark

Installation

  1. Clone the repository:

    git clone https://github.com/your-username/autoinsight-backend.git
    cd autoinsight-backend
    
  2. Create a virtual environment and activate it:

    python -m venv venv
    source venv/bin/activate 
    
  3. Install the required packages:

pip install -r requirements.txt
  1. (Optional) To generate random customer data for testing, use the generate_data.py script in the data folder (not provided in this example).

To start the FastAPI server, run the following command:

uvicorn app.main:app --reload

The API will be accessible at http://127.0.0.1:8000.

API Endpoints

POST /predict/

Predicts suitable hybrid technologies based on customer data.

Example of request:

curl -X POST http://127.0.0.1:8000/predict -H "Content-Type: application/json" -d "{\"age\": 35, \"income\": 80000, \"preferred_features\": [\"low emission\", \"comfort\"], \"gender\": \"male\"}"

Request Body:

{
  "age": 35,
  "income": 80000,
  "preferred_features": ["low emission", "comfort"],
   "gender": "male"
}

Response:

{
  "recommended_technology": "diesel"
}

Model Training

To retrain the machine learning model, run the following script:

python app/models.py

This will retrain the model on the data from data/customers.csv and save it as model.pkl.

Конвейеры
0 успешных
0 с ошибкой