昨天所做的模型没办法成功预测今天尝试把更多特徵加进来也让原本两个判断改成3个来训练

import pandas as pd
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import accuracy_score
from sklearn.preprocessing import LabelEncoder

data = {
\'重量\': [150, 130, 140, 155, 160, 180, 170, 175, 165, 185, 120, 110, 115, 125, 130],
\'颜色\': [\'红色\', \'红色\', \'红色\', \'红色\', \'红色\',
\'橙色\', \'橙色\', \'橙色\', \'橙色\', \'橙色\',
\'黄色\', \'黄色\', \'黄色\', \'黄色\', \'黄色\'],
\'品项\': [\'苹果\', \'苹果\', \'苹果\', \'苹果\', \'苹果\',
\'橘子\', \'橘子\', \'橘子\', \'橘子\', \'橘子\',
\'香蕉\', \'香蕉\', \'香蕉\', \'香蕉\', \'香蕉\'],
\'形状\': [\'圆形\', \'圆形\', \'圆形\', \'圆形\', \'圆形\',
\'圆形\', \'圆形\', \'圆形\', \'圆形\', \'圆形\',
\'条状\', \'条状\', \'条状\', \'条状\', \'条状\'],
\'光滑度\': [\'光滑\', \'光滑\', \'光滑\', \'光滑\', \'光滑\',
\'粗糙\', \'粗糙\', \'粗糙\', \'粗糙\', \'粗糙\',
\'光滑\', \'光滑\', \'光滑\', \'光滑\', \'光滑\']
}

df = pd.DataFrame(data)
encoder = LabelEncoder()

df[\'data_color\'] = encoder.fit_transform(data[\'颜色\'])
df[\'data_item\'] = encoder.fit_transform(data[\'品项\'])
df[\'data_shape\'] = encoder.fit_transform(data[\'形状\'])
df[\'data_smooth\'] = encoder.fit_transform(data[\'光滑度\'])
x = df[[\'重量\',\'data_color\',\'data_shape\',\'data_smooth\']]
y = df[[\'品项\']]
x_train,x_test,y_train,y_test = train_test_split(x,y,test_size=0.2,random_state=1)

model = LogisticRegression()

model.fit(x_train,y_train)

y_pred = model.predict(x_test)

print("测试集的实际标籤:")
print(y_test.values)
print("模型的预测结果")
print(y_pred)

accuracy = accuracy_score(y_test,y_pred)
print(f"模型的準确率:{accuracy * 100:.2f}")