features_i_df = pd.read_csv(self.subset_i, sep="\t", header=0)
if isinstance(X, pd.DataFrame): // use columns" names
self.feature_names = list(X.columns.values)
feature_i = [str(val) for val in features_i_df.values.flatten()]
elif isinstance(X, np.ndarray): // use index
self.feature_names = list(range(X.shape[1]))
feature_i = [int(val) for val in features_i_df.values.flatten()]
After Change
subset_df = pd.read_csv(self.subset_list, header=0, index_col=0)
if isinstance(self.sel_subset, int):
self.sel_subset_name = subset_df.index[self.sel_subset]
elif isinstance(self.sel_subset, list):
self.sel_subset_name = []
for s in self.sel_subset:
if isinstance(s, int):
self.sel_subset_name.append(subset_df.index[s])
else:
self.sel_subset_name.append(s)
else: // self.sel_subset is a string
self.sel_subset_name = self.sel_subset
sel_features = subset_df.loc[self.sel_subset_name, "Features"]
if not isinstance(sel_features, str):
sel_features = ";".join(sel_features.tolist())
sel_uniq_features = set(sel_features.split(""))
if isinstance(X, pd.DataFrame): // use columns" names
self.feature_names = list(X.columns.values)
elif isinstance(X, np.ndarray): // use index