? Mini Project Report
? Mini Project Report
Title:
AI-based Stock Market Price Prediction Model using Heuristics, Constraint
Satisfaction Problem, and First Order Logic
1. Introduction
The stock market is an inherently dynamic and volatile domain, affected by numerous
factors ranging from corporate earnings to global politics. Predicting stock prices is a
challenging task requiring smart models that can learn from historical patterns.
In this project, we have developed a stock price prediction model using Linear
Regression, enriched with Artificial Intelligence (AI) concepts like Heuristics,
Constraint Satisfaction Problems (CSP), and First Order Logic (FOL). These AI
techniques are integrated into the data cleaning, feature selection, and prediction
logic, making the model more intelligent and adaptive.
2. Objective
To build a model capable of predicting the closing price of a stock based on its historical
data.
To integrate AI principles like heuristics, FOL, and CSP for data refinement and model
enhancement.
To visualize and interpret the accuracy and performance of the predictive model.
3. Dataset Description
Source: Kaggle – all_stocks_5yr.csv
Size: ~2266K rows (data from 2013 to 2018)
Attributes:
o date: Trading date
o open: Opening stock price
o high: Highest price of the day
o low: Lowest price of the day
o close: Closing price (Target variable)
o volume: Number of stocks traded
o Name: Stock ticker symbol (not used in this basic model)
4. Tech Stack
Languages & Libraries
Python
Pandas, NumPy – Data processing
Matplotlib – Data visualization
scikit-learn – Machine Learning (Linear Regression)
AI Techniques Used
Technique Application
Heuristics Feature selection, optimization
CSP Data validation and filtering
First Order Logic Rule-based insights and
(FOL) preprocessing
5. Workflow
Step 1: Data Preprocessing
Loaded dataset using Pandas.
Converted the date column to a datetime object.
Removed missing values (dropna()) to ensure valid training data (CSP constraint).
Verified data using .info(), .describe(), and null value checks.
dataset.dropna(inplace=True)
dataset['date'] = pd.to_datetime(dataset['date'])
Step 5: Visualization
Plotted actual vs predicted prices using bar graphs.
dfr = pd.DataFrame({'Actual': y_test, 'Predicted': predicted})
graph = dfr.head(20)
graph.plot(kind='bar')
plt.show()
This visual representation helps in understanding prediction accuracy.
6. Integration of AI Concepts
🔍 Heuristic Approach
Selected features based on domain intuition: stocks are generally influenced by opening
price, high/low ranges, and volume.
Used trial-and-error to find the best combination of features.
Helped reduce noise and overfitting.
📐 Constraint Satisfaction Problem (CSP)
Treated each data row as a variable with constraints:
o No missing values
o Positive values for price and volume
Filtered the dataset to satisfy these constraints using dropna() and logical checks.
📘 First Order Logic (FOL)
Applied simple rule-based reasoning for data filtering and interpretation:
o "IF high < low THEN discard row" (data error)
o "IF volume = 0 THEN ignore entry"
o FOL rules used to sanity check data before training
7. Key Observations
Linear Regression works well on large stock datasets when noise is minimized.
Applying AI principles improved preprocessing and model interpretability.
Heuristic methods helped in faster convergence and better predictions.
CSP ensured model training was done on clean, constraint-satisfied data.
FOL-based insights can be integrated into more complex reasoning systems.
9. Conclusion
This project successfully demonstrates how a simple regression model, when
combined with AI concepts, can effectively predict stock market closing prices.
Although the financial market is complex, applying structured techniques like
Heuristics, CSP, and FOL leads to better feature selection, cleaner data, and logical
consistency, ultimately enhancing model accuracy and reliability.