Memuat
Memuat
Want to go deeper?
Join one of our courses or ask us directly on WhatsApp.
Picked from the software, topic, and level of “Class Machine Learning Python #18: Final Project: Deploy Model to Web”.
Other ways we can help with Python.
Learn with a mentor
Scheduled AI & Machine Learning courses with live guidance and a certificate.

Multi-Objective Optimization Course: NSGA-II, MOPSO & Hybrid Algorithms (Python)

ECG Arrhythmia Classification Course with Wavelet & Deep Learning (PyTorch)

ANFIS + PSO/GA Course for Non-Linear Time Series Forecasting (Python)
Have it built for you
No time to learn Python? Our team can do the project for you.

Python Machine Learning — Prediction Models, Customer Segmentation, Fraud Detection & AI Apps

AI Image Creation with Stable Diffusion — Unlimited Custom Visual Production
★ 4.9

AI Image & Video Creation with Leonardo AI — All-in-One Visuals for Business
★ 4.9
Get notified about new Python classes
At most one email a week. Unfollow anytime with one click.
The full narration of this video. The current sentence is highlighted while the video plays; click any sentence to jump there.
Here is the final result, our own web application for predicting house prices. Users just need to fill in the area, number of rooms, city, and house condition, then the machine learning model will directly calculate the estimated price. We built everything from scratch, from raw data to a ready-to-use application. Let's get started. Hello, welcome to the final episode of the machine learning series with Python. In this episode, we combine everything we've learned into one complete project, house price prediction. We start with the data, build the pipeline, compare several models with cross-validation, select the best model, save it to a file, and deploy it into a web application with Streamlit, so that anyone can use it through a browser.
We open the terminal and install Streamlit and JobLab with PIP. Then create a train .py file. The data consists of 800 houses with features such as area, rooms, age, city, condition, and distance to the city center. Like a real project, there are some empty data in several columns. We split the training data and test data from the beginning.
We set up the preprocessing pipeline as in episode 4, numerical features are filled with the median and then standardized, city with one-hot encoding, and condition with ordinal encoding. Then we compare 3 models with 5-fold cross-validation, linear regression, random forest, and gradient boosting. The metric is MAE in million rupiah, the smaller the better. Gradient boosting is the best, as it can capture non-linear relationships well.
Our best model is tuned with grid search CV for the number of trees, depth, and learning rate. After that, we evaluate it once on the test data, which was saved from the beginning. MAI and R squared are good. Finally, the entire pipeline, including preprocessing, we save into one file using joblib dump. This is the advantage of a pipeline, one file containing all steps, ready to receive raw data.
Now the application. Create a file app.py Streamlit creates a web application with just Python, without HTML. We load the model with joblib load, using cache resource so it's loaded only once. Then we create a title, and input for each feature, number input for area, slider for rooms and age, select box for city and condition.
When the predict price button is pressed, the inputs are collected into a one-row data frame, sent to the model, and the result is displayed in a neat Indonesian rupiah format. We run it with the command streamlit run app.py, here with start minus B so the server runs in the background and the terminal remains usable. Then open it in the browser Running on local host port 8501.
The application is now running. With default values, house 120 square meters, 3 bedrooms, in Bandung, we press the predict price button, and the price estimate appears instantly. Try changing the city to Jakarta and press again. The price increases, according to the pattern learned by the model from the data. To share it with the world, this application can be uploaded for free to Streamlit Community Cloud via GitHub.
Done, and congratulations! You have completed the entire series of machine learning with Python. We have learned from introduction, numpy and pandas, mathematics, data preprocessing, regression, classification, trees, SVM, ensemble evaluation, tuning, feature engineering, clustering, dimensionality reduction, anomaly, deep learning, reinforcement learning, until deployed. Next step, find a dataset online, build your own project, and keep practicing. Thank you for learning with us. Want to master machine learning and data science? Cerdas Inovasi Digital offers Python courses, machine learning, and AI from the basics, model prediction services, data analysis, and AI applications for business or research, as well as selling complete source code of this tutorial. Want to master all series of this, from introduction to machine learning until deploying models to web? All 18 episodes, Complete with a step-by-step PDF guide, available for premium tutorial subscribers. Subscribe starting at Rp69.000 per month, save 28% with the 12-month package, or pay once Rp999.000 for lifetime access. Want a single class only? Buy individual classes with lifetime access. Subscribe now on the premium page at cerdasinovasidigital.com. Contact our WhatsApp, or visit cerdasinovasidigital.com. Thank you for watching, see you in the next episode.
Type a question or keyword; we find the part of this episode that explains it and jump the video there.
Notes are saved with the current video time and are only visible to you.
Stuck on a step? Ask here; the instructor and other learners can answer.
No questions yet.

Cerdas Inovasi Digital Team
Software developers, BIM & 3D engineers, and AI practitioners
We build software, BIM models, games and AI automations for clients every day, and turn that hands-on work into step-by-step classes: every step is shown on screen and comes with a PDF guide you can keep.
See our clients →