Build Machine Learning models (linear regression, ridge regression, and lasso) to predict the price of gold, silver, and the dollar against the rupiah for the next day and deploy them using flask

Regi Apriandi
Data Folks Indonesia
3 min readJul 26, 2021
Image : SpaceX
Image : SpaceX

Lately, many people are busy investing in stocks or other online-based investments such as gold and dollar investments. In carrying out college assignments, namely the task of building machine learning-based applications.

My friends and I in a group that we call friends of mass organizations decided to build an application for predicting the price of gold, silver, and the dollar against the rupiah for tomorrow’s prices where this application was built to help people who want to invest in gold or dollars by predicting the price of tomorrow.

predicting prices the next day will increase or decrease which will help people see the trend in the price of gold, silver, and the dollar against the rupiah to make it easier for them to invest and minimize losses.

for this project built from scratch together using GitHub, for GitHub link this project https://github.com/regiapriandi012/PricePredictions.git and for directory structure like this,

```text
└── PricePredictions
├── model
│ ├── __init__.py
│ ├── modelDolarRidge.py
│ ├── modelDolarLasso.py
│ ├── modelDolarLinear.py
│ ├── modelEmasRidge.py
│ ├── modelEmasLasso.py
│ ├── modelEmasLinear.py
│ ├── modelPerakRidge.py
│ ├── modelPerakLasso.py
│ └── modelPerakLinear.py
├── server
│ ├── __init__.py
│ ├── conf
│ │ ├── __init__.py
│ │ ├── database.ini
│ │ └── setting.py
│ ├── __init__.py
│ └── connect.py
├── static
│ ├── img
│ │ ├── bagus.jpg
│ │ ├── emas.jpg
│ │ ├── fahri.jpg
│ │ ├── logo.jpg
│ │ ├── perak.jpg
│ │ ├── reqi.jpg
│ │ ├── sine.jpg
│ │ └── uang.jpg
│ └── style.css
├── templates
│ ├── index.html
│ └── model.html
├── __init__.py
├── app.py
├── requirements.txt
└── README.md
```

For the first time, we create each machine learning model that is adjusted to the series of gold, silver, and dollar prices against the rupiah. here we use the PostgreSQL database to store data on the price of gold, silver, and dollars against the rupiah. Before creating some models, we make a connection to the server first.

to retrieve the dataset from a database, we use setting.py

after setting up to connect to the database and retrieve data from the database, then we go into the initiation for each model, for here we only show one type of model, namely the gold price prediction model using the linear regression method, the rest can be seen in the Github repository.

after successfully creating the required machine learning model, then create a web display using HTML CSS, and javascript (for chart.js graphs)

lastly, we made the main application using the Flask framework, in the app.py file, there is integration between several models and web interface.

to review the prediction interface like this

that’s all from me and my friends for the projects that have been completed and distributed to friends, thank you for the development of this project running smoothly, hopefully, this little information will be useful for friends.

--

--

Regi Apriandi
Data Folks Indonesia

Student | Who likes to learn new things🕵️‍ | Want to explore the world🌏 | Python Enthusiast | Indonesian | https://www.linkedin.com/in/regiapriandi