我怎样才能得到sparce混淆矩阵?

时间:2018-04-19 13:16:27

标签: python scikit-learn

我正在尝试为时间序列数据“滚动随机森林分类”。 该模型对两个类进行了分类。它会改变数据样本并适合几次,我的意思是“滚动”。

我得到每个样本集的混淆矩阵,并总结为最后一步。 但在几个样本集中,只有一个类出口。 在这种情况下,矩阵显示如下:

[[22]]

我想在下面提出这个案例;

[[22,0]  [0,0]]

你有任何想法让这件事发生吗?

1 个答案:

答案 0 :(得分:0)

试试这个

export const getMileageName = (
  state: GlobalState,
  pdbId: ?string = null,
  index?: number = 0,
): string => {
  const mileages = getMileages(state, pdbId);
  if (!mileages || !mileages[index]) {
    throw Error('Couldn\'t find mileage');
  }

  return mileages[index].name;
};

export const getMileageByKilometers = (
  state: GlobalState,
  pdbId: ?string = null,
  kilometers: number,
) => {
  const mileages = getMileages(state, pdbId);
  console.log(mileages);
  return mileages.find([0]);
};




const state = {
  pdb: {
    items: {
      1: {
        extras: {
          duration: [
            {
              name: 'duration-name',
              description: 'duration',
              duration: '40',
            },
          ],
          extra: [
            { name: 'extra' },
          ],
          contract: [
            { name: 'contract' },
          ],
          claimfree: [
            { name: 'claimfree' },
          ],
          mileage: [
            {
              name: '1.000 mileage',
              mileage: '1.000',
              description: 'mileage-description',
            },
            {
              name: '2.000 mileage',
              mileage: '2.000',
              description: 'mileage-description 2',
            },
            {
              name: '3.000 mileage',
              mileage: '3.000',
              description: 'mileage-description 3',
            },
          ],
        },
      },
    },
  },
};