Memuat
Memuat
Watch every step above performed live, with English narration.
0 plays
Class book
Page 1 / 6
Cover: Class ANFIS Metaheuristics Time Series Forecasting #3: Building ANFIS from Scratch: Five Layers and Hybrid Learning
Click a page or use ◀ ▶ to turn · swipe on mobile · to enlarge
Want to go deeper?
Join one of our courses or ask us directly on WhatsApp.
Picked from the software, topic, and level of “Class ANFIS Metaheuristics Time Series Forecasting #3: Building ANFIS from Scratch: Five Layers and Hybrid Learning”.
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, Anvis that we wrote from scratch, learning from data with hybrid learning. The 6-step Mackey-Glass forecast almost perfectly overlaps with the original, with an error of only 0.3%. We also found the overfitting trap on sunspots and how to overcome it. Let's start. Hello, welcome to episode three of the Anvis Metaheuristics series for time series forecasting. Anvis, Adaptive Neurofuzzy Inference System, was introduced in the early 1990s. Its structure is the same as the Sugeno system, but its parameters are trained like a neural network. The key is the highly efficient hybrid learning. Today we are writing it.
Create a file anvis.py With 4 inputs and 2 membership functions per input, there are 2 to the power of 4, which is 16 rules. Premise parameters are the center and width of the Gaussian, 16 numbers, and consequent parameters 5 numbers per rule, totaling 80. The forward function calculates layers 1 to 3 along with the output. The consequent function is half of the hybrid learning. With fixed premises, the Anvis output is linear to the consequent, so the optimal value is obtained in one least squares calculation. The lay function adds ridge regularization so that coefficients do not grow excessively. The train function runs the hybrid learning.
Each epoch, the consequent is calculated with least squares, then the error is backpropagated through the normalization layer and rule strength to calculate the gradients of the center and width of each membership function, and both are updated with gradient descent. The premise and rule premise functions convert premise parameters into a vector, which is later used by the metaheuristic algorithm. Create a file train_underscore_anvis.py and run it.
We also trained the version without ridge as a comparison. On Mackey Glass, Anvis achieves RMSI train 0.0025 and test 0.0032 in 1 second. On Sunspot, RMSI test 0.1265, but without ridge RMSI test explodes to 2.02. The reason is that the test Sunspot data contains higher peaks than the train data, and 80 coefficients without constraints extrapolate wildly. Regularization tames it.
Let's see the graph. RMSI train drops during 100 epochs. Forecast Mackey Glass, dashed line, almost indistinguishable from actual data, whereas the Sunspot forecast follows the cycle but misses some peaks. The right panel shows the membership functions shifting from initial points to new positions learned from the data.
Done. We have built Anvis from 0 with 5 layers, least squares with ridge regularization, and gradient descent, and trained it on 2 time series. In the next episode, we will optimize the premise parameters with PSO and genetic algorithms. Currently working on a thesis, dissertation, or research in the field of forecasting and artificial intelligence. Cerdas Inovasi Digital helps implement forecasting models, from Sugeno fuzzy systems and Anvis, parameter optimization with PSO and genetic algorithms, up to LSTM and ARIMA comparisons and Diebold Mariano tests, as well as opening Python programming courses for engineering. Want to master the entire series, from chaotic time series to statistical evaluation? All 6 episodes, complete with step-by-step PDF guides, data sets, and source code, are 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. Thank you for watching, see you in the next episode. Thank you for watching,
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 →