Analyzation
Analyze a user profile
Sahha provides automated analyzation
Sahha analyzes a user's activities over a period of time and provides a mental health personalized report which you can display or action within your app.
The default time period for an analysis is the previous 24 hours.
Analyze (Previous 24 Hours)
You can set (includeSourceData: true)
if you would like to receive an array of the source data that was used to generate the analysis in the response. The default value is false
.
// Analyze Previous 24 Hours
// Leave date range empty
Sahha.analyze(includeSourceData: true) { error, json in
isAnalyzeButtonEnabled = true
if let error = error {
print(error)
} else if let json = json {
print(json)
}
}
// Analyze previous 24 hours
// Leave date range empty
Sahha.analyze(true) { error, success ->
error?.also {
println(error)
}
success?.also {
println(success)
}
}
// Analyze previous 24 hours
// Leave date range empty
SahhaFlutter.analyze()
.then((value) => {
debugPrint(value)
})
.catchError((error, stackTrace) => {
debugPrint(error.toString())
});
// Analyze previous 24 Hours
// Leave date range empty
Sahha.analyze(
{
includeSourceData: true,
},
(error: string, value: string) => {
if (error) {
console.error(`Error: ${error}`);
} else if (value) {
console.log(`Value: ${value}`);
}
}
);
// Analyze previous 24 Hours
// Leave date range empty
Sahha.analyze({
includeSourceData: true,
})
.then((data) => {
console.log(data.value);
})
.catch((error: Error) => {
console.error(error);
});
Analyze (Date Range)
You can provide an optional data range if you would like to receive multiple analysis over a specific time period. The response will include an array of analysis for each 24 hour segment in that time period.
// Analyze Previous 7 Days
// Add a date range
let today = Date()
let sevenDaysAgo = Calendar.current.date(byAdding: .day, value: -7, to: today) ?? Date()
Sahha.analyze(dates: (sevenDaysAgo, today), includeSourceData: true) { error, json in
isAnalyzeButtonEnabled = true
if let error = error {
print(error)
} else if let json = json {
print(json)
}
}
// Analyze Previous 7 Days
// Add a date range
val now = Date()
val lastWeek = Date(now.time - SEVEN_DAYS_MILLIS)
Sahha.analyze(
true,
Pair(lastWeek, now)
) { error, success ->
error?.also {
println(error)
}
success?.also {
println(success)
}
}
// Analyze previous 7 days
// Add a date range
var week = DateTime.now().subtract(Duration(days: 7));
SahhaFlutter.analyze(startDate: week, endDate: DateTime.now())
.then((value) => {
debugPrint(value)
})
.catchError((error, stackTrace) => {
debugPrint(error.toString())
});
// Analyze previous 7 Days
// Add date range as milliseconds since epoch time
let endDate: Date = new Date();
let days = endDate.getDate() - 7;
var startDate = new Date();
startDate.setDate(days);
const settings = {
startDate: startDate.getTime(),
endDate: endDate.getTime(),
includeSourceData: true,
};
Sahha.analyze(settings, (error: string, value: string) => {
if (error) {
console.error(`Error: ${error}`);
} else if (value) {
console.log(`Value: ${value}`);
}
});
// Analyze previous 7 Days
// Add date range as milliseconds since epoch time
let endDate: Date = new Date();
let days = endDate.getDate() - 7;
var startDate = new Date();
startDate.setDate(days);
Sahha.analyze({
startDate: startDate.getTime(),
endDate: endDate.getTime(),
includeSourceData: true,
})
.then((data) => {
console.log(data.value);
})
.catch((error: Error) => {
console.error(error);
});
200 Response
200 Response
The response will be in JSON format. An example response includes these fields:
{
"inferences": [
{
"createdAt": "2022-05-20T00:30:00+00:00",
"predictionState": "not_depressed",
"predictionSimilarity": 0.8,
"dataSource": ["sleep", "steps", "age", "gender"]
}
]
}
204 Response
204 Response
MINIMUM DATA REQUIREMENTS
The analysis engine requires a minimum amount of device sensor data to be uploaded and processed before an analysis can be determined.
If you call
analyze
for a new user profile or a user that has been inactive lately, it's possible for the response to be204 No Content
. This is not an error.You will need to wait and try again every 24 hours until an analysis is available.
// An analysis is not ready yet
// Try again in 24 hours
// Empty JSON
{}
Data Sources
The analysis is created from various data sources
To receive an analysis, a minimum of one data source must be configured by the SDK.
The more data sources that you configure via the SDK, the better the analysis that will be generated.
Some data sources are not yet available on all platforms. Sahha continues to improve its analysis engine by bringing feature parity between platforms as well as adding new data sources.
Data Source | Description | Android | iOS |
---|---|---|---|
sleep | User sleep patterns | ✓ | ✓ |
steps | User walking patterns | X | ✓ |
screen | User device screen time | ✓ | X |
age | User age | ✓ | ✓ |
gender | User gender | ✓ | ✓ |
Sensors
Use Sensors as a Data Source
Learn how to configure sensors a data source.
Demographics
Use Demographics as a Data Source
Learn how to configure demographics as a data source.
Data Output
The analysis generated will include these distinct data types.
Data Output | Description | Data Type | Possible Values |
---|---|---|---|
createdAt | Time the analysis was generated | String | TimeStamp in format yyyy-MM-dd'T'HH:mm:ssxxx |
predictionState | Prediction of user health state | String | Either depressed or not_depressed |
predictionSimilarity | Similarity between source data and prediction state | Number | Any number between 0.5 to 1.0 |
dataSource | Data sources used to generate the analysis | String Array | Any combination of sleep ,steps ,screen ,age ,gender |
Updated 26 days ago