-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from AngelsSoftwareOrg/develop
v1.0.0.8 - Cycle Release - LottoDataManagerSetup_v1.0.0.8 - Add dashboard report game next draw day - Pluralized the label on the jackpot group items on Dashboard - Copying data to clipboard, increase the gap between waiting time to 200ms - Add new Machine Learning - Draw Result Win Count Predictor - Update ReadMe
- Loading branch information
Showing
32 changed files
with
497 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
Includes/Classes/Generator/Types/DrawResultWinCountFastTreeTweedieRandomGenerator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
using LottoDataManager.Includes.Classes.ML.FastTreeTweedie.DrawResultWinCount; | ||
using LottoDataManager.Includes.Model.Details; | ||
using LottoDataManager.Includes.Utilities; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace LottoDataManager.Includes.Classes.Generator.Types | ||
{ | ||
public class DrawResultWinCountFastTreeTweedieRandomGenerator : AbstractSequenceGenerator, SequenceGenerator | ||
{ | ||
public DrawResultWinCountFastTreeTweedieRandomGenerator(LotteryDataServices lotteryDataServices) : base(lotteryDataServices) | ||
{ | ||
SeqGeneratorType = GeneratorType.DRAW_RESULT_WIN_COUNT_PREDICTION_FAST_TREE_REGRESSION; | ||
this.Description = ResourcesUtils.GetMessage("pick_class_draw_result_win_count_match_desc"); | ||
SequenceParams = new List<SequenceGeneratorParams>(); | ||
SequenceParams.Add(new SequenceGeneratorParams() | ||
{ | ||
GeneratorParamType = GeneratorParamType.COUNT, | ||
Description = ResourcesUtils.GetMessage("pick_class_draw_result_win_count_match_lp_count"), | ||
MaxCountValue = 99 | ||
}); | ||
SequenceParams.Add(new SequenceGeneratorParams() | ||
{ | ||
GeneratorParamType = GeneratorParamType.COUNT, | ||
Description = @ResourcesUtils.GetMessage("pick_class_draw_result_win_count_match_perc"), | ||
MaxCountValue = 100 | ||
}); | ||
} | ||
|
||
public bool AreParametersValueValid(out string errMessage) | ||
{ | ||
return ValidateCountParamField(out errMessage, 0) | ||
&& ValidateCountParamField(out errMessage, 1); | ||
} | ||
|
||
public List<int[]> GenerateSequence() | ||
{ | ||
int maximumPickCount = GetFieldParamValueForCount(0); | ||
int matchPerc = GetFieldParamValueForCount(1); | ||
int maxLoopBreaker = 10000; | ||
int maxLoopCtr = 0; | ||
List<int[]> results = new List<int[]>(); | ||
DrawResultWinCountInputModel sampleData; | ||
LotteryDrawResultSetup lotteryDrawResult = new LotteryDrawResultSetup(); | ||
lotteryDrawResult.GameCode = lotteryDataServices.LotteryDetails.GameCode; | ||
Random ran = new Random(); | ||
|
||
while (results.Count < maximumPickCount) | ||
{ | ||
int[] randomSeq = LuckyPickGenerator(ran); | ||
lotteryDrawResult.ResetSequenceToZero(); | ||
lotteryDrawResult.FillNumberBySeq(randomSeq); | ||
sampleData = lotteryDrawResult.GetDrawResultWinCountInputModel(true); | ||
DrawResultWinCountOutputModel output = DrawResultWinCountPredictor.Predict(sampleData); | ||
int score = (int)(output.Score * 100); | ||
|
||
if (score >= matchPerc) | ||
{ | ||
Array.Sort(randomSeq); | ||
results.Add(randomSeq); | ||
} | ||
if (maxLoopCtr++ > maxLoopBreaker) break; | ||
} | ||
return results; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
Includes/Classes/ML/FastTreeTweedie/DrawResultWinCount/DrawResultWinCountDataIntake.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using LottoDataManager.Includes.Classes.ML.TrainerProcessor; | ||
using LottoDataManager.Includes.Model.Details; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace LottoDataManager.Includes.Classes.ML.FastTreeTweedie.DrawResultWinCount | ||
{ | ||
public class DrawResultWinCountDataIntake : TrainerProcessorAbstract | ||
{ | ||
private static String DATA_TABLE_HEADERS = "game_cd,draw_date,num1,num2,num3,num4,num5,num6,draw_result\r\n"; | ||
private DrawResultWinCountTrainer drawResultWinCountTrainer; | ||
|
||
public DrawResultWinCountDataIntake(LotteryDataServices lotteryDataServices) : base(DATA_TABLE_HEADERS) | ||
{ | ||
this.LotteryDataServices = lotteryDataServices; | ||
this.drawResultWinCountTrainer = new DrawResultWinCountTrainer(); | ||
this.drawResultWinCountTrainer.ProcessingStatus += CommonTrainerInstanceEvent_ProcessingStatus; | ||
} | ||
|
||
public override void StartUpdate() | ||
{ | ||
CommonTrainerModelDrawResults(); | ||
} | ||
protected override DateTime GetDrawDateEquivalent(Object lotteryObject) | ||
{ | ||
LotteryDrawResult result = (LotteryDrawResult)lotteryObject; | ||
return result.GetDrawDate(); | ||
} | ||
protected override List<Object> GetTrainerDataSets(TrainerDataIntakeModel trainerDataIntakeModel) | ||
{ | ||
return LotteryDataServices.GetDrawResultWinCountMLDataset( | ||
trainerDataIntakeModel.GameMode, trainerDataIntakeModel.StartingDateTime).ToList<object>(); | ||
} | ||
protected override String GetDataSetEntry(Object lotteryModel) | ||
{ | ||
LotteryDrawResult model = (LotteryDrawResult)lotteryModel; | ||
return model.GetDrawResultWinCountModelDataIntake(); | ||
} | ||
protected override void CreateTrainerModel(String fileName) | ||
{ | ||
try | ||
{ | ||
CommonCreateTrainerModel(drawResultWinCountTrainer, fileName); | ||
} | ||
catch (Exception e) | ||
{ | ||
log(e.StackTrace); | ||
} | ||
} | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
Includes/Classes/ML/FastTreeTweedie/DrawResultWinCount/DrawResultWinCountInputModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using Microsoft.ML.Data; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace LottoDataManager.Includes.Classes.ML.FastTreeTweedie.DrawResultWinCount | ||
{ | ||
public class DrawResultWinCountInputModel | ||
{ | ||
[ColumnName(@"game_cd"), LoadColumn(0)] | ||
public float Game_cd { get; set; } | ||
|
||
[ColumnName(@"draw_date"), LoadColumn(1)] | ||
public string Draw_date { get; set; } | ||
|
||
[ColumnName(@"num1"), LoadColumn(2)] | ||
public float Num1 { get; set; } | ||
|
||
[ColumnName(@"num2"), LoadColumn(3)] | ||
public float Num2 { get; set; } | ||
|
||
[ColumnName(@"num3"), LoadColumn(4)] | ||
public float Num3 { get; set; } | ||
|
||
[ColumnName(@"num4"), LoadColumn(5)] | ||
public float Num4 { get; set; } | ||
|
||
[ColumnName(@"num5"), LoadColumn(6)] | ||
public float Num5 { get; set; } | ||
|
||
[ColumnName(@"num6"), LoadColumn(7)] | ||
public float Num6 { get; set; } | ||
|
||
[ColumnName(@"draw_result"), LoadColumn(8)] | ||
public float Draw_result { get; set; } | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
Includes/Classes/ML/FastTreeTweedie/DrawResultWinCount/DrawResultWinCountOutputModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace LottoDataManager.Includes.Classes.ML.FastTreeTweedie.DrawResultWinCount | ||
{ | ||
public class DrawResultWinCountOutputModel | ||
{ | ||
public float Score { get; set; } | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
Includes/Classes/ML/FastTreeTweedie/DrawResultWinCount/DrawResultWinCountPredictor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using Microsoft.ML; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace LottoDataManager.Includes.Classes.ML.FastTreeTweedie.DrawResultWinCount | ||
{ | ||
public class DrawResultWinCountPredictor : MLModelAbstract | ||
{ | ||
private static readonly String MODEL_NAME = "MLModel_5H_DrawResultWinCount.zip"; | ||
public static readonly Lazy<PredictionEngine<DrawResultWinCountInputModel, DrawResultWinCountOutputModel>> | ||
PredictEngine = new Lazy<PredictionEngine<DrawResultWinCountInputModel, DrawResultWinCountOutputModel>>(() => | ||
CreatePredictEngine(), true); | ||
|
||
public static String MLNetModelPath | ||
{ | ||
get | ||
{ | ||
return GetCompleteModelPath(MODEL_NAME); | ||
} | ||
} | ||
|
||
public static bool IsMLModelExisting(String folderPath = null) | ||
{ | ||
return IsModelExists(MODEL_NAME, folderPath); | ||
} | ||
|
||
|
||
/// <summary> | ||
/// Use this method to predict on <see cref="DrawResultWinCountOutputModel"/>. | ||
/// </summary> | ||
/// <param name="input">model input.</param> | ||
/// <returns><seealso cref=" DrawResultWinCountInputModel"/></returns> | ||
public static DrawResultWinCountOutputModel Predict(DrawResultWinCountInputModel input) | ||
{ | ||
var predEngine = PredictEngine.Value; | ||
return predEngine.Predict(input); | ||
} | ||
|
||
private static PredictionEngine<DrawResultWinCountInputModel, DrawResultWinCountOutputModel> CreatePredictEngine() | ||
{ | ||
var mlContext = new MLContext(); | ||
ITransformer mlModel = mlContext.Model.Load(MLNetModelPath, out var _); | ||
return mlContext.Model.CreatePredictionEngine<DrawResultWinCountInputModel, DrawResultWinCountOutputModel>(mlModel); | ||
} | ||
|
||
} | ||
} |
Oops, something went wrong.