数据集:
imodels/credit-card
Port of the credit-card dataset from UCI (link here ). See details there and use carefully.
Basic preprocessing done by the imodels team in this notebook .
The target is the binary outcome default.payment.next.month .
Load the data:
from datasets import load_dataset dataset = load_dataset("imodels/credit-card") df = pd.DataFrame(dataset['train']) X = df.drop(columns=['default.payment.next.month']) y = df['default.payment.next.month'].values
Fit a model:
import imodels import numpy as np m = imodels.FIGSClassifier(max_rules=5) m.fit(X, y) print(m)
Evaluate:
df_test = pd.DataFrame(dataset['test']) X_test = df.drop(columns=['default.payment.next.month']) y_test = df['default.payment.next.month'].values print('accuracy', np.mean(m.predict(X_test) == y_test))
从UCI(链接 here )导入信用卡数据集。请在那里查看详细信息并小心使用。
基本预处理由 imodels team 完成。
目标是二元结果default.payment.next.month。
加载数据:
from datasets import load_dataset dataset = load_dataset("imodels/credit-card") df = pd.DataFrame(dataset['train']) X = df.drop(columns=['default.payment.next.month']) y = df['default.payment.next.month'].values
拟合模型:
import imodels import numpy as np m = imodels.FIGSClassifier(max_rules=5) m.fit(X, y) print(m)
评估:
df_test = pd.DataFrame(dataset['test']) X_test = df.drop(columns=['default.payment.next.month']) y_test = df['default.payment.next.month'].values print('accuracy', np.mean(m.predict(X_test) == y_test))