我正在尝试使用几种技术在python中执行功能选择。我尝试应用的第一种技术是仅使用各种功能来选择功能。我的代码如下:
def feature_selection_technique(train, test, lbls, technique):
if technique == "variance":
sel = VarianceThreshold(threshold=(0.00010 * (1 - .15)))
model1 = sel1.fit_transform(face_train)
new_train = model1.transform(train)
new_test = model1.transform(test)
return new_train, new_test
实际上,我想使用训练数据集计算所选要素,然后将其应用于测试数据集。在这种情况下,似乎无法改变转换方法。在那种情况下我该怎么办?
答案 0 :(得分:1)
我认为您使用的语法存在问题。请参阅文档和示例here。正确的语法如下:
> Uncaught Error: Unexpected value 'PropDecoratorFactory' imported by the module 'AppModule'. Please add a @NgModule annotation.
at syntaxError (compiler.es5.js:1689)
at compiler.es5.js:15373
at Array.forEach (<anonymous>)
at CompileMetadataResolver.getNgModuleMetadata (compiler.es5.js:15356)
at JitCompiler._loadModules (compiler.es5.js:26679)
at JitCompiler._compileModuleAndComponents (compiler.es5.js:26652)
at JitCompiler.compileModuleAsync (compiler.es5.js:26581)
at PlatformRef_._bootstrapModuleWithZone (core.es5.js:4595)
at PlatformRef_.bootstrapModule (core.es5.js:4581)
at Object.107 (main.ts:10)
也就是说,您应该初始化
,然后将其拟合到训练数据并对其进行转换,然后转换测试数据。 import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { Input } from '@angular/core';
import { ViewChild } from '@angular/core';
import { Output } from '@angular/core';
import { AppComponent } from './app.component';
import { HeaderComponent } from './header/header.component';
import { PlayersBoardComponent } from './players-board/players-board.component';
import { PlayerComponent } from './players-board/player/player.component';
import { ScoresComponent } from './players-board/scores/scores.component';
import { CopmPlayerComponent } from './players-board/copm-player/copm-player.component';
@NgModule({
declarations: [
AppComponent,
HeaderComponent,
PlayersBoardComponent,
PlayerComponent,
ScoresComponent,
],
imports: [
BrowserModule,
FormsModule,
HttpModule,
ViewChild
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }