Zaktualizuj 'main.py'

This commit is contained in:
Jerzy Kwiatkowski 2023-06-22 11:32:48 +02:00
parent 3bfbb22edb
commit 101b46639c

10
main.py
View File

@ -14,23 +14,17 @@ data_train = shuffled_data[:n]
data_test = shuffled_data[n:]
X_train = data_train.iloc[:, 1:-1].values
print(X_train)
y_train = data_train.iloc[:, -1].values
lab = preprocessing.LabelEncoder()
y_transformed = lab.fit_transform(y_train)
X_test = data_test.iloc[:, 1:-1].values
# y_test = data_test.iloc[:, 1:].values
# svr = SVR()
# svr.fit(X_train, y_train)
# print(svr.score(X_train, y_train))
# print(svr.score(X_test, y_test))
classifier = RandomForestClassifier()
classifier.fit(X_train, y_transformed)
y_pred = classifier.predict(X_test)
for i, prediction in enumerate(y_pred):
print(f"Rekord {i+1}: collapse={prediction}")
print(data_test.iloc[i, 0] + ": ")
print(prediction)