tina - 預測肖戰粉絲

# 訓練數據
# 肖戰粉絲標準:是否知道肖戰生日   每天爲肖戰發帖的數量
#               知道幾個肖戰代表作  有個多少好友是肖戰粉絲
import numpy as np

biao_zhun = np.asarray([[1, 0, 0, 1], [1, 1, 6, 11],
                        [0, 1, 1, 1], [0, 3, 5, 20]])
fans = np.asarray([[0], [1], [0], [1]])

yuce_biaozhun1 = int(input("是否知道肖戰生日?"))
yuce_biaozhun2 = int(input("每天爲肖戰發帖的數量?"))
yuce_biaozhun3 = int(input("知道幾個肖戰代表作?"))
yuce_biaozhun4 = int(input("有個多少好友是肖戰粉絲?"))
# xin_ren=np.asarray([[1,0,7,2]])
xin_ren=np.asarray([[yuce_biaozhun1,yuce_biaozhun2,yuce_biaozhun3,yuce_biaozhun4]])

from sklearn import linear_model
xun_lian=linear_model.LinearRegression()
xun_lian.fit(biao_zhun,fans)
jie_guo=xun_lian.predict(xin_ren)
print(jie_guo)
score = xun_lian.score(biao_zhun,fans)
print(score)

# print(biao_zhun)
# print(fans)
# 1.導入線性模型
from sklearn import linear_model
# 2.新建訓練器對象  邏輯迴歸
xun_lian = linear_model.LogisticRegression()
xun_lian.fit(biao_zhun,fans)
# 預測  predict
jie_guo=xun_lian.predict(xin_ren)
score=xun_lian.score(biao_zhun,fans)
# print(score)
if jie_guo[0] == 1:
    print("這個人是肖站粉絲,預測概率是%d %%"%(score*100))
else:
    print("這個人是假粉絲,預測概率是%d %%"%(score*100))



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章