Skip to content

Commit 38df179

Browse files
Copilothotlong
andcommitted
Fix naming collision: rename Feature to ModelFeature in predictive analytics
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 48cc4c4 commit 38df179

File tree

5 files changed

+108
-33
lines changed

5 files changed

+108
-33
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
title: ModelFeature
3+
description: ModelFeature Schema Reference
4+
---
5+
6+
## Properties
7+
8+
| Property | Type | Required | Description |
9+
| :--- | :--- | :--- | :--- |
10+
| **name** | `string` || Feature name (snake_case) |
11+
| **label** | `string` | optional | Human-readable label |
12+
| **field** | `string` || Source field name |
13+
| **object** | `string` | optional | Source object (if different from target) |
14+
| **dataType** | `Enum<'numeric' \| 'categorical' \| 'text' \| 'datetime' \| 'boolean'>` || Feature data type |
15+
| **transformation** | `Enum<'none' \| 'normalize' \| 'standardize' \| 'one_hot_encode' \| 'label_encode' \| 'log_transform' \| 'binning' \| 'embedding'>` | optional | |
16+
| **required** | `boolean` | optional | |
17+
| **defaultValue** | `any` | optional | |
18+
| **description** | `string` | optional | |
19+
| **importance** | `number` | optional | Feature importance score (0-1) |

content/docs/references/ai/config/Feature.mdx

Lines changed: 0 additions & 15 deletions
This file was deleted.
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
{
2+
"$ref": "#/definitions/ModelFeature",
3+
"definitions": {
4+
"ModelFeature": {
5+
"type": "object",
6+
"properties": {
7+
"name": {
8+
"type": "string",
9+
"pattern": "^[a-z_][a-z0-9_]*$",
10+
"description": "Feature name (snake_case)"
11+
},
12+
"label": {
13+
"type": "string",
14+
"description": "Human-readable label"
15+
},
16+
"field": {
17+
"type": "string",
18+
"description": "Source field name"
19+
},
20+
"object": {
21+
"type": "string",
22+
"description": "Source object (if different from target)"
23+
},
24+
"dataType": {
25+
"type": "string",
26+
"enum": [
27+
"numeric",
28+
"categorical",
29+
"text",
30+
"datetime",
31+
"boolean"
32+
],
33+
"description": "Feature data type"
34+
},
35+
"transformation": {
36+
"type": "string",
37+
"enum": [
38+
"none",
39+
"normalize",
40+
"standardize",
41+
"one_hot_encode",
42+
"label_encode",
43+
"log_transform",
44+
"binning",
45+
"embedding"
46+
],
47+
"default": "none"
48+
},
49+
"required": {
50+
"type": "boolean",
51+
"default": true
52+
},
53+
"defaultValue": {},
54+
"description": {
55+
"type": "string"
56+
},
57+
"importance": {
58+
"type": "number",
59+
"description": "Feature importance score (0-1)"
60+
}
61+
},
62+
"required": [
63+
"name",
64+
"field",
65+
"dataType"
66+
],
67+
"additionalProperties": false
68+
}
69+
},
70+
"$schema": "http://json-schema.org/draft-07/schema#"
71+
}

packages/spec/src/ai/predictive.test.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ import { describe, it, expect } from 'vitest';
22
import {
33
PredictiveModelSchema,
44
PredictiveModelTypeSchema,
5-
FeatureSchema,
5+
ModelFeatureSchema,
66
HyperparametersSchema,
77
TrainingConfigSchema,
88
EvaluationMetricsSchema,
99
PredictionRequestSchema,
1010
PredictionResultSchema,
1111
ModelDriftSchema,
1212
type PredictiveModel,
13-
type Feature,
13+
type ModelFeature,
1414
type PredictionRequest,
1515
} from './predictive.zod';
1616

@@ -32,23 +32,23 @@ describe('PredictiveModelTypeSchema', () => {
3232
});
3333
});
3434

35-
describe('FeatureSchema', () => {
35+
describe('ModelFeatureSchema', () => {
3636
it('should accept minimal feature', () => {
37-
const feature: Feature = {
37+
const feature: ModelFeature = {
3838
name: 'user_age',
3939
field: 'age',
4040
dataType: 'numeric',
4141
};
4242

43-
const result = FeatureSchema.parse(feature);
43+
const result = ModelFeatureSchema.parse(feature);
4444
expect(result.transformation).toBe('none');
4545
expect(result.required).toBe(true);
4646
});
4747

4848
it('should enforce snake_case for feature name', () => {
4949
const validNames = ['user_age', 'total_revenue', '_internal_score'];
5050
validNames.forEach(name => {
51-
expect(() => FeatureSchema.parse({
51+
expect(() => ModelFeatureSchema.parse({
5252
name,
5353
field: 'test',
5454
dataType: 'numeric',
@@ -57,7 +57,7 @@ describe('FeatureSchema', () => {
5757

5858
const invalidNames = ['userAge', 'User-Age', '123age'];
5959
invalidNames.forEach(name => {
60-
expect(() => FeatureSchema.parse({
60+
expect(() => ModelFeatureSchema.parse({
6161
name,
6262
field: 'test',
6363
dataType: 'numeric',
@@ -66,39 +66,39 @@ describe('FeatureSchema', () => {
6666
});
6767

6868
it('should accept feature with transformation', () => {
69-
const feature: Feature = {
69+
const feature: ModelFeature = {
7070
name: 'normalized_revenue',
7171
field: 'annual_revenue',
7272
dataType: 'numeric',
7373
transformation: 'normalize',
7474
label: 'Normalized Annual Revenue',
7575
};
7676

77-
expect(() => FeatureSchema.parse(feature)).not.toThrow();
77+
expect(() => ModelFeatureSchema.parse(feature)).not.toThrow();
7878
});
7979

8080
it('should accept categorical feature', () => {
81-
const feature: Feature = {
81+
const feature: ModelFeature = {
8282
name: 'industry_encoded',
8383
field: 'industry',
8484
dataType: 'categorical',
8585
transformation: 'one_hot_encode',
8686
description: 'Industry category with one-hot encoding',
8787
};
8888

89-
expect(() => FeatureSchema.parse(feature)).not.toThrow();
89+
expect(() => ModelFeatureSchema.parse(feature)).not.toThrow();
9090
});
9191

9292
it('should accept feature from related object', () => {
93-
const feature: Feature = {
93+
const feature: ModelFeature = {
9494
name: 'account_revenue',
9595
field: 'annual_revenue',
9696
object: 'account',
9797
dataType: 'numeric',
9898
transformation: 'log_transform',
9999
};
100100

101-
expect(() => FeatureSchema.parse(feature)).not.toThrow();
101+
expect(() => ModelFeatureSchema.parse(feature)).not.toThrow();
102102
});
103103
});
104104

packages/spec/src/ai/predictive.zod.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ export const PredictiveModelTypeSchema = z.enum([
3131
]);
3232

3333
/**
34-
* Feature Definition
35-
* Describes an input feature for the model
34+
* Model Feature Definition
35+
* Describes an input feature for a predictive model
3636
*/
37-
export const FeatureSchema = z.object({
37+
export const ModelFeatureSchema = z.object({
3838
/** Feature Identity */
3939
name: z.string().regex(/^[a-z_][a-z0-9_]*$/).describe('Feature name (snake_case)'),
4040
label: z.string().optional().describe('Human-readable label'),
@@ -183,7 +183,7 @@ export const PredictiveModelSchema = z.object({
183183
targetType: z.enum(['numeric', 'categorical', 'binary']).optional().describe('Target field type'),
184184

185185
/** Features */
186-
features: z.array(FeatureSchema).describe('Input features for the model'),
186+
features: z.array(ModelFeatureSchema).describe('Input features for the model'),
187187

188188
/** Hyperparameters */
189189
hyperparameters: HyperparametersSchema.optional(),
@@ -285,7 +285,7 @@ export const ModelDriftSchema = z.object({
285285

286286
// Type exports
287287
export type PredictiveModelType = z.infer<typeof PredictiveModelTypeSchema>;
288-
export type Feature = z.infer<typeof FeatureSchema>;
288+
export type ModelFeature = z.infer<typeof ModelFeatureSchema>;
289289
export type Hyperparameters = z.infer<typeof HyperparametersSchema>;
290290
export type TrainingConfig = z.infer<typeof TrainingConfigSchema>;
291291
export type EvaluationMetrics = z.infer<typeof EvaluationMetricsSchema>;

0 commit comments

Comments
 (0)