0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

install lazypredictを試してみた

Posted at

# Google Colabで必要なライブラリをインストール
!pip install lazypredict
!pip install scikit-learn

# 必要なライブラリをインポート
import lazypredict
from lazypredict.Supervised import LazyClassifier
from sklearn.datasets import load_breast_cancer
from sklearn.model_selection import train_test_split

# 乳がん診断データセットを読み込み
data = load_breast_cancer()
X = data.data
y = data.target

# データをトレーニングセットとテストセットに分割
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.3, random_state=42)

# LazyClassifierを使用してモデルを一括で学習・評価
clf = LazyClassifier(verbose=0, ignore_warnings=True, custom_metric=None)
models, predictions = clf.fit(X_train, X_test, y_train, y_test)

# モデル比較結果を表示
print(models)

解説:

  1. lazypredictのインストール: lazypredictscikit-learnライブラリをGoogle Colabにインストールします。
  2. 乳がん診断データセットの準備: sklearn.datasetsload_breast_cancer()関数を使用して乳がん診断データセットを読み込みます。
  3. データの分割: train_test_split()関数を使用して、データセットを訓練データ(70%)とテストデータ(30%)に分割します。
  4. LazyClassifierの利用: LazyClassifierをインスタンス化し、学習と評価を行います。
  5. 結果表示: modelsに格納された結果をprint()で表示し、各モデルの正解率などを比較します。

結果

Model
LogisticRegression 0.98 0.98 0.98 0.98
Perceptron 0.98 0.98 0.98 0.98
LinearSVC 0.98 0.98 0.98 0.98
PassiveAggressiveClassifier 0.98 0.97 0.97 0.98
SVC 0.98 0.97 0.97 0.98
ExtraTreesClassifier 0.98 0.97 0.97 0.98
CalibratedClassifierCV 0.98 0.97 0.97 0.98
XGBClassifier 0.97 0.97 0.97 0.97
AdaBoostClassifier 0.97 0.97 0.97 0.97
SGDClassifier 0.96 0.97 0.97 0.97
RandomForestClassifier 0.97 0.96 0.96 0.97
QuadraticDiscriminantAnalysis 0.96 0.96 0.96 0.96
BernoulliNB 0.96 0.96 0.96 0.96
LGBMClassifier 0.96 0.96 0.96 0.96
KNeighborsClassifier 0.96 0.95 0.95 0.96
BaggingClassifier 0.95 0.95 0.95 0.95
DecisionTreeClassifier 0.94 0.94 0.94 0.94
RidgeClassifierCV 0.95 0.94 0.94 0.95
LinearDiscriminantAnalysis 0.95 0.94 0.94 0.95
RidgeClassifier 0.95 0.94 0.94 0.95
LabelSpreading 0.94 0.94 0.94 0.94
LabelPropagation 0.94 0.94 0.94 0.94
NuSVC 0.94 0.93 0.93 0.94
GaussianNB 0.94 0.93 0.93 0.94
NearestCentroid 0.94 0.93 0.93 0.94
ExtraTreeClassifier 0.89 0.90 0.90 0.90
DummyClassifier 0.63 0.50 0.50 0.49

                           Time Taken  

Model
LogisticRegression 0.07
Perceptron 0.03
LinearSVC 0.11
PassiveAggressiveClassifier 0.06
SVC 0.05
ExtraTreesClassifier 0.42
CalibratedClassifierCV 0.12
XGBClassifier 0.68
AdaBoostClassifier 0.41
SGDClassifier 0.05
RandomForestClassifier 1.32
QuadraticDiscriminantAnalysis 0.07
BernoulliNB 0.05
LGBMClassifier 0.59
KNeighborsClassifier 0.06
BaggingClassifier 0.13
DecisionTreeClassifier 0.04
RidgeClassifierCV 0.32
LinearDiscriminantAnalysis 0.09
RidgeClassifier 0.08
LabelSpreading 0.08
LabelPropagation 0.19
NuSVC 0.12
GaussianNB 0.03
NearestCentroid 0.06
ExtraTreeClassifier 0.06
DummyClassifier 0.04

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?