亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何預測蟒蛇的結果?

如何預測蟒蛇的結果?

繁花如伊 2022-09-20 15:49:27
我有以下代碼,其中我從4個輸入值預測一個值:import numpy as npfrom sklearn.naive_bayes import GaussianNBfrom sklearn.model_selection import train_test_splitfrom sklearn.neural_network import MLPClassifierdata = np.loadtxt('C:/Users/hedeg/Desktop/RulaSoftEdgePrediction.txt')X_train = np.array(data[0:3500,0:4])y_train = np.array(data[0:3500,4])X_test = np.array(data[3500::,0:4])y_test = np.array(data[3500::,4])clf = MLPClassifier(solver='lbfgs', alpha=1e-5,hidden_layer_sizes=(5, 2), random_state=1)clf.fit(X_train, y_train)我收到此錯誤消息:raise ValueError("Unknown label type: %s" % repr(ys))ValueError: Unknown label type: (array([1. , 1.1, 1.2, ..., 3. , 3. , 3. ]),)我該如何解決這個問題?
查看完整描述

1 回答

?
萬千封印

TA貢獻1891條經驗 獲得超3個贊

嘗試使用這個:


from sklearn.linear_model import LogisticRegression

from sklearn.datasets import make_blobs

# generate 2d classification dataset

X, y = make_blobs(n_samples=100, centers=2, n_features=2, random_state=1)

# fit final model

model = LogisticRegression()

model.fit(X, y)


# example of training a final classification model

from sklearn.linear_model import LogisticRegression

from sklearn.datasets import make_blobs

# generate 2d classification dataset

X, y = make_blobs(n_samples=100, centers=2, n_features=2, random_state=1)

# fit final model

model = LogisticRegression()

model.fit(X, y)


查看完整回答
反對 回復 2022-09-20
  • 1 回答
  • 0 關注
  • 118 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號