Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Вивчайте Challenge: Predict Stock Movement | Machine Learning for FinTech
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
Python for FinTech

bookChallenge: Predict Stock Movement

Predicting whether a stock price will rise or fall the next day is a classic example of a binary classification problem in machine learning. In this context, you assign a label—such as 1 for "up" and 0 for "down"—to each day based on whether the stock's closing price increases or decreases compared to the previous day. By using features like the previous day's return and moving averages, you can train a model to recognize patterns that may indicate future price movements. Logistic regression, a widely used algorithm for binary classification, is well-suited for this task because it estimates the probability of a binary outcome based on input features. Evaluating the model's accuracy on unseen data helps you understand how well it can generalize to future stock movements, which is crucial for making informed decisions in finance.

Завдання

Swipe to start coding

Implement a function that predicts whether a stock's closing price will go up or down the next day using logistic regression. Use only the provided list of prices as input.

  • Calculate the previous day's return for each day as a feature.
  • Calculate the 3-day moving average of the closing price as a feature.
  • Define the target as 1 if the next day's closing price is higher than the current day's, otherwise 0.
  • Drop any rows with missing values resulting from feature calculations.
  • Use 80% of the data for training and 20% for testing, without shuffling the order.
  • Train a logistic regression model using the features.
  • Predict the target for the test set and return the model's accuracy.

Рішення

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 3. Розділ 3
single

single

Запитати АІ

expand

Запитати АІ

ChatGPT

Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат

close

bookChallenge: Predict Stock Movement

Свайпніть щоб показати меню

Predicting whether a stock price will rise or fall the next day is a classic example of a binary classification problem in machine learning. In this context, you assign a label—such as 1 for "up" and 0 for "down"—to each day based on whether the stock's closing price increases or decreases compared to the previous day. By using features like the previous day's return and moving averages, you can train a model to recognize patterns that may indicate future price movements. Logistic regression, a widely used algorithm for binary classification, is well-suited for this task because it estimates the probability of a binary outcome based on input features. Evaluating the model's accuracy on unseen data helps you understand how well it can generalize to future stock movements, which is crucial for making informed decisions in finance.

Завдання

Swipe to start coding

Implement a function that predicts whether a stock's closing price will go up or down the next day using logistic regression. Use only the provided list of prices as input.

  • Calculate the previous day's return for each day as a feature.
  • Calculate the 3-day moving average of the closing price as a feature.
  • Define the target as 1 if the next day's closing price is higher than the current day's, otherwise 0.
  • Drop any rows with missing values resulting from feature calculations.
  • Use 80% of the data for training and 20% for testing, without shuffling the order.
  • Train a logistic regression model using the features.
  • Predict the target for the test set and return the model's accuracy.

Рішення

Switch to desktopПерейдіть на комп'ютер для реальної практикиПродовжуйте з того місця, де ви зупинились, використовуючи один з наведених нижче варіантів
Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 3. Розділ 3
single

single

some-alt