Skip to content

Commit

Permalink
all generated tests work upon generator.py/tester.py now
Browse files Browse the repository at this point in the history
  • Loading branch information
Soeren Sonnenburg committed Aug 31, 2011
1 parent b17aeae commit 3deadd2
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 23 deletions.
Expand Up @@ -54,7 +54,7 @@ def distribution_ppwm_modular (fm_dna=traindna, order=3):

#out_likelihood = histo.get_log_likelihood()
#out_sample = histo.get_log_likelihood_sample()
return ppwm,w,u
return w,u
###########################################################################
# call functions
###########################################################################
Expand Down
Expand Up @@ -38,7 +38,7 @@ def streaming_vw_createcache_modular(fname):
features = StreamingVwFeatures(input_file, True, 1024);
vw = VowpalWabbit(features)
vw.train()
return vw
#return vw

if __name__ == "__main__":
streaming_vw_createcache_modular(*parameter_list[0])
28 changes: 14 additions & 14 deletions examples/undocumented/python_modular/streaming_vw_modular.py
Expand Up @@ -6,25 +6,25 @@
parameter_list=[[None]]

def streaming_vw_modular(dummy):
"""Runs the VW algorithm on a toy dataset in SVMLight format."""
"""Runs the VW algorithm on a toy dataset in SVMLight format."""

# Open the input file as a StreamingVwFile
input_file = StreamingVwFile("../data/fm_train_sparsereal.dat")
# Open the input file as a StreamingVwFile
input_file = StreamingVwFile("../data/fm_train_sparsereal.dat")

# Tell VW that the file is in SVMLight format
# Supported types are T_DENSE, T_SVMLIGHT and T_VW
input_file.set_parser_type(T_SVMLIGHT)
# Tell VW that the file is in SVMLight format
# Supported types are T_DENSE, T_SVMLIGHT and T_VW
input_file.set_parser_type(T_SVMLIGHT)

# Create a StreamingVwFeatures object, `True' indicating the examples are labelled
features = StreamingVwFeatures(input_file, True, 1024)
# Create a StreamingVwFeatures object, `True' indicating the examples are labelled
features = StreamingVwFeatures(input_file, True, 1024)

# Create a VW object from the features
vw = VowpalWabbit(features)
# Create a VW object from the features
vw = VowpalWabbit(features)

# Train
vw.train()
# Train
vw.train()

return vw
#return vw

if __name__ == "__main__":
streaming_vw_modular(*parameter_list[0]))
streaming_vw_modular(*parameter_list[0])
18 changes: 12 additions & 6 deletions src/shogun/kernel/SplineKernel.cpp
Expand Up @@ -18,11 +18,11 @@

using namespace shogun;

CSplineKernel::CSplineKernel(void)
CSplineKernel::CSplineKernel() : CDotKernel()
{
}

CSplineKernel::CSplineKernel(CDotFeatures* l, CDotFeatures* r)
CSplineKernel::CSplineKernel(CDotFeatures* l, CDotFeatures* r) : CDotKernel()
{
init(l,r);
}
Expand All @@ -34,6 +34,12 @@ CSplineKernel::~CSplineKernel()

bool CSplineKernel::init(CFeatures* l, CFeatures* r)
{
ASSERT(l->get_feature_type()==F_DREAL);
ASSERT(l->get_feature_type()==r->get_feature_type());

ASSERT(l->get_feature_class()==C_SIMPLE);
ASSERT(l->get_feature_class()==r->get_feature_class());

CDotKernel::init(l,r);
return init_normalizer();
}
Expand All @@ -48,8 +54,8 @@ float64_t CSplineKernel::compute(int32_t idx_a, int32_t idx_b)
int32_t alen, blen;
bool afree, bfree;

float32_t* avec = ((CSimpleFeatures<float32_t>*) lhs)->get_feature_vector(idx_a, alen, afree);
float32_t* bvec = ((CSimpleFeatures<float32_t>*) rhs)->get_feature_vector(idx_b, blen, bfree);
float64_t* avec = ((CSimpleFeatures<float64_t>*) lhs)->get_feature_vector(idx_a, alen, afree);
float64_t* bvec = ((CSimpleFeatures<float64_t>*) rhs)->get_feature_vector(idx_b, blen, bfree);
ASSERT(alen == blen);

float64_t result = 0;
Expand All @@ -59,8 +65,8 @@ float64_t CSplineKernel::compute(int32_t idx_a, int32_t idx_b)
result += 1 + x*y + x*y*min - ((x+y)/2)*min*min + min*min*min/3;
}

((CSimpleFeatures<float32_t>*) lhs)->free_feature_vector(avec, idx_a, afree);
((CSimpleFeatures<float32_t>*) rhs)->free_feature_vector(bvec, idx_b, bfree);
((CSimpleFeatures<float64_t>*) lhs)->free_feature_vector(avec, idx_a, afree);
((CSimpleFeatures<float64_t>*) rhs)->free_feature_vector(bvec, idx_b, bfree);

return result;
}
2 changes: 1 addition & 1 deletion src/shogun/kernel/SplineKernel.h
Expand Up @@ -70,7 +70,7 @@ class CSplineKernel: public CDotKernel
*
* @return name Spline
*/
virtual const char* get_name() const { return "Spline"; }
virtual const char* get_name() const { return "SplineKernel"; }

protected:
virtual float64_t compute(int32_t idx_a, int32_t idx_b);
Expand Down

0 comments on commit 3deadd2

Please sign in to comment.