日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

ML之LoR:基于LoR(逻辑回归)算法对乳腺癌肿瘤(9+1)进行二分类预测(良/恶性)

發布時間:2025/3/21 46 豆豆
生活随笔 收集整理的這篇文章主要介紹了 ML之LoR:基于LoR(逻辑回归)算法对乳腺癌肿瘤(9+1)进行二分类预测(良/恶性) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

ML之LoR:基于LoR(邏輯回歸)算法對乳腺癌腫瘤(9+1)進行二分類預測(良/惡性)

?

?

目錄

輸出結果

設計思路

數據集

核心代碼


?

?

?

輸出結果





Testing accuracy (10 training samples): 0.8685714285714285
Testing accuracy (all training samples): 0.9371428571428572

?

?

設計思路

數據集

? ? ? ? ?可知該原始數據共有699條樣本,每條樣本有11列不同的數值:1列用于檢索的id,9列與腫瘤相關的醫學特征,以及一列表征腫瘤類型的數值。所有9列用于表示腫瘤醫學特質的數值均被量化為1~10之間的數字,而腫瘤的類型也借由數字2和數字4分別指代良性與惡性。不過,這份數據也聲明其中包含16個缺失值,并且用“?”標出。本代碼中,對于存在缺失值的數據,都暫時子以忽略。

Number of Instances:699 (as of 15 July 1992)
Number of Attributes:10 plus the class attribute
Attribute Information:(class attribute has been moved to last column

#Attribute ? ? ? ? ? ? ? ? ? ? ? ? ? ? Domain ? ? ? ? ? ? ? ? ? ? ? ? ? ? ??
1 .Sample code number ? ? ? ? id number
2 .Clump Thickness ? ? ? ? ? ? ? ? ?1一10
3 .Uniformity of Cell ? ? ? ? ? ? ? ? ?1一10
4 .Uniformity of Cell ? ? ? ? ? ? ? ? ?1一10
5 .Marginal Adhesion ? ? ? ? ? ? ? ?1一10
6 .Single Epithelial Cell Size? ? ?1一10
7 .Bare Nuclei? ? ? ? ? ? ? ? ? ? ? ? ? ?1一10
8 .Bland Chromatin? ? ? ? ? ? ? ? ? ?1一10
9. Normal Nucleoli? ? ? ? ? ? ? ? ? ??1一10
10 .Mitoses? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?1一10
11 .Class: ? ? ? ? ? ? ? (2 for benign, ?4 for malignant)

?

核心代碼

import numpy as np intercept = np.random.random([1]) coef = np.random.random([2])lx = np.arange(0, 12) ly = (-intercept - lx * coef[0]) / coef[1]from sklearn.linear_model import LogisticRegression lr = LogisticRegression() lr.fit(df_train[['Clump Thickness', 'Cell Size']][:10], df_train['Type'][:10]) print('Testing accuracy (10 training samples):', lr.score(df_test[['Clump Thickness', 'Cell Size']], df_test['Type']))intercept = lr.intercept_ coef = lr.coef_[0, :] ly = (-intercept - lx * coef[0]) / coef[1]lr = LogisticRegression() lr.fit(df_train[['Clump Thickness', 'Cell Size']], df_train['Type']) print('Testing accuracy (all training samples):', lr.score(df_test[['Clump Thickness', 'Cell Size']], df_test['Type']))intercept = lr.intercept_ coef = lr.coef_[0, :] ly = (-intercept - lx * coef[0]) / coef[1]

?

?

?

?

?

總結

以上是生活随笔為你收集整理的ML之LoR:基于LoR(逻辑回归)算法对乳腺癌肿瘤(9+1)进行二分类预测(良/恶性)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。