datareader.cs
来自「Computational Intelligence IRIS dataset 」· CS 代码 · 共 37 行
CS
37 行
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
namespace CIProject
{
class DataReader
{
public static void ReadData(String fileName,
int rowCount,
int columnCount,
ref Double[][] result,
ref Double[] target)
{
String[] row = null;
/*result = new double[rowCount][];
target = new double[rowCount];
for (int i = 0; i < rowCount; i++)
{
result[i] = new double[columnCount - 1];
}*/
System.IO.StreamReader streamReader = new StreamReader(fileName);
for(int i = 0; i < rowCount; i++)
{
row = streamReader.ReadLine().Split(" ".ToCharArray());
for (int j = 0; j < columnCount-1; j++)
{
result[i][j] = Double.Parse(row[j]);
}
target[i] = Double.Parse(row[columnCount - 1]);
}
streamReader.Close();
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?