Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Вивчайте Challenge: Predict Ozone Levels | Modeling and Predicting Environmental Phenomena
Python for Environmental Science

bookChallenge: Predict Ozone Levels

In environmental science, predicting air quality indicators such as ozone levels is crucial for understanding pollution dynamics and informing public health decisions. You will use a simple linear regression model to predict ozone levels based on temperature data, a common approach for exploring how weather conditions relate to air pollution.

Begin by importing the necessary libraries and preparing your data. You have a small dataset of daily temperature and ozone measurements, which allows you to practice building and evaluating a predictive model.

Завдання

Swipe to start coding

Fit a linear regression model using scikit-learn to predict ozone levels from temperature, using this DataFrame:

  • Use the provided pandas DataFrame with columns temperature and ozone.
  • Fit a linear regression model (LinearRegression) to predict ozone from temperature.
  • Store the fitted model as model.
  • Predict ozone values for the input data and store them in y_pred.
  • Calculate and print the mean squared error (MSE) and R² score of the predictions.
  • Plot a scatter plot of the data and overlay the regression line.

The DataFrame is:

import pandas as pd
df = pd.DataFrame({
    "temperature": [22, 25, 27, 23, 28, 30, 26, 29, 31, 24, 32, 33, 21, 20, 19],
    "ozone": [34, 44, 49, 37, 51, 60, 46, 55, 62, 39, 65, 67, 30, 28, 25]
})

Рішення

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

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

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

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

single

Запитати АІ

expand

Запитати АІ

ChatGPT

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

Suggested prompts:

What are the necessary libraries I need to import for this task?

Can you show me how to prepare the temperature and ozone data for modeling?

How do I load and view the sample dataset?

close

bookChallenge: Predict Ozone Levels

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

In environmental science, predicting air quality indicators such as ozone levels is crucial for understanding pollution dynamics and informing public health decisions. You will use a simple linear regression model to predict ozone levels based on temperature data, a common approach for exploring how weather conditions relate to air pollution.

Begin by importing the necessary libraries and preparing your data. You have a small dataset of daily temperature and ozone measurements, which allows you to practice building and evaluating a predictive model.

Завдання

Swipe to start coding

Fit a linear regression model using scikit-learn to predict ozone levels from temperature, using this DataFrame:

  • Use the provided pandas DataFrame with columns temperature and ozone.
  • Fit a linear regression model (LinearRegression) to predict ozone from temperature.
  • Store the fitted model as model.
  • Predict ozone values for the input data and store them in y_pred.
  • Calculate and print the mean squared error (MSE) and R² score of the predictions.
  • Plot a scatter plot of the data and overlay the regression line.

The DataFrame is:

import pandas as pd
df = pd.DataFrame({
    "temperature": [22, 25, 27, 23, 28, 30, 26, 29, 31, 24, 32, 33, 21, 20, 19],
    "ozone": [34, 44, 49, 37, 51, 60, 46, 55, 62, 39, 65, 67, 30, 28, 25]
})

Рішення

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

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

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

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

single

some-alt