- Hands-On Machine Learning with ML.NET
- Jarred Capellman
- 88字
- 2021-06-24 16:43:34
The FeatureExtractor class
This newly added class provides our feature extraction for the given folder of files. Once extraction is complete, the classification and strings data is written out to the sampledata file:
using System;
using System.IO;
using chapter03_logistic_regression.Common;
using chapter03_logistic_regression.ML.Base;
namespace chapter03_logistic_regression.ML
{
public class FeatureExtractor : BaseML
{
public void Extract(string folderPath)
{
var files = Directory.GetFiles(folderPath);
using (var streamWriter =
new StreamWriter(Path.Combine(AppContext.BaseDirectory, $"../../../Data/{Constants.SAMPLE_DATA}")))
{
foreach (var file in files)
{
var strings = GetStrings(File.ReadAllBytes(file));
streamWriter.WriteLine($"{file.ToLower().Contains("malicious")}\t{strings}");
}
}
Console.WriteLine($"Extracted {files.Length} to {Constants.SAMPLE_DATA}");
}
}
}
推薦閱讀
- 密碼學原理與Java實現
- 新編Premiere Pro CC從入門到精通
- 快速念咒:MySQL入門指南與進階實戰
- Protocol-Oriented Programming with Swift
- 從Java到Web程序設計教程
- 編程菜鳥學Python數據分析
- Babylon.js Essentials
- Java語言程序設計教程
- Learning Modular Java Programming
- Functional Python Programming
- UML基礎與Rose建模實用教程(第三版)
- Java EE輕量級解決方案:S2SH
- Mastering Vim
- Python編程零基礎入門
- 軟件定義存儲:原理、實踐與生態