Пример #1
0
    public void CreateDangerousEngine()
    {
        DangerousEngineCreated = true;

        //var trainingFilePath = string.Format(@"Assets/StreamingAssets/{0}", Data.Instance.TraingDangerousDataPath);
        //var testingFilePath = string.Format(@"Assets/StreamingAssets/{0}", Data.Instance.TestDangerousDataPath);
        var trainingFilePath = UsefullUtils.GetPathToStreamingAssetsFile(Data.Instance.TraingDangerousDataPath);
        var testingFilePath  = UsefullUtils.GetPathToStreamingAssetsFile(Data.Instance.TestDangerousDataPath);

        var trainingData = GetDataFromCsv(trainingFilePath);
        var testData     = GetDataFromCsv(testingFilePath);

        IDataView dataView     = mlContext.Data.LoadFromEnumerable(trainingData);
        IDataView testDataView = mlContext.Data.LoadFromEnumerable(testData);

        // Step 4 - we need to create the pipeline and define the workflows in it
        //                  switch params: ("FeedBackText", "Features") to => ("Features", "FeedbackText")
        var pipeline = mlContext.Transforms.Text.FeaturizeText("Features", "Features")

                       .Append(mlContext.BinaryClassification.Trainers
                               .FastTree(numberOfLeaves: 50, numberOfTrees: 50, minimumExampleCountPerLeaf: 1));

        // Step 5 - traing the algorithm and get the model out
        var model = pipeline.Fit(dataView);

        var predictions = model.Transform(testDataView);
        var metrics     = mlContext.BinaryClassification.Evaluate(predictions, "Label");

        // Step 7 - Use model
        _dangerousPredictionsEngine = mlContext.Model.CreatePredictionEngine
                                      <FeedBackTrainingData, FeedBackPrediction>
                                          (model);
    }
Пример #2
0
    public void ReadString()
    {
        string path = UsefullUtils.GetPathToStreamingAssetsFile("Settings.txt");

        //Read the text from directly from the test.txt file
        StreamReader reader = new StreamReader(path);

        IS_LOGGED_IN = reader.ReadToEnd() == "LOGGED_IN";
        reader.Close();
    }
Пример #3
0
    public void UpdateCategoriesQuestions()
    {
        var savedCategories = DataService.GetAllCategories();

        foreach (var category in savedCategories)
        {
            var filePath = UsefullUtils.GetPathToStreamingAssetsFile(category.File + ".html");
            category.MaxLines = UsefullUtils.CountLinesInFile(filePath);
        }

        DataService.WriteCategoriesData(savedCategories, update: true);
    }
Пример #4
0
    public (IDataView training, IDataView test) LoadData(MLContext mlContext)
    {
        var trainingPath = Data.Instance.TraingDataPath;
        var testingPath  = Data.Instance.TraingDataPath;


        //var trainingDataPath = string.Format(@"Assets/StreamingAssets/{0}", trainingPath);
        //var testDataPath = string.Format(@"Assets/StreamingAssets/{0}", testingPath);

        var trainingDataPath = UsefullUtils.GetPathToStreamingAssetsFile(trainingPath);
        var testDataPath     = UsefullUtils.GetPathToStreamingAssetsFile(testingPath);

        IDataView trainingDataView = mlContext.Data.LoadFromTextFile <MedicRating>(trainingDataPath, hasHeader: true, separatorChar: ',');
        IDataView testDataView     = mlContext.Data.LoadFromTextFile <MedicRating>(testDataPath, hasHeader: true, separatorChar: ',');

        return(trainingDataView, testDataView);
    }
Пример #5
0
    public void WriteString(string setting)
    {
        string path = UsefullUtils.GetPathToStreamingAssetsFile("Settings.txt");

        File.WriteAllText(path, setting);
    }