1. Introduction
In AI, Machines require human intelligence to perform task, such as learning, problem-solving, decision-making, and understanding language.
In simple words, AI enables machines to think and learn from data.
In simple words, AI does not follow fixed instructions it enables machines to think and learn from data. AI systems analyze data patterns and improve their performance over time.
Now a days, AI is used in many industries like healthcare, finance, education, e-commerce, transportation, and entertainment.
Some Example of AI applications include:
- Voice assistants like Siri and Google Assistant.
- Recommendation systems used by Netflix and Amazon.
- Self-driving technology developed by Tesla.
- Chatbots used in customer support.
2. Syntax
Mostly AI applications are developed using programming languages like Python because It has a powerful libraries.
Below is a simple syntax of a basic AI machine learning model using Python and the Scikit-learn library.
from sklearn.tree import DecisionTreeClassifier
# Training data
features = [[120, 5], [150, 7], [200, 10]]
labels = ["Small", "Medium", "Large"]
# Create AI model
model = DecisionTreeClassifier()
# Train model
model.fit(features, labels)
# Predict
prediction = model.predict([[180, 8]])
print(prediction) //output: Medium size
3. Basic Example
In this example, we will create a AI system that predicts the size of a pizza based on its diameter and number of slices.
Python Example
from sklearn.tree import DecisionTreeClassifier
# Pizza Data: [diameter, slices]
pizzaData = [
[8, 4],
[10, 6],
[12, 8],
[16, 12]
]
# Create a Labels
labels = ["Small", "Medium", "Large", "Extra Large"]
# Create model
model = DecisionTreeClassifier()
# Train the model
model.fit(pizzaData, labels)
# Predict pizza size
result1 = model.predict([[11, 6]])
result2 = model.predict([[13, 8]])
print("Predicted Pizza Size:", result1[0]) //Output is Medium
print("Predicted Pizza Size:", result2[0]) //Output is Large
Training Data
You trained the model using these examples with scikit-learn in Python.
| Diameter | Slices | Label |
|---|---|---|
| 8 | 4 | Small |
| 10 | 6 | Medium |
| 12 | 8 | Large |
| 16 | 12 | Extra Large |
Note: This AI model learns from previous data and predicts the size of a new pizza.
Output:
Predicted Pizza Size: Large
Explanation:
1. Import Library
from sklearn.tree import DecisionTreeClassifier
This imports a machine learning algorithm called Decision Tree, which helps AI make decisions based on data.
2. Define Training Data
features = [[8,4],[10,6],[12,8],[16,12]]
labels = ["Small","Medium","Large","Extra Large"]
Here we provide training data to the AI model.
- Features → Input data (diameter and slices)
- Labels → Expected output (pizza size)
3. Create the Model
model = DecisionTreeClassifier()
This creates the AI model.
4. Train the Model
model.fit(features, labels)
5. Make Prediction
model.predict([[11,6]])
The model predicts the pizza size based on new input.
AI models work by learning patterns from historical data and applying them to new data to make predictions.
4. Real-world Example
I will show you a very popular real-world application of AI is movie recommendation systems used by Netflix.
Whenever you open Netflix, you see movie suggestions like:
- “Recommended for you”
- “Because you watched…”
- “Trending now”
This happens because Netflix uses AI and machine learning algorithms to analyze user behavior.
The system studies:
- Movies you watch
- Movies you search
- Movies you rate
- Your viewing history
Based on this data, AI predicts which movies you are most likely to watch next.
#Simplified Example of Recommendation AI
from sklearn.neighbors import NearestNeighbors
# User watching data
movies = [
[1, 1, 0], # User liked Action & Comedy
[1, 0, 1], # User liked Action & Drama
[0, 1, 1] # User liked Comedy & Drama
]
# Create model
model = NearestNeighbors(n_neighbors=1)
# Train model
model.fit(movies)
# New user preference
new_user = [[1, 1, 0]]
# Find similar user
distance, index = model.kneighbors(new_user)
print("Recommended based on user:", index)
Output:
Explanation:
- 0 means the first user in the dataset is the most similar.
Training Data
Your dataset:
| Action | Comedy | Drama | Meaning |
|---|---|---|---|
| 1 | 1 | 0 | User likes Action & Comedy |
| 1 | 0 | 1 | User likes Action & Drama |
| 0 | 1 | 1 | User likes Comedy & Drama |
This simplified AI model finds users with similar interests and recommends content.
5. Other real-world AI applications include:
1. Healthcare
AI helps doctors detect diseases such as cancer by analyzing medical images.
2. Self-Driving Cars
Companies like Tesla use AI to detect roads, pedestrians, and traffic signals.
3. E-commerce
Online stores like Amazon use AI to recommend products based on your shopping behavior.
4. Virtual Assistants
Voice assistants like Siri and Google Assistant use AI to understand voice commands and answer questions.
5. Fraud Detection
Banks use AI to detect suspicious transactions and prevent fraud.
6. Conclusion
Artificial Intelligence is rapidly transforming in the businesses. AI is improving efficiency and decision-making across many industries like recommendation systems, chatbots, self-driving cars and medical diagnostics.
With the help of machine learning algorithms, AI systems can learn from data, identify patterns, and make predictions with high accuracy.
Now a days, AI will play an even bigger role in automation, innovation, and digital transformation.