CGI-FR / CGI-FR/SIGO

[FEAT][API] Get explained variance of avatarization/de-identification model

Open
#79 0 comments 0 reactions 0 assignees View on GitHub
api octopize
Dominant language
Go
Stars
6
Forks
0
PR merge metrics
No merged PRs in 30d

Description

## Description
This feature allows to get the explained variance of records used to fit the model.

## Request

### Method
GET

### URL
`/variance/{job_id}`

### Request Parameters
| Parameter | Description | Required | Example |
|---|---|---|---|
| job_id | avatarization or privacy job id used to fit the model | yes | `0123456789abcdef0123456789abcdef` |

### Request Body
(none)

## Result

### Result parameters
(none)

### Result Body
```go
type ExplainedVariance struct {
Raw []float64 `json:"raw"`
Ratio []float64 `json:"ratio"`
}
```

## Example Curl Request

### Request
```bash
curl -X GET "http://localhost:8080/variance/0123456789abcdef0123456789abcdef"
```

### Curl Response
```go
{
"raw": [
0.9999999999999999,
0.9999999999999999,
0.9999999999999999,
0.9999999999999999,
0.9999999999999999
],
"ratio": [
0.9999999999999999,
0.9999999999999999,
0.9999999999999999,
0.9999999999999999,
0.9999999999999999
]
}
```

## Go server

### Struct
```go
type explainedVarianceResponse struct {
Raw []float64 `json:"raw"`
Ratio []float64 `json:"ratio"`
}
```

### Handler
```go
func (s *server) getExplainedVariance(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()

jobID := mux.Vars(r)["jobID"]
ev, err := s.db.GetExplainedVariance(ctx, jobID)
if err != nil {
http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
return
}

w.Header().Set("Content-Type", "application/json")
if err := json.NewEncoder(w).Encode(explainedVarianceResponse{
Raw: ev.Raw,
Ratio: ev.Ratio,
}); err != nil {
http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
return
}
}
```
## Links

- [Metrics.get_explained_variance](https://github.com/octopize/avatar-python/blob/0.6.2/avatars/api.py#L1002)
- [ExplainedVariance](https://github.com/octopize/avatar-python/blob/0.6.2/avatars/api.py#L1002)

## Automated Issue Details

Dear visitor,

This issue has been automatically generated from the Octopize project [avatar-python](https://github.com/octopize/avatar-python/) to make SIGO compatible. Please vote with a thumbs up or thumbs down to assess the quality of the automatic generation.

Best regards,
The SIGO Team

Contributor guide

Open the contributing guide

Research direction

Start at the getExplainedVariance handler and s.db.GetExplainedVariance entry points, then compare their behavior with Metrics.get_explained_variance in avatar-python's avatars/api.py. The work is done when GET /variance/{job_id} returns the documented raw and ratio JSON values for the specified avatarization or privacy job.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, python
Domain
api, backend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.