GithubHelp home page GithubHelp logo

2020huaweicodecraftwarmup's Introduction

2020HuaweiCodecraft

用贝叶斯分类器来解决二分类问题,训练数据选择了1580个样本,维度选择400,卡了准确度69.5,最终成绩0.022,rank 12.

问题描述

给定训练集,训练集有N个样本,每个样本有1000维特征,样本所属类别有两种,0类和1类。对测试集中的Y个样本(1000维特征)进行预测,最终的分数与预测的准确、程序运行时间相关。

解题思路

考虑最终的分数与运行时间、准确度均有关,但是惩罚系数并不是很大,于是就想着去卡70%准确度,寻找一种可以并行的算法来对测试集进行预测。这里选择了贝叶斯分类器,然后就一条路走到黑。对于朴素贝叶斯分类器,详细的介绍可自行百度查阅,最终需要的只是一个公式:

如果P(1|x)>P(0|x),那么当前样本预测为1,否则预测为0。为了防止下溢,两边开log可以化为加法,然后平滑处理一下,得到两个公式的系数向量mu[0]和mu[1]。最终的P(x|0) = Dot(vt, mu[0]) + P(0), P(x|1) = Dot(vt, mu[1]) + P(1)。如果 P(x|1) - P(x|0) > 0,就预测为1,这里可以提前预处理mu[1] - m[0],少做一次点乘,即P(x|1) - P(x|0) = Dot(vt, mu[1] - mu[0]) + P(1) - P(0)。

数据读取选择mmap,循环加速建议查看华为官方鲲鹏920代码调优指南文档,利用多线程和多进程加速,卡一下准确度,减少程序中的赋值操作等,可以得到一个不错的结果。(面向对象的程序好像会慢一些,就去掉了)。

2020huaweicodecraftwarmup's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.