pascalabcnet/InstallerSamples/MachineLearning/08_Datasets/TitanicRu/04_AgeHistogramBySurvival.pas
Mikhalkovich Stanislav 7eaddd9a54 ML - множество примеров
ML - устранение неточностей и багов
ML - оптимизация производительности DecisionTreeRegressor.Fit, RandomForestRegressor.Fit
ML - тесты
2026-05-07 22:53:13 +03:00

24 lines
949 B
ObjectPascal
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

uses MLABC, PlotML;
begin
var ds := Datasets.TitanicRu;
var df := ds.Data.Filter(row -> row.IsValid('Возраст'));
var diedAges: array of real := df
.Filter(row -> row.Int('Выжил') = 0)
.ToVector('Возраст').Data;
var survivedAges: array of real := df
.Filter(row -> row.Int('Выжил') = 1)
.ToVector('Возраст').Data;
Println($'Пассажиров с известным возрастом: {df.RowCount}');
Println($'Не выжили: {diedAges.Length}');
Println($'Выжили: {survivedAges.Length}');
Plot.HistMany([diedAges,survivedAges], bins := 20, colors := [Colors.IndianRed, Colors.SteelBlue], alpha := 0.45, legend := ['не выжили','выжили']);
Plot.Title := 'Титаник: возраст выживших (голубой) и невыживших (красный)';
Plot.XLabel('Возраст');
Plot.YLabel('Число пассажиров');
end.