美文网首页C++计算机杂谈程序员
【毕设进行时-工业大数据,数据挖掘】用C++对数据进行整改,修缮

【毕设进行时-工业大数据,数据挖掘】用C++对数据进行整改,修缮

作者: 张照博 | 来源:发表于2018-04-05 17:35 被阅读84次

    正文之前

    因为数据差距实在太大,从10-10000都有,要是全搞决策树我估计我是啥都不用搞了,看着电脑卡死就ok!所以特地将连续的数据转化为连续的数据!看看是不是会生成新的、更好地决策树!

    正文

    废话不多说!直接丢代码!不然真是难受的一批!写了好一会儿才搞定的!

    #include<iostream>
    #include<string>
    #include<fstream>
    using namespace std;
    
    int main()
    {
        int count=0;
        float attr[34];
        ifstream in("/Users/zhangzhaobo/Documents/Graduation-Design/Mydata.txt");
        ofstream out("/Users/zhangzhaobo/Documents/Graduation-Design/Data/New_Data.txt");
        string line[34];
        for (int i = 0; i < 34; ++i)
        {
            in>>line[i];
        }
        out<<"Diff_X"<<"\t"<<"Diff_Y"<<"\t";
        for (int i = 4; i < 8; ++i)
        {
            out<<line[i]<<"\t";
        }
        out<<"Diff_Luminosity\t";
        out<<line[10]<<"\t";
        out<<"TypeouOfSteel\t";
        for (int i = 13; i < 27; ++i)
        {
            out<<line[i]<<"\t";
        }
        out<<"Fault";
        out<<endl;
        float maxX,MaxY,MaxL;
        while(count<1941)
        {
            for (int i = 0; i < 34; ++i)
            {
                in>>attr[i];
            }
            float X_dis=attr[1]-attr[0];
            float Y_dis=attr[3]-attr[2];
            float Luminosity_dis=attr[9]-attr[8];
            float TypeOfSteel=attr[11];
            out<<X_dis<<"\t"<<Y_dis<<"\t";
            for (int i = 4; i < 8; ++i)
            {
                out<<attr[i]<<"\t";
            }
            out<<Luminosity_dis<<"\t";
            out<<attr[10]<<"\t";
            out<<TypeOfSteel<<"\t";
            for (int i = 13; i < 27; ++i)
            {
                out<<attr[i]<<"\t";
            }
            int Fault=0;
            for (int i = 0; i < 7; ++i)
            {
                Fault=(Fault+attr[i+27])*2;
            }
            out<<Fault<<endl;
            count++;
        }
        in.close();
        return 0;
    }
    

    正文

    改善之后的属性为:

    Diff_X  Diff_Y  Pixels_Areas    X_Perimeter Y_Perimeter Sum_of_Luminosity   Diff_Luminosity Length_of_Conveyer  TypeouOfSteel   Steel_Plate_Thickness   Edges_Index Empty_Index Square_Index    Outside_X_Index Edges_X_Index   Edges_Y_Index   Outside_Global_Index    LogOfAreas  Log_X_Index Log_Y_Index Orientation_Index   Luminosity_Index    SigmoidOfAreas  Fault
    8   44  267 17  44  24220   32  1687    1   80  0.0498  0.2415  0.1818  0.0047  0.4706  1   1   2.4265  0.9031  1.6435  0.8182  -0.2913 0.5822  128
    6   29  108 10  30  11397   39  1687    1   80  0.7647  0.3793  0.2069  0.0036  0.6 0.9667  1   2.0334  0.7782  1.4624  0.7931  -0.1756 0.2984  128
    

    为此还特地写了个C++的程序来观察!

    #include<iostream>
    #include<string>
    #include<fstream>
    using namespace std;
    
    int main()
    {
        string line[72];
        int count=0;
        for (int i = 0; i < 72; ++i)
        {
            cin>>line[i];
        }
        for (int i = 0; i < 24; ++i)
        {
            cout<<"[->"<<i<<": "<<line[i]<<" --> "<<line[i+24]<<" --> "<<line[i+48]<<endl;
            /* code */
        }
    }
    

    最后整出来还蛮好看!

    相关文章

      网友评论

      • 悟2023:你的开发IDE是什么?
        张照博:@紫葡萄0 都是一个公司的!C++的是CLion Java的是IntelliJ
        QxQx:@海棠依旧r_o 看着像clion
      • 张照博:那个光度总值实在讨厌,我干脆给删了!美滋滋
        #include<iostream>
        #include<string>
        #include<fstream>
        using namespace std;

        int main()
        {
        int count=0;
        float attr[34];
        ifstream in("/Users/zhangzhaobo/Documents/Graduation-Design/Mydata.txt");
        ofstream out("/Users/zhangzhaobo/Documents/Graduation-Design/Data/New_Data.txt");
        string line[34];
        for (int i = 0; i < 34; ++i)
        {
        in>>line[i];
        }
        out<<"Diff_X"<<"\t"<<"Diff_Y"<<"\t";
        for (int i = 4; i < 7; ++i)
        {
        out<<line[i]<<"\t";
        }
        out<<"Diff_Luminosity\t";
        out<<line[10]<<"\t";
        out<<"TypeouOfSteel\t";
        for (int i = 13; i < 27; ++i)
        {
        out<<line[i]<<"\t";
        }
        out<<"Fault";
        out<<endl;
        float maxX,MaxY,MaxL;
        while(count<1941)
        {
        for (int i = 0; i < 34; ++i)
        {
        in>>attr[i];
        }
        float X_dis=attr[1]-attr[0];
        float Y_dis=attr[3]-attr[2];
        float Luminosity_dis=attr[9]-attr[8];
        float TypeOfSteel=attr[11];
        if (X_dis>maxX)
        {
        maxX=X_dis;
        /* code */
        }
        if (Y_dis>MaxY)
        {
        MaxY=Y_dis;
        /* code */
        }
        if (Luminosity_dis>MaxL)
        {
        MaxL=Luminosity_dis;
        /* code */
        }
        out<<X_dis<<"\t"<<Y_dis<<"\t";
        for (int i = 4; i < 7; ++i)
        {
        out<<attr[i]<<"\t";
        }
        out<<Luminosity_dis<<"\t";
        out<<attr[10]<<"\t";
        out<<TypeOfSteel<<"\t";
        for (int i = 13; i < 27; ++i)
        {
        out<<attr[i]<<"\t";
        }
        int Fault=0;
        for (int i = 0; i < 7; ++i)
        {
        Fault=(Fault+attr[i+27])*2;
        }
        out<<Fault<<endl;
        count++;
        }
        cout<<"|"<<maxX<<"|"<<MaxY<<"|"<<MaxL<<endl;
        in.close();
        return 0;
        }

      本文标题:【毕设进行时-工业大数据,数据挖掘】用C++对数据进行整改,修缮

      本文链接:https://www.haomeiwen.com/subject/mqddhftx.html