|
|
| $ProjectDir = Join-Path $env:USERPROFILE 'bd-model-generations'
|
| $StatusFile = Join-Path $ProjectDir 'status\model_evaluator.status'
|
| $LogFile = Join-Path $ProjectDir 'logs\actions.log'
|
|
|
| function Write-Log {
|
| param([string]$Message, [string]$Type = 'INFO')
|
| $timestamp = (Get-Date).ToString('yyyyMMdd_HHmmss')
|
| Add-Content -Path $LogFile -Value "[$timestamp] $Type`: $Message"
|
| }
|
|
|
|
|
| New-Item -ItemType Directory -Force -Path (Split-Path $StatusFile) | Out-Null
|
|
|
| try {
|
|
|
| Set-Content -Path $StatusFile -Value 'Initializing model evaluation...'
|
| Write-Log 'Model evaluator started' 'INFO'
|
|
|
|
|
| $progressSteps = @(
|
| @{ Status = 'Loading test dataset...'; Duration = 2 },
|
| @{ Status = 'Computing accuracy metrics...'; Duration = 3 },
|
| @{ Status = 'Analyzing model performance...'; Duration = 2 },
|
| @{ Status = 'Generating confusion matrix...'; Duration = 2 },
|
| @{ Status = 'Creating evaluation report...'; Duration = 1 }
|
| )
|
|
|
| foreach ($step in $progressSteps) {
|
| Set-Content -Path $StatusFile -Value $step.Status
|
| Write-Log $step.Status 'INFO'
|
| Start-Sleep -Seconds $step.Duration
|
| }
|
|
|
|
|
| Set-Content -Path $StatusFile -Value 'Model evaluation completed successfully'
|
| Write-Log 'Model evaluation completed' 'SUCCESS'
|
| Start-Sleep -Seconds 1
|
|
|
| } catch {
|
| Write-Log "Error in model evaluation: $_" 'ERROR'
|
| Set-Content -Path $StatusFile -Value 'Error: Model evaluation failed'
|
| Start-Sleep -Seconds 1
|
| } finally {
|
|
|
| if (Test-Path $StatusFile) {
|
| Remove-Item -Path $StatusFile
|
| }
|
| }
|
|
|