Giter VIP home page Giter VIP logo

Comments (4)

zengfr avatar zengfr commented on August 22, 2024 1

if you use Weights\ WeightLabels and model , you should reload model. like this is OK:
SaveModel and LoadModel

parameter.WeightLabels = lableFeaturesBuilder.CreateWeightLables("行政湖景双床房").ToArray();
parameter.Weights = new double[] { 1.90, 1.90, 1.90, 1.99, 1.99 };

var model2 = LibSVMsharp.SVM.Train(problem, parameter);
model2.SaveModel("roomMatching.model");

var model = LibSVMsharp.SVM.LoadModel("roomMatching.model");
foreach (var room in rooms1)
{
predictedY = LibSVMsharp.SVM.Predict(model, nodes);

you can see my sample:

https://github.com/zengfr/SVM-Neuro-Matching/blob/master/roomMatching/roomMatching/Program.cs

from libsvmsharp.

MonsterMMORPG avatar MonsterMMORPG commented on August 22, 2024

Even wrapping them inside try catch causes error :(

The error does not happen if i don't use parameter.WeightLabels

from libsvmsharp.

ccerhan avatar ccerhan commented on August 22, 2024

First, sorry for my late answer.

Could you explain how you use weights for each class?
By using the properties Weights and WeightLabels in SVMParameter?

Please check the lines between 414 and 424 in this link, just to be sure.

from libsvmsharp.

slonoten avatar slonoten commented on August 22, 2024

To reproduce this issue just add weights to LibSVMsharp.Examples.Classification:

            // Select the parameter set
            SVMParameter parameter = new SVMParameter();
            parameter.Type = SVMType.C_SVC;
            parameter.Kernel = SVMKernelType.RBF;
            parameter.C = 1;
            parameter.Gamma = 1;
            parameter.WeightLabels = new[] { 1, 2, 3 };
            parameter.Weights = new[] { 1.0, 2.0, 3.0 };

I think there is an extra call of SVMModel.Free in SVMModel.Allocate
Commenting this call resolves problem:

            // Allocate model.parameter
            IntPtr ptr_param = SVMParameter.Allocate(x.Parameter);
            y.param = (svm_parameter)Marshal.PtrToStructure(ptr_param, typeof(svm_parameter));
            // SVMParameter.Free(ptr_param);

from libsvmsharp.

Related Issues (18)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.