File tree Expand file tree Collapse file tree 2 files changed +9
-9
lines changed
Expand file tree Collapse file tree 2 files changed +9
-9
lines changed Original file line number Diff line number Diff line change 2020 ],
2121 "require" : {
2222 "php" : " >=7.2" ,
23- "league/csv" : " ^9.5" ,
24- "rubix/ml" : " ^0.1.0-rc3"
23+ "rubix/ml" : " ^0.1.0"
2524 },
2625 "scripts" : {
2726 "train" : " @php train.php"
Original file line number Diff line number Diff line change 88use Rubix \ML \Other \Loggers \Screen ;
99use Rubix \ML \CrossValidation \Reports \ContingencyTable ;
1010use Rubix \ML \CrossValidation \Metrics \Homogeneity ;
11- use League \ Csv \ Writer ;
11+ use Rubix \ ML \ Datasets \ Unlabeled ;
1212
1313use function Rubix \ML \array_transpose ;
1414
3131
3232$ estimator = new KMeans (10 );
3333
34- $ estimator ->setLogger (new Screen (' colors ' ));
34+ $ estimator ->setLogger (new Screen ());
3535
3636echo 'Training ... ' . PHP_EOL ;
3737
3838$ estimator ->train ($ training );
3939
4040$ losses = $ estimator ->steps ();
4141
42- $ writer = Writer::createFromPath ('progress.csv ' , 'w+ ' );
43-
44- $ writer ->insertOne (['loss ' ]);
45- $ writer ->insertAll (array_transpose ([$ losses ]));
42+ Unlabeled::build (array_transpose ([$ losses ]))
43+ ->toCSV (['losses ' ])
44+ ->write ('progress.csv ' );
4645
4746echo 'Progress saved to progress.csv ' . PHP_EOL ;
4847
5453
5554$ results = $ report ->generate ($ predictions , $ testing ->labels ());
5655
57- file_put_contents ('report.json ' , json_encode ($ results , JSON_PRETTY_PRINT ));
56+ echo $ results ;
57+
58+ $ results ->toJSON ()->write ('report.json ' );
5859
5960echo 'Report saved to report.json ' . PHP_EOL ;
6061
You can’t perform that action at this time.
0 commit comments