Advertisement
Guest User

Untitled

a guest
May 19th, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. /// <summary>
  2. /// The main program class.
  3. /// </summary>
  4. public class Program
  5. {
  6. // filenames for training and test data
  7. private static string trainingDataPath = Path.Combine(Environment.CurrentDirectory, "train_data.csv");
  8. private static string testDataPath = Path.Combine(Environment.CurrentDirectory, "test_data.csv");
  9.  
  10. /// <summary>
  11. /// The main application entry point.
  12. /// </summary>
  13. /// <param name="args">The command line arguments.</param>
  14. public static void Main(string[] args)
  15. {
  16. // set up a machine learning context
  17. var mlContext = new MLContext();
  18.  
  19. // set up a text loader
  20. var textLoader = mlContext.Data.CreateTextLoader(
  21. new TextLoader.Options()
  22. {
  23. Separators = new[] { ',' },
  24. HasHeader = true,
  25. AllowQuoting = true,
  26. Columns = new[]
  27. {
  28. new TextLoader.Column("Label", DataKind.Boolean, 1),
  29. new TextLoader.Column("Pclass", DataKind.Single, 2),
  30. new TextLoader.Column("Name", DataKind.String, 3),
  31. new TextLoader.Column("Sex", DataKind.String, 4),
  32. new TextLoader.Column("RawAge", DataKind.String, 5), // <-- not a float!
  33. new TextLoader.Column("SibSp", DataKind.Single, 6),
  34. new TextLoader.Column("Parch", DataKind.Single, 7),
  35. new TextLoader.Column("Ticket", DataKind.String, 8),
  36. new TextLoader.Column("Fare", DataKind.Single, 9),
  37. new TextLoader.Column("Cabin", DataKind.String, 10),
  38. new TextLoader.Column("Embarked", DataKind.String, 11)
  39. }
  40. }
  41. );
  42.  
  43. // load training and test data
  44. Console.WriteLine("Loading data...");
  45. var trainingDataView = textLoader.Load(trainingDataPath);
  46. var testDataView = textLoader.Load(testDataPath);
  47.  
  48. // the rest of the code goes here...
  49. }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement