因素" X"有新的水平a,b,c ...(逻辑回归)

时间:2016-05-10 20:19:57

标签: r logistic-regression

我尝试对数据集应用逻辑回归,但是我遇到了这个问题

import {Component, Input, forwardRef, ViewChildren} from '@angular/core'

interface MenuItem {
  title: string;
  items: Array<MenuItem>
}

@Component({
  selector: 'li.menu-item',
  styles: [`
    .block {
      display: block;
    }
  `],
  template: `
   <a [ngClass]="{'right-caret': !!data.items && !opened, 'left-caret': !!data.items && opened}" (click)="onClick($event)">{{data.title}}</a>
   <template [ngIf]="!!data.items">
    <ul class="dropdown-menu sub-menu" [ngClass]="{'block': opened}">
     <li class="menu-item" *ngFor="let menuItem of data.items" [data]="menuItem">
     </li>
    </ul>
   </template>
  `,
  directives: [forwardRef(()=> MenuItem)]
})
export class MenuItem {
  @Input() data: MenuItem;
  @ViewChildren(MenuItem) children:QueryList<MenuItem>;
  private _opened: boolean = false;
  get opened() {
    return this._opened;
  };
  set opened(val) {
    this._opened = val;
    if(!val) {
      this.children.toArray().forEach(x => x.opened = false)
    }
  }
  onClick(e){
    this.opened = !this.opened;
    if(this.data.items) {
      e.stopPropagation();
    }
  }
}

我尝试从测试数据集中删除属性Margin但是错误再次出现,并且具有不同的属性。

这是我的代码

Error in model.frame.default(Terms, newdata, na.action = na.action, xlev = object$xlevels) : 
  factor Margin has new levels 14 runs, 19 runs, 3 wickets, 9 wickets, 95 runs

model1的输出是

#applying Logistic Regression
model1 <- glm(Team1.Result ~ Matchid    +Team2  + Margin    +   Toss +  Bat + Ground +  Date +  Team1.BatRate   + Team1.Bat_SR +    Team1.BowlRate +    Team1.Bowl_SR   + Team2.BatRate +   Team2.Bat_SR +  Team2.BowlRate +    Team2.Bowl_SR, family=binomial(link='logit'),data=data_train)
summary(model1)


fitted.results <- predict(model1,newdata= test,type='response')
fitted.results <- ifelse(fitted.results > 0.5,1,0)

misClasificError <- mean(fitted.results != data_test$Survived)
print(paste('Accuracy',1-misClasificError))

str(data_test $ Margin)和str(data_train $ Margin)

(Dispersion parameter for binomial family taken to be 1)

    Null deviance: 4.6070e+01  on 33  degrees of freedom
Residual deviance: 5.3617e-10  on  0  degrees of freedom
AIC: 68

Number of Fisher Scoring iterations: 24

我的问题是如何删除此错误?

0 个答案:

没有答案
相关问题