11import torch
2- import _pickle as pickle
2+ import pickle
33import os
4- import sys
5- from scipy .sparse import lil_matrix
64import numpy as np
7- from sklearn .preprocessing import normalize
8- import xclib .data .data_utils as data_utils
9- import operator
10- from .lookup import Table , PartitionedTable
115from .features import construct as construct_f
126from .labels import construct as construct_l
137
@@ -44,7 +38,7 @@ def construct(self, data_dir, fname, data, indices, normalize, _type):
4438 data = construct_f (data_dir , fname , data , normalize , _type )
4539 if indices is not None :
4640 indices = np .loadtxt (indices , dtype = np .int64 )
47- data .index_select (indices )
41+ data ._index_select (indices )
4842 return data
4943
5044 def __len__ (self ):
@@ -126,12 +120,12 @@ def __init__(self, data_dir, fname_features, fname_labels,
126120 def _remove_samples_wo_features_and_labels (self ):
127121 """Remove instances if they don't have any feature or label
128122 """
129- indices = self .features .get_valid (axis = 1 )
123+ indices = self .features .get_valid_indices (axis = 1 )
130124 if self .labels is not None :
131- indices_labels = self .labels .get_valid (axis = 1 )
125+ indices_labels = self .labels .get_valid_indices (axis = 1 )
132126 indices = np .intersect1d (indices , indices_labels )
133- self .labels .index_select (indices , axis = 0 )
134- self .features .index_select (indices , axis = 0 )
127+ self .labels ._index_select (indices , axis = 0 )
128+ self .features ._index_select (indices , axis = 0 )
135129
136130 def index_select (self , feature_indices , label_indices ):
137131 """Transform feature and label matrix to specified
@@ -145,11 +139,11 @@ def _get_split_id(fname):
145139 if label_indices is not None :
146140 self ._split = _get_split_id (label_indices )
147141 label_indices = np .loadtxt (label_indices , dtype = np .int32 )
148- self .labels .index_select (label_indices , axis = 1 )
142+ self .labels ._index_select (label_indices , axis = 1 )
149143 if feature_indices is not None :
150144 self ._split = _get_split_id (feature_indices )
151145 feature_indices = np .loadtxt (feature_indices , dtype = np .int32 )
152- self .features .index_select (feature_indices , axis = 1 )
146+ self .features ._index_select (feature_indices , axis = 1 )
153147
154148 def load_features (self , data_dir , fname , X ,
155149 normalize_features , feature_type ):
@@ -216,7 +210,7 @@ def _process_labels_predict(self, data_obj):
216210 example
217211 """
218212 valid_labels = data_obj ['valid_labels' ]
219- self .labels .index_select (valid_labels )
213+ self .labels ._index_select (valid_labels , axis = 1 )
220214
221215 def _process_labels (self , model_dir ):
222216 """Process labels to handle labels without any training instance;
0 commit comments