我正在使用python 2.7中的pandas_ml软件包绘制混淆矩阵 使用以下代码
#include<iostream>
#include<fstream>
#include<string>
#include<string.h>
#include<exception>
#include<sstream>
using namespace std;
int main()
{
string arrival,burst[1000];
char string[] ="Job";
char *tokenptr;
int x=0;
tokenptr = strtok(string," ");
ifstream jobfile("job.csv");
if(jobfile.is_open())
{
cout << "Successfully open file"<<endl;
while(jobfile!=NULL)
{
getline(jobfile,arrival,',');
cout << arrival << endl;
try
{
if(arrival.length() < 30)
{
std::string jobstr = arrival.substr (28,1); //To take substring from arrival
stringstream job(jobstr);
int jobArr; // To convert string into integer
job >> jobArr;
cout<<"Job Arrival = " << jobArr <<endl;
}
if(arrival.length() == 30)
{
std::string jobstr = arrival.substr (29,2);
stringstream job(jobstr);
int jobArr;
job >> jobArr;
cout<<"Job Arrival = " << jobArr <<endl;
}
if(arrival.length() > 30)
{
std::string jobstr = arrival.substr (30,2);
stringstream job(jobstr);
int jobArr = 0;
job >> jobArr;
cout<<"Job Arrival = " << jobArr <<endl;
}
}
// To check exception
catch (std::exception const &exc)
{
std::cerr << "Exception caught " << exc.what() << "\n";
}
catch (...)
{
std::cerr << "Unknown exception caught\n";
}
for(int i=0;i < 4;i++)
{
getline(jobfile,burst[i],',');
cout<<burst[i]<<endl;
}
tokenptr=strtok(NULL," ");
if(tokenptr==0)
{
x+=1;
}
}
cout<<"Number of Job ="<< x <<endl;
}
jobfile.close();
}
如何指定配色方案?
答案 0 :(得分:0)
您可以执行以下操作,前提是后端不是Seaborn
plt.set_cmap('Blues')