Code Monkey home page Code Monkey logo

bbdd's Introduction

Advertising Model API ๐Ÿš€

Flask API ๐ŸŒ has several routes that allow you to make predictions, ingest data, and retrain the model.

This repository contains two main folders: data and ejercicio. The data folder contains the necessary data for the Advertising Model API, while the ejercicio folder contains the code for the API and the script to convert a CSV file into an SQLite database.

Advertising Model API ๐Ÿš€ This repository contains a Flask API for an advertising model and a script to convert a CSV file into an SQLite database.

Flask API ๐ŸŒ The Flask API has several routes that allow you to make predictions, ingest data, and retrain the model.

Routes ๐Ÿ›ฃ๏ธ ๐ŸŒˆ The / route accepts GET requests and returns a warm welcome message. ๐Ÿค—

๐Ÿ”ฎ The /v2/predict route accepts GET requests with values for tv, radio, and newspaper as arguments in the call. When a request is received, the code loads a previously trained model from the data/advertising_model file, gets the values of the arguments, and uses the model to make a prediction. Then, it returns the prediction to the client. ๐Ÿ”ฎ

๐Ÿ“ฌ The /v2/ingest_data route accepts POST requests with data in JSON format in the request body. When a request is received, the code connects to an SQLite database called advertising.db in the data directory, creates a table called advertising if it doesnโ€™t exist, and stores the received data in this table. ๐Ÿ“ฌ

๐Ÿ”ง The /v2/retrain route accepts PUT requests. When a request is received, the code loads the previously trained model from the data/advertising_model file, connects to the SQLite database, retrieves the data stored in the advertising table, converts it into a pandas DataFrame, and separates the independent and dependent variables. Then, it retrains the model using this data and saves the retrained model in the same file. ๐Ÿ”ง

SQL Database Creator Script ๐Ÿ—„๏ธ The sql_db_creator.py script reads data from a CSV file called Advertising.csv in the data directory, connects to an SQLite database called advertising.db in the same directory, and stores the data from the CSV file in this database.

The script uses pandas to read the CSV file and convert it into a DataFrame. Then, it renames the column newspaper to newpaper, as specified in your requirements. Finally, it uses the to_sql method of pandas to create a table called advertising in the SQLite database and store the data from the DataFrame in this table.

Usage ๐Ÿ’ป To use this repository, first make sure you have Python 3 installed on your machine. Then, clone this repository and navigate to its root directory.

To run the Flask API, use the following command:

python app_model_db.py

This will start a local development server at http://localhost:5000. You can then use your web browser or an HTTP client like cURL or Postman to interact with the API.

To run the SQL database creator script, use the following command:

  • python csv_to_sqlite.py

This will read data from the CSV file and store it in an SQLite database called advertising.db in the data directory.

We hope you find this repository useful! ๐Ÿ˜Š

bbdd's People

Contributors

jaterub avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.