【发布时间】:2022-11-12 11:48:30
【问题描述】:
我正在使用 Colab 中的 Pycaret 库对这个数据集进行简单的预测:
https://www.kaggle.com/andrewmvd/fetal-health-classification
当我运行我的代码时:
from pycaret.utils import enable_colab
enable_colab()
from google.colab import drive
drive.mount('/content/drive')
import pandas as pd
from pycaret.classification import *
from pandas_profiling import ProfileReport
df= pd.read_csv("/content/drive/MyDrive/Pycaret/fetal_health.csv")
df2 = df.iloc[:,:11]
df2['fetal_health'] = df['fetal_health']
test = df2.sample(frac=0.10, random_state=42, weights='fetal_health')
train = df2.drop(test.index)
test.reset_index(inplace=True, drop=True)
train.reset_index(inplace=True, drop=True)
clf = setup(data =train, target = 'fetal_health', session_id=42,
log_experiment=True, experiment_name='fetal', normalize=True)
best = compare_models(sort="Accuracy")
rf = create_model('rf', fold=30)
tuned_rf = tune_model(rf, optimize='Accuracy')
predict_model(tuned_rf)
我明白了错误:
我认为这是因为我的目标变量不平衡(参见 img)并导致预测不正确。
有人可以帮我理解吗? 提前谢谢
【问题讨论】:
标签: python-3.x machine-learning classification google-colaboratory pycaret