0
私は(テストデータセットより)その精度を計算したいと思います。 モデルは、次の予測値を有する。PythonのRFモデルの精度を比較します
[0 1 0 1 1 1 1 0 1 0 1 0 1 1 0 0 0 1 0 1 0 1 0 0 0 1 1 0 0 0 0 0 0 0 1 1 0
1 1 1 0 0 0 0 0 1 0 0 0 1 0 0 1 0 0 0 0]
どのようにテストデータに対するその精度を取得する(この場合、BまたはMで)実際の値と比較することができます。これは、他のデータセットの値にも一般的でなければなりません。ここ は、私はランダムフォレストモデルに使用するコードです:
import pandas as pd
import numpy as np
# Load scikit's random forest classifier library
from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import train_test_split
file_path = 'https://archive.ics.uci.edu/ml/machine-learning-databases/breast-cancer-wisconsin/wdbc.data'
dataset2 = pd.read_csv(file_path, header=None, sep=',')
train, test = train_test_split(dataset2, test_size=0.1)
y = pd.factorize(train[1])[0]
clf = RandomForestClassifier(n_jobs=2, random_state=0)
features = train.columns[2:]
clf.fit(train[features], y)
RandomForestClassifier(bootstrap=True, class_weight=None, criterion='gini',
max_depth=None, max_features='auto', max_leaf_nodes=None,
min_impurity_split=1e-07, min_samples_leaf=1,
min_samples_split=2, min_weight_fraction_leaf=0.0,
n_estimators=10, n_jobs=2, oob_score=False, random_state=0,
verbose=0, warm_start=False)
# Apply the Classifier we trained to the test data
clf.predict(test[features])
次のような回答がありますか?この質問の意味は、元のラベルのB、Mとの精度を評価したいと解釈されました。 – Keiku