我已经使用随机树嵌入技术将数据转换为高维状态,现在需要保存输出。我该如何保存?

时间:2019-07-19 13:16:36

标签: python-3.x

我正在尝试将随机树嵌入的输出保存在.txt或.csv文件中。我试图使用此功能,   打印(X_train5,file = open(“ output.txt”,“ a”)) 但是它只保存一半的输出。 我需要将X_test5和X_train5的所有输出保存在.txt或.csv文件中。 enter image description here

我试图通过使用保存它, 打印(X_train5,file = open(“ output.txt”,“ a”)) 但这并没有保存所有输出。 我需要保存所有输出。

dataset5 = pd.read_csv(     'C:/ Users \ yubra \ Desktop \ MY_Papers \ Combined \ COM_MC_vs_M.csv')

 X5 = dataset5.iloc[:, :-1].values
 y5 = dataset5.iloc[:, 0].values

 X_train5, X_test5, y_train5, y_test5 = train_test_split(X5, y5, 
 test_size=0.30, random_state=48)

 sc = StandardScaler(copy=True, with_mean=True, with_std=True)
 X_train5 = sc.fit_transform(X_train5)
 X_test5 = sc.transform(X_test5)
 # # Random Tree Embedding
 X_iso = ensemble.RandomTreesEmbedding(n_estimators=200, 
 random_state=None, max_depth=5)
 model = X_iso.fit(X_train5)
 X_train5 = X_iso.fit_transform(X_train5)
 X_test5 = X_iso.transform(X_test5)
 print(X_train5, file=open("output.txt", "a"))

我需要将X_test5和X_train5的所有输出保存到.txt或.csv文件中。

0 个答案:

没有答案