AI simple programming
- Get link
- X
- Other Apps
AI programming with simple example and result
Here is a very simple AI programming example in Python using a basic machine-learning model.
🤖 Example: Predict Student Result
The program learns from previous students' study hours and marks, then predicts the marks for a new student.
from sklearn.linear_model import LinearRegression # Training data # Hours studied → Marks obtained X = [[1], [2], [3], [4], [5]] y = [35, 45, 55, 65, 75] # Create AI/ML model model = LinearRegression() # Train the model model.fit(X, y) # Predict marks for a student who studies 6 hours prediction = model.predict([[6]]) print("Predicted Marks:", round(prediction[0], 2))
✅ Result
Predicted Marks: 85.0
How it works
Training data:
| Study Hours | Marks |
|---|---|
| 1 | 35 |
| 2 | 45 |
| 3 | 55 |
| 4 | 65 |
| 5 | 75 |
The AI learns the relationship between study hours → marks and predicts:
6 hours → 85 marks
This is a simple example of Machine Learning, where the computer learns from existing data instead of being explicitly programmed with the answer.
If you want, I can also give you 5 simple AI Python programs with input + output, suitable for teaching students at NRsolution4u.
- Get link
- X
- Other Apps
Comments
Post a Comment