Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
ease
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
ease
Commits
ea255e9f
Commit
ea255e9f
authored
Jan 24, 2013
by
Vik Paruchuri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding generic ML algo
parent
862c1637
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
61 additions
and
1 deletions
+61
-1
predictor_set.py
+61
-1
No files found.
predictor_set.py
View file @
ea255e9f
...
...
@@ -4,6 +4,7 @@ import sys
import
random
import
os
import
logging
import
essay_set
base_path
=
os
.
path
.
dirname
(
__file__
)
sys
.
path
.
append
(
base_path
)
...
...
@@ -38,4 +39,63 @@ class PredictorSet(object):
self
.
essay_sets
=
[]
def
add_row
(
self
,
numeric_features
,
textual_features
,
target
):
pass
#Basic input checking
if
not
isinstance
(
target
,
(
int
,
long
,
float
)):
error_message
=
"Target is not a numeric value."
log
.
exception
(
error_message
)
raise
util_functions
.
InputError
(
target
,
error_message
)
if
not
isinstance
(
numeric_features
,
list
):
error_message
=
"Numeric features are not a list."
log
.
exception
(
error_message
)
raise
util_functions
.
InputError
(
numeric_features
,
error_message
)
if
not
isinstance
(
textual_features
,
list
):
error_message
=
"Textual features are not a list."
log
.
exception
(
error_message
)
raise
util_functions
.
InputError
(
textual_features
,
error_message
)
#Do some length checking for parameters
if
len
(
self
.
_numeric_features
)
>
0
:
numeric_length
=
len
(
self
.
_numeric_features
[
-
1
])
current_numeric_length
=
len
(
numeric_features
)
if
numeric_length
!=
current_numeric_length
:
error_message
=
"Numeric features are an improper length."
log
.
exception
(
error_message
)
raise
util_functions
.
InputError
(
numeric_features
,
error_message
)
if
len
(
self
.
_textual_features
)
>
0
:
textual_length
=
len
(
self
.
_textual_features
[
-
1
])
current_textual_length
=
len
(
textual_features
)
if
textual_length
!=
current_textual_length
:
error_message
=
"Textual features are an improper length."
log
.
exception
(
error_message
)
raise
util_functions
.
InputError
(
textual_features
,
error_message
)
#Now check to see if text features and numeric features are individually correct
for
i
in
xrange
(
0
,
len
(
numeric_features
)):
try
:
numeric_features
[
i
]
=
float
(
numeric_features
[
i
])
except
:
error_message
=
"Numeric feature {0} not numeric."
.
format
(
numeric_features
[
i
])
log
.
exception
(
error_message
)
raise
util_functions
.
InputError
(
numeric_features
,
error_message
)
for
i
in
xrange
(
0
,
len
(
textual_features
)):
try
:
textual_features
[
i
]
=
str
(
textual_features
[
i
]
.
encode
(
'ascii'
,
'ignore'
))
except
:
error_message
=
"Textual feature {0} not string."
.
format
(
textual_features
[
i
])
log
.
exception
(
error_message
)
raise
util_functions
.
InputError
(
textual_features
,
error_message
)
if
len
(
self
.
_textual_features
)
==
0
:
for
i
in
xrange
(
0
,
len
(
textual_features
)):
self
.
essay_sets
.
append
()
self
.
_numeric_features
.
append
(
numeric_features
)
self
.
_textual_features
.
append
(
textual_features
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment