STOCK PRICE PREDICTION using Machine Learning📈 | Machine Learning Projects | GeeksforGeeks



AI Summary

Session Summary:

  • Topic: Implementation of KNN algorithm
  • Previous Session Recap:
    • Discussed mathematical intuition behind KNN for regression and classification.
    • Advised to watch the previous session for better understanding.
  • Agenda:
    • Define the problem.
    • Step-by-step coding demonstration using a stock prediction dataset.
  • Dataset:
    • Source: Quandl (financial data extraction).
    • Features: Date, Open, High, Low, Last, Close, Total Trade Quantity, Turnover.
    • Objective: Predict the ‘Close’ value and decide whether to buy or sell stock.
  • Libraries Used:
    • Pandas, NumPy, Matplotlib, Quandl.
  • Tasks:
    1. Predict the ‘Close’ value (Regression Problem).
    2. Decide whether to buy (+1) or sell (-1) stock (Classification Problem).
  • KNN Implementation:
    • Demonstrated KNN for both regression and classification.
    • Used features like ‘Open - Close’ and ‘High - Low’ for predictions.
    • Explained the process of converting stock data into a classification problem.
    • Discussed the importance of choosing the right ‘K’ value using GridSearchCV.
  • Model Training and Testing:
    • Split data into training and testing sets.
    • Used KNeighborsClassifier and KNeighborsRegressor from sklearn.
    • Evaluated model accuracy and error metrics (RMS error).
  • Results:
    • Classification: Training accuracy (68%), Test accuracy (51%).
    • Regression: Showed actual vs predicted ‘Close’ values, noted high RMS error due to feature selection.
  • Conclusion:
    • KNN can be used for both regression and classification tasks.
    • The choice of features and the value of ‘K’ are crucial for model performance.
    • Future sessions will explore other models like Random Forest and LSTM.
  • Next Steps:
    • Discuss other topics and models in future sessions.
    • Address any doubts in the comment section.
  • End of Session.