#include<bits/stdc++.h>
using namespace std;
#define ROWS 100
#define COLUMNS 10001
#define MAXITERTIMES 1000
int matrix[ROWS][COLUMNS];
int trainY[ROWS],testY[ROWS],myY[ROWS];
int W[COLUMNS] = {0};//因为多了一个x0;
int bestW[COLUMNS] = {0};
ofstream output;
ifstream Input;
int iterTimes = 0;//迭代次数
int sign(int x) {return x >= 0 ? +1 : -1; }
void makeUpMatrix(string fileName)
{
int lines = 0;
Input.open(fileName.c_str());
string line;
while(getline(Input,line))
{
stringstream ss;
int columns = 1;
//一行一句话的,所以用stringstream,整行读入的特性会方便很多
ss.clear();
ss.str(line);//From:http://blog.csdn.net/lanbing510/article/details/42423333
//str()成员函数的使用可以让istringstream对象返回一个string字符串
int dict;
matrix[lines][0] = 1;
while(ss>>dict) //读入每行的数据集内容的词汇
{
matrix[lines][columns++] = dict;
}
//读取完这行词汇了
lines++; //第几行计数
}
Input.close();
}
void readLabels()
{
using namespace std;
#define ROWS 100
#define COLUMNS 10001
#define MAXITERTIMES 1000
int matrix[ROWS][COLUMNS];
int trainY[ROWS],testY[ROWS],myY[ROWS];
int W[COLUMNS] = {0};//因为多了一个x0;
int bestW[COLUMNS] = {0};
ofstream output;
ifstream Input;
int iterTimes = 0;//迭代次数
int sign(int x) {return x >= 0 ? +1 : -1; }
void makeUpMatrix(string fileName)
{
int lines = 0;
Input.open(fileName.c_str());
string line;
while(getline(Input,line))
{
stringstream ss;
int columns = 1;
//一行一句话的,所以用stringstream,整行读入的特性会方便很多
ss.clear();
ss.str(line);//From:http://blog.csdn.net/lanbing510/article/details/42423333
//str()成员函数的使用可以让istringstream对象返回一个string字符串
int dict;
matrix[lines][0] = 1;
while(ss>>dict) //读入每行的数据集内容的词汇
{
matrix[lines][columns++] = dict;
}
//读取完这行词汇了
lines++; //第几行计数
}
Input.close();
}
void readLabels()
{