0

I am using svd algorithm and I am using coldstart form in suggestion system in my dataset(book crosing).

for leveraging sparsity with MathNet.Numeric befor using svD in my form ,I am using This code in rating Table , But my code doesnt read a data set.

here is my code

var arrayOfDoubles = DenseMatrix.OfArray(To2D<double>
(dt1_rating.AsEnumerable().Select(x => new[] { 
 Convert.ToDouble(x[0]) }).ToArray()));
        //Select(x => new[] { Convert.ToDouble(x[0]), 
      Convert.ToDouble(x[1]) }).ToArray()));

        var S = arrayOfDoubles.Svd();
        DataTable dt = new DataTable();
        dt.Clear();
        dt.Columns.Add("USERID");
        dt.Columns.Add("ISBn");
        dt.Columns.Add("BOOKRATING");

        double[,] U = S.VT.ToArray();

        for (int outerIndex = 0; outerIndex < S.VT.RowCount; outerIndex++)
        {


            for (int innerIndex = 0; innerIndex < S.VT.ColumnCount; innerIndex++)
            {
                DataRow newRow = dt.NewRow();
                newRow["USERID"] = U[outerIndex, innerIndex];
                newRow["ISBN"] = U[outerIndex, innerIndex];
                newRow["BOOKRATING"] = U[outerIndex, innerIndex];
                dt.Rows.Add(newRow);

            }

        }
        dt1_rating = dt;///////////////////تا این جا

This is my error

Object cannot be Cast fromDbNull to other types or System Invalid CastExceptions

Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
Mahdy
  • 1
  • 2
  • Don't understand what question you are asking. A DataSet consists on one or more DataTables. Most classes that require a DataSet will also accept one DataTable instead. You can also add a DataTable to a DataSet if the class doesn't accept a single DataTable. – jdweng Jun 24 '17 at 20:16
  • My data set is from book crossing , which is from table with rating and user and other items. Now I want to use SVD for rating . For the first I want to use svd and put it in to a data then use cold .what is your idea? – Mahdy Jun 24 '17 at 20:35
  • I added the error contex to the question. – Mahdy Jun 24 '17 at 20:41
  • Check if arrayOfDoubles, S, or U are null. One or more of these 3 variables are null. – jdweng Jun 24 '17 at 20:45
  • Thanks,it works.I have no error now.could you give an example of U matrix? My result are same with cold state. – Mahdy Jun 25 '17 at 07:18
  • double[,] U = { { 0, 1 }, { 1, 2 }, { 3, 4 }, { 5, 6 }, { 7, 8 } }; – jdweng Jun 25 '17 at 08:05
  • your numbers doesnt work.my SVD formula is data=U*S*VT. I need real number for U matrix according to rating table.do have any suggestion? – Mahdy Jun 25 '17 at 19:06

0 Answers0