super(channel_selection, self).__init__() self.indexes = nn.Parameter(torch.ones(num_channels))

时间: 2024-05-23 07:15:53 浏览: 119
这两行代码是一个类的构造函数,用于初始化类的属性。第一行代码调用了父类的构造函数并传递了 `channel_selection` 参数,以便父类可以正确地初始化。第二行代码创建了一个名为 `indexes` 的可训练参数(`nn.Parameter`),它是一个大小为 `num_channels` 的张量,每个元素都被初始化为 1。这个参数在模型训练时会被动态更新,用于选择输入数据中的哪些通道参与计算。
相关问题

def forward(self, data, org_edge_index): x = data.clone().detach() edge_index_sets = self.edge_index_sets device = data.device batch_num, node_num, all_feature = x.shape x = x.view(-1, all_feature).contiguous() gcn_outs = [] for i, edge_index in enumerate(edge_index_sets): edge_num = edge_index.shape[1] cache_edge_index = self.cache_edge_index_sets[i] if cache_edge_index is None or cache_edge_index.shape[1] != edge_num*batch_num: self.cache_edge_index_sets[i] = get_batch_edge_index(edge_index, batch_num, node_num).to(device) batch_edge_index = self.cache_edge_index_sets[i] all_embeddings = self.embedding(torch.arange(node_num).to(device)) weights_arr = all_embeddings.detach().clone() all_embeddings = all_embeddings.repeat(batch_num, 1) weights = weights_arr.view(node_num, -1) cos_ji_mat = torch.matmul(weights, weights.T) normed_mat = torch.matmul(weights.norm(dim=-1).view(-1,1), weights.norm(dim=-1).view(1,-1)) cos_ji_mat = cos_ji_mat / normed_mat dim = weights.shape[-1] topk_num = self.topk topk_indices_ji = torch.topk(cos_ji_mat, topk_num, dim=-1)[1] self.learned_graph = topk_indices_ji gated_i = torch.arange(0, node_num).T.unsqueeze(1).repeat(1, topk_num).flatten().to(device).unsqueeze(0) gated_j = topk_indices_ji.flatten().unsqueeze(0) gated_edge_index = torch.cat((gated_j, gated_i), dim=0) batch_gated_edge_index = get_batch_edge_index(gated_edge_index, batch_num, node_num).to(device) gcn_out = self.gnn_layers[i](x, batch_gated_edge_index, node_num=node_num*batch_num, embedding=all_embeddings) gcn_outs.append(gcn_out) x = torch.cat(gcn_outs, dim=1) x = x.view(batch_num, node_num, -1) indexes = torch.arange(0,node_num).to(device) out = torch.mul(x, self.embedding(indexes)) out = out.permute(0,2,1) out = F.relu(self.bn_outlayer_in(out)) out = out.permute(0,2,1) out = self.dp(out) out = self.out_layer(out) out = out.view(-1, node_num) return out

这是一个PyTorch模型的前向传播函数,它接受两个参数:data和org_edge_index。该函数使用GCN(图卷积神经网络)来处理输入数据,并返回一个输出张量。具体实现细节可以参考代码中的注释。

class AbstractGreedyAndPrune(): def __init__(self, aoi: AoI, uavs_tours: dict, max_rounds: int, debug: bool = True): self.aoi = aoi self.max_rounds = max_rounds self.debug = debug self.graph = aoi.graph self.nnodes = self.aoi.n_targets self.uavs = list(uavs_tours.keys()) self.nuavs = len(self.uavs) self.uavs_tours = {i: uavs_tours[self.uavs[i]] for i in range(self.nuavs)} self.__check_depots() self.reachable_points = self.__reachable_points() def __pruning(self, mr_solution: MultiRoundSolution) -> MultiRoundSolution: return utility.pruning_multiroundsolution(mr_solution) def solution(self) -> MultiRoundSolution: mrs_builder = MultiRoundSolutionBuilder(self.aoi) for uav in self.uavs: mrs_builder.add_drone(uav) residual_ntours_to_assign = {i : self.max_rounds for i in range(self.nuavs)} tour_to_assign = self.max_rounds * self.nuavs visited_points = set() while not self.greedy_stop_condition(visited_points, tour_to_assign): itd_uav, ind_tour = self.local_optimal_choice(visited_points, residual_ntours_to_assign) residual_ntours_to_assign[itd_uav] -= 1 tour_to_assign -= 1 opt_tour = self.uavs_tours[itd_uav][ind_tour] visited_points |= set(opt_tour.targets_indexes) # update visited points mrs_builder.append_tour(self.uavs[itd_uav], opt_tour) return self.__pruning(mrs_builder.build()) class CumulativeGreedyCoverage(AbstractGreedyAndPrune): choice_dict = {} for ind_uav in range(self.nuavs): uav_residual_rounds = residual_ntours_to_assign[ind_uav] if uav_residual_rounds > 0: uav_tours = self.uavs_tours[ind_uav] for ind_tour in range(len(uav_tours)): tour = uav_tours[ind_tour] quality_tour = self.evaluate_tour(tour, uav_residual_rounds, visited_points) choice_dict[quality_tour] = (ind_uav, ind_tour) best_value = max(choice_dict, key=int) return choice_dict[best_value] def evaluate_tour(self, tour : Tour, round_count : int, visited_points : set): new_points = (set(tour.targets_indexes) - visited_points) return round_count * len(new_points) 如何改写上述程序,使其能返回所有已经探索过的目标点visited_points的数量,请用代码表示

可以在 `solution()` 方法中添加一个变量来记录已经探索过的目标点数量,然后在每次更新 `visited_points` 后更新这个变量。下面是修改后的代码: ``` class AbstractGreedyAndPrune(): def __init__(self, aoi: AoI, uavs_tours: dict, max_rounds: int, debug: bool = True): self.aoi = aoi self.max_rounds = max_rounds self.debug = debug self.graph = aoi.graph self.nnodes = self.aoi.n_targets self.uavs = list(uavs_tours.keys()) self.nuavs = len(self.uavs) self.uavs_tours = {i: uavs_tours[self.uavs[i]] for i in range(self.nuavs)} self.__check_depots() self.reachable_points = self.__reachable_points() def __pruning(self, mr_solution: MultiRoundSolution) -> MultiRoundSolution: return utility.pruning_multiroundsolution(mr_solution) def solution(self) -> Tuple[MultiRoundSolution, int]: mrs_builder = MultiRoundSolutionBuilder(self.aoi) for uav in self.uavs: mrs_builder.add_drone(uav) residual_ntours_to_assign = {i : self.max_rounds for i in range(self.nuavs)} tour_to_assign = self.max_rounds * self.nuavs visited_points = set() explored_points = 0 while not self.greedy_stop_condition(visited_points, tour_to_assign): itd_uav, ind_tour = self.local_optimal_choice(visited_points, residual_ntours_to_assign) residual_ntours_to_assign[itd_uav] -= 1 tour_to_assign -= 1 opt_tour = self.uavs_tours[itd_uav][ind_tour] new_points = set(opt_tour.targets_indexes) - visited_points explored_points += len(new_points) visited_points |= new_points # update visited points mrs_builder.append_tour(self.uavs[itd_uav], opt_tour) return self.__pruning(mrs_builder.build()), explored_points class CumulativeGreedyCoverage(AbstractGreedyAndPrune): def evaluate_tour(self, tour : Tour, round_count : int, visited_points : set): new_points = set(tour.targets_indexes) - visited_points return round_count * len(new_points) def local_optimal_choice(self, visited_points, residual_ntours_to_assign): choice_dict = {} for ind_uav in range(self.nuavs): uav_residual_rounds = residual_ntours_to_assign[ind_uav] if uav_residual_rounds > 0: uav_tours = self.uavs_tours[ind_uav] for ind_tour in range(len(uav_tours)): tour = uav_tours[ind_tour] quality_tour = self.evaluate_tour(tour, uav_residual_rounds, visited_points) choice_dict[quality_tour] = (ind_uav, ind_tour) best_value = max(choice_dict, key=int) return choice_dict[best_value]
阅读全文

相关推荐

class SVDRecommender: def __init__(self, k=50, ncv=None, tol=0, which='LM', v0=None, maxiter=None, return_singular_vectors=True, solver='arpack'): self.k = k self.ncv = ncv self.tol = tol self.which = which self.v0 = v0 self.maxiter = maxiter self.return_singular_vectors = return_singular_vectors self.solver = solver def svds(self, A): if self.which == 'LM': largest = True elif self.which == 'SM': largest = False else: raise ValueError("which must be either 'LM' or 'SM'.") if not (isinstance(A, LinearOperator) or isspmatrix(A) or is_pydata_spmatrix(A)): A = np.asarray(A) n, m = A.shape if self.k <= 0 or self.k >= min(n, m): raise ValueError("k must be between 1 and min(A.shape), k=%d" % self.k) if isinstance(A, LinearOperator): if n > m: X_dot = A.matvec X_matmat = A.matmat XH_dot = A.rmatvec XH_mat = A.rmatmat else: X_dot = A.rmatvec X_matmat = A.rmatmat XH_dot = A.matvec XH_mat = A.matmat dtype = getattr(A, 'dtype', None) if dtype is None: dtype = A.dot(np.zeros([m, 1])).dtype else: if n > m: X_dot = X_matmat = A.dot XH_dot = XH_mat = _herm(A).dot else: XH_dot = XH_mat = A.dot X_dot = X_matmat = _herm(A).dot def matvec_XH_X(x): return XH_dot(X_dot(x)) def matmat_XH_X(x): return XH_mat(X_matmat(x)) XH_X = LinearOperator(matvec=matvec_XH_X, dtype=A.dtype, matmat=matmat_XH_X, shape=(min(A.shape), min(A.shape))) #获得隐式定义的格拉米矩阵的低秩近似。 eigvals, eigvec = eigsh(XH_X, k=self.k, tol=self.tol ** 2, maxiter=self.maxiter, ncv=self.ncv, which=self.which, v0=self.v0) #格拉米矩阵有实非负特征值。 eigvals = np.maximum(eigvals.real, 0) #使用来自pinvh的小特征值的复数检测。 t = eigvec.dtype.char.lower() factor = {'f': 1E3, 'd': 1E6} cond = factor[t] * np.finfo(t).eps cutoff = cond * np.max(eigvals) #获得一个指示哪些本征对不是简并微小的掩码, #并为阈值奇异值创建一个重新排序数组。 above_cutoff = (eigvals > cutoff) nlarge = above_cutoff.sum() nsmall = self.k - nlarge slarge = np.sqrt(eigvals[above_cutoff]) s = np.zeros_like(eigvals) s[:nlarge] = slarge if not self.return_singular_vectors: return np.sort(s) if n > m: vlarge = eigvec[:, above_cutoff] ularge = X_matmat(vlarge) / slarge if self.return_singular_vectors != 'vh' else None vhlarge = _herm(vlarge) else: ularge = eigvec[:, above_cutoff] vhlarge = _herm(X_matmat(ularge) / slarge) if self.return_singular_vectors != 'u' else None u = _augmented_orthonormal_cols(ularge, nsmall) if ularge is not None else None vh = _augmented_orthonormal_rows(vhlarge, nsmall) if vhlarge is not None else None indexes_sorted = np.argsort(s) s = s[indexes_sorted] if u is not None: u = u[:, indexes_sorted] if vh is not None: vh = vh[indexes_sorted] return u, s, vh def _augmented_orthonormal_cols(U, n): if U.shape[0] <= n: return U Q, R = np.linalg.qr(U) return Q[:, :n] def _augmented_orthonormal_rows(V, n): if V.shape[1] <= n: return V Q, R = np.linalg.qr(V.T) return Q[:, :n].T def _herm(x): return np.conjugate(x.T) 将上述代码修改为使用LM,迭代器使用arpack

from scipy.sparse.linalg import eigsh, LinearOperator from scipy.sparse import isspmatrix, is_pydata_spmatrix class SVDRecommender: def init(self, k=50, ncv=None, tol=0, which='LM', v0=None, maxiter=None, return_singular_vectors=True, solver='arpack'): self.k = k self.ncv = ncv self.tol = tol self.which = which self.v0 = v0 self.maxiter = maxiter self.return_singular_vectors = return_singular_vectors self.solver = solver def svds(self, A): largest = self.which == 'LM' if not largest and self.which != 'SM': raise ValueError("which must be either 'LM' or 'SM'.") if not (isinstance(A, LinearOperator) or isspmatrix(A) or is_pydata_spmatrix(A)): A = np.asarray(A) n, m = A.shape if self.k <= 0 or self.k >= min(n, m): raise ValueError("k must be between 1 and min(A.shape), k=%d" % self.k) if isinstance(A, LinearOperator): if n > m: X_dot = A.matvec X_matmat = A.matmat XH_dot = A.rmatvec XH_mat = A.rmatmat else: X_dot = A.rmatvec X_matmat = A.rmatmat XH_dot = A.matvec XH_mat = A.matmat dtype = getattr(A, 'dtype', None) if dtype is None: dtype = A.dot(np.zeros([m, 1])).dtype else: if n > m: X_dot = X_matmat = A.dot XH_dot = XH_mat = _herm(A).dot else: XH_dot = XH_mat = A.dot X_dot = X_matmat = _herm(A).dot def matvec_XH_X(x): return XH_dot(X_dot(x)) def matmat_XH_X(x): return XH_mat(X_matmat(x)) XH_X = LinearOperator(matvec=matvec_XH_X, dtype=A.dtype, matmat=matmat_XH_X, shape=(min(A.shape), min(A.shape))) eigvals, eigvec = eigsh(XH_X, k=self.k, tol=self.tol ** 2, maxiter=self.maxiter, ncv=self.ncv, which=self.which, v0=self.v0) eigvals = np.maximum(eigvals.real, 0) t = eigvec.dtype.char.lower() factor = {'f': 1E3, 'd': 1E6} cond = factor[t] * np.finfo(t).eps cutoff = cond * np.max(eigvals) above_cutoff = (eigvals > cutoff) nlarge = above_cutoff.sum() nsmall = self.k - nlarge slarge = np.sqrt(eigvals[above_cutoff]) s = np.zeros_like(eigvals) s[:nlarge] = slarge if not self.return_singular_vectors: return np.sort(s) if n > m: vlarge = eigvec[:, above_cutoff] ularge = X_matmat(vlarge) / slarge if self.return_singular_vectors != 'vh' else None vhlarge = _herm(vlarge) else: ularge = eigvec[:, above_cutoff] vhlarge = _herm(X_matmat(ularge) / slarge) if self.return_singular_vectors != 'u' else None u = _augmented_orthonormal_cols(ularge, nsmall) if ularge is not None else None vh = _augmented_orthonormal_rows(vhlarge, nsmall) if vhlarge is not None else None indexes_sorted = np.argsort(s) s = s[indexes_sorted] if u is not None: u = u[:, indexes_sorted] if vh is not None: vh = vh[indexes_sorted] return u, s, vh def _augmented_orthonormal_cols(U, n): if U.shape[0] <= n: return U Q, R = np.linalg.qr(U) return Q[:, :n] def _augmented_orthonormal_rows(V, n): if V.shape[1] <= n: return V Q, R = np.linalg.qr(V.T) return Q[:, :n].T def _herm(x): return np.conjugate(x.T)这段代码中使用的scipy包太旧了,导致会出现报错信息为:cannot import name 'is_pydata_spmatrix' from 'scipy.sparse' (D:\Anaconda\lib\site-packages\scipy\sparse_init.py),将这段代码修改为使用最新版的scipy包

class SVDRecommender: def init(self, k=50, ncv=None, tol=0, which='LM', v0=None, maxiter=None, return_singular_vectors=True, solver='arpack'): self.k = k self.ncv = ncv self.tol = tol self.which = which self.v0 = v0 self.maxiter = maxiter self.return_singular_vectors = return_singular_vectors self.solver = solver def svds(self, A): if which == 'LM': largest = True elif which == 'SM': largest = False else: raise ValueError("which must be either 'LM' or 'SM'.") if not (isinstance(A, LinearOperator) or isspmatrix(A) or is_pydata_spmatrix(A)): A = np.asarray(A) n, m = A.shape if k <= 0 or k >= min(n, m): raise ValueError("k must be between 1 and min(A.shape), k=%d" % k) if isinstance(A, LinearOperator): if n > m: X_dot = A.matvec X_matmat = A.matmat XH_dot = A.rmatvec XH_mat = A.rmatmat else: X_dot = A.rmatvec X_matmat = A.rmatmat XH_dot = A.matvec XH_mat = A.matmat dtype = getattr(A, 'dtype', None) if dtype is None: dtype = A.dot(np.zeros([m, 1])).dtype else: if n > m: X_dot = X_matmat = A.dot XH_dot = XH_mat = _herm(A).dot else: XH_dot = XH_mat = A.dot X_dot = X_matmat = _herm(A).dot def matvec_XH_X(x): return XH_dot(X_dot(x)) def matmat_XH_X(x): return XH_mat(X_matmat(x)) XH_X = LinearOperator(matvec=matvec_XH_X, dtype=A.dtype, matmat=matmat_XH_X, shape=(min(A.shape), min(A.shape))) # Get a low rank approximation of the implicitly defined gramian matrix. eigvals, eigvec = eigsh(XH_X, k=k, tol=tol ** 2, maxiter=maxiter, ncv=ncv, which=which, v0=v0) # Gramian matrix has real non-negative eigenvalues. eigvals = np.maximum(eigvals.real, 0) # Use complex detection of small eigenvalues from pinvh. t = eigvec.dtype.char.lower() factor = {'f': 1E3, 'd': 1E6} cond = factor[t] * np.finfo(t).eps cutoff = cond * np.max(eigvals) # Get a mask indicating which eigenpairs are not degenerate tiny, # and create a reordering array for thresholded singular values. above_cutoff = (eigvals > cutoff) nlarge = above_cutoff.sum() nsmall = k - nlarge slarge = np.sqrt(eigvals[above_cutoff]) s = np.zeros_like(eigvals) s[:nlarge] = slarge if not return_singular_vectors: return np.sort(s) if n > m: vlarge = eigvec[:, above_cutoff] ularge = X_matmat(vlarge) / slarge if return_singular_vectors != 'vh' else None vhlarge = _herm(vlarge) else: ularge = eigvec[:, above_cutoff] vhlarge = _herm(X_matmat(ularge) / slarge) if return_singular_vectors != 'u' else None u = _augmented_orthonormal_cols(ularge, nsmall) if ularge is not None else None vh = _augmented_orthonormal_rows(vhlarge, nsmall) if vhlarge is not None else None indexes_sorted = np.argsort(s) s = s[indexes_sorted] if u is not None: u = u[:, indexes_sorted] if vh is not None: vh = vh[indexes_sorted] return u, s, vh将这段代码放入一个.py文件中,用Spyder查看,有报错,可能是缩进有问题,无法被调用,根据这个问题,给出解决办法,给出改正后的完整代码

bs_data = w_data[w_data['波束场景No'] == cross_data['波束场景No'][0]] 报错:Traceback (most recent call last): File "C:\Users\z84259074\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\core\indexes\base.py", line 3652, in get_loc return self._engine.get_loc(casted_key) File "pandas\_libs\index.pyx", line 147, in pandas._libs.index.IndexEngine.get_loc File "pandas\_libs\index.pyx", line 176, in pandas._libs.index.IndexEngine.get_loc File "pandas\_libs\hashtable_class_helper.pxi", line 7080, in pandas._libs.hashtable.PyObjectHashTable.get_item File "pandas\_libs\hashtable_class_helper.pxi", line 7088, in pandas._libs.hashtable.PyObjectHashTable.get_item KeyError: '波束场景No' The above exception was the direct cause of the following exception: Traceback (most recent call last): File "D:\Users\z84259074\PycharmProjects\参数自优化\self_optimizing.py", line 127, in <module> data = optimizing() File "D:\Users\z84259074\PycharmProjects\参数自优化\self_optimizing.py", line 18, in __init__ self.optimizing_main() File "D:\Users\z84259074\PycharmProjects\参数自优化\self_optimizing.py", line 120, in optimizing_main self.child2=self.mutation_cdata(fitness_data,self.cross_data) File "D:\Users\z84259074\PycharmProjects\参数自优化\self_optimizing.py", line 86, in mutation_cdata bs_data = w_data[w_data['波束场景No'] == cross_data['波束场景No'][0]] File "C:\Users\z84259074\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\core\frame.py", line 3761, in __getitem__ indexer = self.columns.get_loc(key) File "C:\Users\z84259074\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\core\indexes\base.py", line 3654, in get_loc raise KeyError(key) from err KeyError: '波束场景No'

(random.randint(0, bs_data[12]-1))*3+bs_data[8] 报错:Traceback (most recent call last): File "C:\Users\z84259074\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\core\indexes\base.py", line 3652, in get_loc return self._engine.get_loc(casted_key) File "pandas\_libs\index.pyx", line 147, in pandas._libs.index.IndexEngine.get_loc File "pandas\_libs\index.pyx", line 176, in pandas._libs.index.IndexEngine.get_loc File "pandas\_libs\hashtable_class_helper.pxi", line 7080, in pandas._libs.hashtable.PyObjectHashTable.get_item File "pandas\_libs\hashtable_class_helper.pxi", line 7088, in pandas._libs.hashtable.PyObjectHashTable.get_item KeyError: 12 The above exception was the direct cause of the following exception: Traceback (most recent call last): File "d:\Users\z84259074\PycharmProjects\参数自优化\self_optimizing.py", line 128, in <module> data = optimizing() File "d:\Users\z84259074\PycharmProjects\参数自优化\self_optimizing.py", line 15, in __init__ self.optimizing_main() File "d:\Users\z84259074\PycharmProjects\参数自优化\self_optimizing.py", line 124, in optimizing_main self.child2=self.mutation_cdata(fitness_data,self.cross_data) File "d:\Users\z84259074\PycharmProjects\参数自优化\self_optimizing.py", line 92, in mutation_cdata print('cross_data[波束场景No]',bs_data[12]) File "C:\Users\z84259074\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\core\frame.py", line 3761, in __getitem__ indexer = self.columns.get_loc(key) File "C:\Users\z84259074\AppData\Local\Programs\Python\Python310\lib\site-packages\pandas\core\indexes\base.py", line 3654, in get_loc raise KeyError(key) from err KeyError: 12

Traceback (most recent call last): File "D:\Anaconda\lib\site-packages\pandas\core\indexes\base.py", line 3802, in get_loc return self._engine.get_loc(casted_key) File "pandas\_libs\index.pyx", line 138, in pandas._libs.index.IndexEngine.get_loc File "pandas\_libs\index.pyx", line 165, in pandas._libs.index.IndexEngine.get_loc File "pandas\_libs\hashtable_class_helper.pxi", line 5745, in pandas._libs.hashtable.PyObjectHashTable.get_item File "pandas\_libs\hashtable_class_helper.pxi", line 5753, in pandas._libs.hashtable.PyObjectHashTable.get_item KeyError: 'A' The above exception was the direct cause of the following exception: Traceback (most recent call last): File "e:\Mydata\py\提取指定范围excel数据.py", line 7, in <module> data = df.loc[0:9, 'A':'B'] # 例如提取第1行到第10行,第1列到第3列的数据 File "D:\Anaconda\lib\site-packages\pandas\core\indexing.py", line 1067, in __getitem__ return self._getitem_tuple(key) File "D:\Anaconda\lib\site-packages\pandas\core\indexing.py", line 1256, in _getitem_tuple return self._getitem_tuple_same_dim(tup) File "D:\Anaconda\lib\site-packages\pandas\core\indexing.py", line 924, in _getitem_tuple_same_dim retval = getattr(retval, self.name)._getitem_axis(key, axis=i) File "D:\Anaconda\lib\site-packages\pandas\core\indexing.py", line 1290, in _getitem_axis return self._get_slice_axis(key, axis=axis) File "D:\Anaconda\lib\site-packages\pandas\core\indexing.py", line 1324, in _get_slice_axis indexer = labels.slice_indexer(slice_obj.start, slice_obj.stop, slice_obj.step) File "D:\Anaconda\lib\site-packages\pandas\core\indexes\base.py", line 6559, in slice_indexer start_slice, end_slice = self.slice_locs(start, end, step=step) File "D:\Anaconda\lib\site-packages\pandas\core\indexes\base.py", line 6767, in slice_locs start_slice = self.get_slice_bound(start, "left") File "D:\Anaconda\lib\site-packages\pandas\core\indexes\base.py", line 6686, in get_slice_bound raise err File "D:\Anaconda\lib\site-packages\pandas\core\indexes\base.py", line 6680, in get_slice_bound slc = self.get_loc(label) File "D:\Anaconda\lib\site-packages\pandas\core\indexes\base.py", line 3804, in get_loc raise KeyError(key) from err KeyError: 'A'

最新推荐

recommend-type

[Oracle] dbms_metadata.get_ddl 的使用方法总结

如果需要获取一个模式下所有对象的DDL,可以编写脚本来遍历`DBA_TABLES`、`DBA_VIEWS`、`DBA_INDEXES`、`DBA_OBJECTS`等数据字典视图。例如,获取所有表的DDL: ```sql SET PAGESIZE 0 SET LONG 90000 SET FEEDBACK...
recommend-type

基于springboot + vue前后端分离的完整小型电商系统全部资料+详细文档.zip

【资源说明】 基于springboot + vue前后端分离的完整小型电商系统全部资料+详细文档.zip 【备注】 1、该项目是个人高分项目源码,已获导师指导认可通过,答辩评审分达到95分 2、该资源内项目代码都经过测试运行成功,功能ok的情况下才上传的,请放心下载使用! 3、本项目适合计算机相关专业(人工智能、通信工程、自动化、电子信息、物联网等)的在校学生、老师或者企业员工下载使用,也可作为毕业设计、课程设计、作业、项目初期立项演示等,当然也适合小白学习进阶。 4、如果基础还行,可以在此代码基础上进行修改,以实现其他功能,也可直接用于毕设、课设、作业等。 欢迎下载,沟通交流,互相学习,共同进步!
recommend-type

R语言中workflows包的建模工作流程解析

资源摘要信息:"工作流程建模是将预处理、建模和后处理请求结合在一起的过程,从而优化数据科学的工作流程。工作流程可以将多个步骤整合为一个单一的对象,简化数据处理流程,提高工作效率和可维护性。在本资源中,我们将深入探讨工作流程的概念、优点、安装方法以及如何在R语言环境中使用工作流程进行数据分析和模型建立的例子。 首先,工作流程是数据处理的一个高级抽象,它将数据预处理(例如标准化、转换等),模型建立(例如使用特定的算法拟合数据),以及后处理(如调整预测概率)等多个步骤整合起来。使用工作流程,用户可以避免对每个步骤单独跟踪和管理,而是将这些步骤封装在一个工作流程对象中,从而简化了代码的复杂性,增强了代码的可读性和可重用性。 工作流程的优势主要体现在以下几个方面: 1. 管理简化:用户不需要单独跟踪和管理每个步骤的对象,只需要关注工作流程对象。 2. 效率提升:通过单次fit()调用,可以执行预处理、建模和模型拟合等多个步骤,提高了操作的效率。 3. 界面简化:对于具有自定义调整参数设置的复杂模型,工作流程提供了更简单的界面进行参数定义和调整。 4. 扩展性:未来的工作流程将支持添加后处理操作,如修改分类模型的概率阈值,提供更全面的数据处理能力。 为了在R语言中使用工作流程,可以通过CRAN安装工作流包,使用以下命令: ```R install.packages("workflows") ``` 如果需要安装开发版本,可以使用以下命令: ```R # install.packages("devtools") devtools::install_github("tidymodels/workflows") ``` 通过这些命令,用户可以将工作流程包引入到R的开发环境中,利用工作流程包提供的功能进行数据分析和建模。 在数据建模的例子中,假设我们正在分析汽车数据。我们可以创建一个工作流程,将数据预处理的步骤(如变量选择、标准化等)、模型拟合的步骤(如使用特定的机器学习算法)和后处理的步骤(如调整预测阈值)整合到一起。通过工作流程,我们可以轻松地进行整个建模过程,而不需要编写繁琐的代码来处理每个单独的步骤。 在R语言的tidymodels生态系统中,工作流程是构建高效、可维护和可重复的数据建模工作流程的重要工具。通过集成工作流程,R语言用户可以在一个统一的框架内完成复杂的建模任务,充分利用R语言在统计分析和机器学习领域的强大功能。 总结来说,工作流程的概念和实践可以大幅提高数据科学家的工作效率,使他们能够更加专注于模型的设计和结果的解释,而不是繁琐的代码管理。随着数据科学领域的发展,工作流程的工具和方法将会变得越来越重要,为数据处理和模型建立提供更加高效和规范的解决方案。"
recommend-type

管理建模和仿真的文件

管理Boualem Benatallah引用此版本:布阿利姆·贝纳塔拉。管理建模和仿真。约瑟夫-傅立叶大学-格勒诺布尔第一大学,1996年。法语。NNT:电话:00345357HAL ID:电话:00345357https://theses.hal.science/tel-003453572008年12月9日提交HAL是一个多学科的开放存取档案馆,用于存放和传播科学研究论文,无论它们是否被公开。论文可以来自法国或国外的教学和研究机构,也可以来自公共或私人研究中心。L’archive ouverte pluridisciplinaire
recommend-type

【工程技术中的数值分析秘籍】:数学问题的终极解决方案

![【工程技术中的数值分析秘籍】:数学问题的终极解决方案](https://media.geeksforgeeks.org/wp-content/uploads/20240429163511/Applications-of-Numerical-Analysis.webp) 参考资源链接:[东南大学_孙志忠_《数值分析》全部答案](https://wenku.csdn.net/doc/64853187619bb054bf3c6ce6?spm=1055.2635.3001.10343) # 1. 数值分析的数学基础 在探索科学和工程问题的计算机解决方案时,数值分析为理解和实施这些解决方案提供了
recommend-type

如何在数控车床仿真系统中正确进行机床回零操作?请结合手工编程和仿真软件操作进行详细说明。

机床回零是数控车床操作中的基础环节,特别是在仿真系统中,它确保了机床坐标系的正确设置,为后续的加工工序打下基础。在《数控车床仿真实验:操作与编程指南》中,你可以找到关于如何在仿真环境中进行机床回零操作的详尽指导。具体操作步骤如下: 参考资源链接:[数控车床仿真实验:操作与编程指南](https://wenku.csdn.net/doc/3f4vsqi6eq?spm=1055.2569.3001.10343) 首先,确保数控系统已经启动,并处于可以进行操作的状态。然后,打开机床初始化界面,解除机床锁定。在机床控制面板上选择回零操作,这通常涉及选择相应的操作模式或输入特定的G代码,例如G28或
recommend-type

Vue统计工具项目配置与开发指南

资源摘要信息:"该项目标题为'bachelor-thesis-stat-tool',是一个涉及统计工具开发的项目,使用Vue框架进行开发。从描述中我们可以得知,该项目具备完整的前端开发工作流程,包括项目设置、编译热重装、生产编译最小化以及代码质量检查等环节。具体的知识点包括: 1. Vue框架:Vue是一个流行的JavaScript框架,用于构建用户界面和单页应用程序。它采用数据驱动的视图层,并能够以组件的形式构建复杂界面。Vue的核心库只关注视图层,易于上手,并且可以通过Vue生态系统中的其他库和工具来扩展应用。 2. yarn包管理器:yarn是一个JavaScript包管理工具,类似于npm。它能够下载并安装项目依赖,运行项目的脚本命令。yarn的特色在于它通过一个锁文件(yarn.lock)来管理依赖版本,确保项目中所有人的依赖版本一致,提高项目的可预测性和稳定性。 3. 项目设置与开发流程: - yarn install:这是一个yarn命令,用于安装项目的所有依赖,这些依赖定义在package.json文件中。执行这个命令后,yarn会自动下载并安装项目所需的所有包,以确保项目环境配置正确。 - yarn serve:这个命令用于启动一个开发服务器,使得开发者可以在本地环境中编译并实时重载应用程序。在开发模式下,这个命令通常包括热重载(hot-reload)功能,意味着当源代码发生变化时,页面会自动刷新以反映最新的改动,这极大地提高了开发效率。 4. 生产编译与代码最小化: - yarn build:这个命令用于构建生产环境所需的代码。它通常包括一系列的优化措施,比如代码分割、压缩和打包,目的是减少应用程序的体积和加载时间,提高应用的运行效率。 5. 代码质量检查与格式化: - yarn lint:这个命令用于运行项目中的lint工具,它是用来检查源代码中可能存在的语法错误、编码风格问题、代码重复以及代码复杂度等问题。通过配置适当的lint规则,可以统一项目中的代码风格,提高代码的可读性和可维护性。 6. 自定义配置: - 描述中提到'请参阅',虽然没有具体信息,但通常意味着项目中会有自定义的配置文件或文档,供开发者参考,如ESLint配置文件(.eslintrc.json)、webpack配置文件等。这些文件中定义了项目的个性化设置,包括开发服务器设置、代码转译规则、插件配置等。 综上所述,这个项目集成了前端开发的常用工具和流程,展示了如何使用Vue框架结合yarn包管理器和多种开发工具来构建一个高效的项目。开发者需要熟悉这些工具和流程,才能有效地开发和维护项目。"
recommend-type

"互动学习:行动中的多样性与论文攻读经历"

多样性她- 事实上SCI NCES你的时间表ECOLEDO C Tora SC和NCESPOUR l’Ingén学习互动,互动学习以行动为中心的强化学习学会互动,互动学习,以行动为中心的强化学习计算机科学博士论文于2021年9月28日在Villeneuve d'Asq公开支持马修·瑟林评审团主席法布里斯·勒菲弗尔阿维尼翁大学教授论文指导奥利维尔·皮耶昆谷歌研究教授:智囊团论文联合主任菲利普·普雷教授,大学。里尔/CRISTAL/因里亚报告员奥利维耶·西格德索邦大学报告员卢多维奇·德诺耶教授,Facebook /索邦大学审查员越南圣迈IMT Atlantic高级讲师邀请弗洛里安·斯特鲁布博士,Deepmind对于那些及时看到自己错误的人...3谢谢你首先,我要感谢我的两位博士生导师Olivier和Philippe。奥利维尔,"站在巨人的肩膀上"这句话对你来说完全有意义了。从科学上讲,你知道在这篇论文的(许多)错误中,你是我可以依
recommend-type

74LS181逻辑电路设计:原理图到实际应用的速成课

参考资源链接:[4位运算功能验证:74LS181 ALU与逻辑运算实验详解](https://wenku.csdn.net/doc/2dn8i4v6g4?spm=1055.2635.3001.10343) # 1. 74LS181逻辑电路概述 ## 1.1 74LS181的定义与重要性 74LS181是一款广泛应用于数字逻辑设计的4位算术逻辑单元(ALU),它提供了一系列算术和逻辑运算功能,使得复杂的计算任务得以简化实现。该器件由16个引脚组成,是早期数字系统设计的核心组件之一。 ## 1.2 74LS181的应用背景 74LS181出现在计算机和数字电路设计的黄金时期,它支持多种二进制运
recommend-type

在集成电路测试中,如何根据JEDEC标准正确应用K因子校准方法来测量热阻?

对于从事半导体器件测试的工程师来说,掌握基于JEDEC标准的热阻测量方法是至关重要的。在这些方法中,K因子校准是确保热阻测量精度的关键步骤。为了帮助你深入理解并正确应用K因子校准方法,我们建议参考《JEDEC JESD51-1:集成电路热特性与电学测试》。这份文档详细介绍了如何进行K因子校准以及相关的测试流程。 参考资源链接:[JEDEC JESD51-1:集成电路热特性与电学测试](https://wenku.csdn.net/doc/3rddttq31q?spm=1055.2569.3001.10343) K因子校准方法涉及以下几个关键步骤: