<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: Type Error when attempting Linear Regression in Archives of Support Questions (Read Only)</title>
    <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Type-Error-when-attempting-Linear-Regression/m-p/98760#M12097</link>
    <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/209/dkumar.html" nodeid="209"&gt;@Dhruv Kumar&lt;/A&gt; Thanks it worked. &lt;/P&gt;</description>
    <pubDate>Mon, 14 Dec 2015 22:20:22 GMT</pubDate>
    <dc:creator>vjain</dc:creator>
    <dc:date>2015-12-14T22:20:22Z</dc:date>
    <item>
      <title>Type Error when attempting Linear Regression</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Type-Error-when-attempting-Linear-Regression/m-p/98754#M12091</link>
      <description>&lt;PRE&gt;import org.apache.spark.mllib.regression.LinearRegressionWithSGD
import org.apache.spark.mllib.regression.LabeledPoint
import org.apache.spark.mllib.linalg.Vectors
import org.apache.spark.ml.feature.{OneHotEncoder, StringIndexer}
import sqlContext.implicits._


val df = sqlContext.sql("select mnemonic, average, median, stddev from wellbook.curve_statistics")


val indexer = new StringIndexer()
  .setInputCol("mnemonic")
  .setOutputCol("mnemonicIndex")
  .fit(df)
val indexed = indexer.transform(df)


val encoder = new OneHotEncoder().setInputCol("mnemonicIndex").
  setOutputCol("mnemonicVec")
val encoded = encoder.transform(indexed)
val data = encoded.select("mnemonicVec", "average", "median", "stddev")


val parsedData = data.map(row =&amp;gt; LabeledPoint(row.getDouble(0), row.getAs[Vector](1)))
&lt;/PRE&gt;&lt;H3&gt;&lt;/H3&gt;&lt;H3&gt;&lt;/H3&gt;&lt;H3&gt;&amp;lt;console&amp;gt;:297: error: kinds of the type arguments (Vector) do not conform to the expected kinds of the type parameters (type T).
Vector's type parameters do not match type T's expected parameters:
type Vector has one type parameter, but type T has none
       val parsedData = data.map(row =&amp;gt; LabeledPoint(row.getDouble(0), row.getAs[Vector](1))&lt;/H3&gt;</description>
      <pubDate>Fri, 11 Dec 2015 12:22:11 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Type-Error-when-attempting-Linear-Regression/m-p/98754#M12091</guid>
      <dc:creator>vjain</dc:creator>
      <dc:date>2015-12-11T12:22:11Z</dc:date>
    </item>
    <item>
      <title>Re: Type Error when attempting Linear Regression</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Type-Error-when-attempting-Linear-Regression/m-p/98755#M12092</link>
      <description>&lt;P&gt;Which version of Spark and HDP are you using?&lt;/P&gt;</description>
      <pubDate>Fri, 11 Dec 2015 13:18:25 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Type-Error-when-attempting-Linear-Regression/m-p/98755#M12092</guid>
      <dc:creator>dkumar1</dc:creator>
      <dc:date>2015-12-11T13:18:25Z</dc:date>
    </item>
    <item>
      <title>Re: Type Error when attempting Linear Regression</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Type-Error-when-attempting-Linear-Regression/m-p/98756#M12093</link>
      <description>&lt;P&gt;Vedant, give this a shot:&lt;/P&gt;&lt;PRE&gt;val parsedData = data.map(row =&amp;gt; LabeledPoint(row.getDouble(0), row.asInstanceOf[Vector](1)))&lt;/PRE&gt;</description>
      <pubDate>Fri, 11 Dec 2015 14:19:11 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Type-Error-when-attempting-Linear-Regression/m-p/98756#M12093</guid>
      <dc:creator>jwiden</dc:creator>
      <dc:date>2015-12-11T14:19:11Z</dc:date>
    </item>
    <item>
      <title>Re: Type Error when attempting Linear Regression</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Type-Error-when-attempting-Linear-Regression/m-p/98757#M12094</link>
      <description>&lt;A rel="user" href="https://community.cloudera.com/users/209/dkumar.html" nodeid="209"&gt;@Dhruv Kumar&lt;/A&gt;&lt;P&gt;Spark1.4.1 and HDP2.3.2&lt;/P&gt;</description>
      <pubDate>Sat, 12 Dec 2015 03:15:20 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Type-Error-when-attempting-Linear-Regression/m-p/98757#M12094</guid>
      <dc:creator>vjain</dc:creator>
      <dc:date>2015-12-12T03:15:20Z</dc:date>
    </item>
    <item>
      <title>Re: Type Error when attempting Linear Regression</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Type-Error-when-attempting-Linear-Regression/m-p/98758#M12095</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/472/jwiden.html" nodeid="472"&gt;@Joe Widen&lt;/A&gt; I tried it earlier and gave me the same error. &lt;/P&gt;</description>
      <pubDate>Sat, 12 Dec 2015 03:16:47 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Type-Error-when-attempting-Linear-Regression/m-p/98758#M12095</guid>
      <dc:creator>vjain</dc:creator>
      <dc:date>2015-12-12T03:16:47Z</dc:date>
    </item>
    <item>
      <title>Re: Type Error when attempting Linear Regression</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Type-Error-when-attempting-Linear-Regression/m-p/98759#M12096</link>
      <description>&lt;P&gt;In addition to Vectors, you need to import the Spark Vector class explicitly since Scala imports its in-built Vector type by default. Try this:&lt;/P&gt;&lt;PRE&gt;import org.apache.spark.mllib.linalg.{Vector, Vectors}&lt;/PRE&gt;</description>
      <pubDate>Sun, 13 Dec 2015 06:04:03 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Type-Error-when-attempting-Linear-Regression/m-p/98759#M12096</guid>
      <dc:creator>dkumar1</dc:creator>
      <dc:date>2015-12-13T06:04:03Z</dc:date>
    </item>
    <item>
      <title>Re: Type Error when attempting Linear Regression</title>
      <link>https://community.cloudera.com/t5/Archives-of-Support-Questions/Type-Error-when-attempting-Linear-Regression/m-p/98760#M12097</link>
      <description>&lt;P&gt;&lt;A rel="user" href="https://community.cloudera.com/users/209/dkumar.html" nodeid="209"&gt;@Dhruv Kumar&lt;/A&gt; Thanks it worked. &lt;/P&gt;</description>
      <pubDate>Mon, 14 Dec 2015 22:20:22 GMT</pubDate>
      <guid>https://community.cloudera.com/t5/Archives-of-Support-Questions/Type-Error-when-attempting-Linear-Regression/m-p/98760#M12097</guid>
      <dc:creator>vjain</dc:creator>
      <dc:date>2015-12-14T22:20:22Z</dc:date>
    </item>
  </channel>
</rss>

