以下是使用Python编写的随机森林插补风力发电功率数据的程序:
import pandas as pd
from sklearn.ensemble import RandomForestRegressor
# 读取原始数据
data = pd.read_csv('wind_power_data.csv')
# 将缺失值用0替代
data.fillna(0, inplace=True)
# 分离已知和未知数据
known = data[data['power'].notna()]
unknown = data[data['power'].isna()]
# 定义特