Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
youen opened this issue Mar 31, 2024 · 0 comments
Open

Comments

@youen
Copy link
Collaborator

youen commented Mar 31, 2024

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

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

Example Curl Request

Request

curl -X GET "http://localhost:8080/variance/0123456789abcdef0123456789abcdef"

Curl Response

{
  "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

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

Handler

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

Automated Issue Details

Dear visitor,

This issue has been automatically generated from the Octopize project 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant