Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8690491
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T23:54:50+00:00 2026-06-12T23:54:50+00:00

I am trying to implement a novelty detector using the kernlab library (ksvm function)

  • 0

I am trying to implement a novelty detector using the kernlab library (ksvm function) in R. Here is a simple example of what I am trying to do:

# Training data
xxTrain <- matrix(rnorm(2000), nrow=1000, ncol=2, byrow=TRUE)
y <- rep(1,1000)
classifier <- ksvm(xxTrain, y, type="one-svc", kernel="rbfdot", kpar="automatic")
# Test data
x1 <- rnorm(1000)
scale <- c(rep(1,500), rep(10,100), rep(1,400))
x2 <- rnorm(1000)*scale
xxTest <- matrix(c(x1,x2), nrow=1000, ncol=2, byrow=TRUE)
# Prediction
p <- predict(classifier, xxTest, type="response")
# Visualization
plot(x2, type='l')
lines(x1, col="red")
points(5*as.integer(p), type='l', col="blue")

enter image description here

The figure above is the result I get. The blue trace is the prediction, and it clearly shows a period where its consitently 0. But it does not match in time or width with the outlier in the black trace. There are 100 points (black line) which are of larger amplitude, and the output I get in the blue does not match with the black line.

What am I doing wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T23:54:52+00:00Added an answer on June 12, 2026 at 11:54 pm

    Here is what you are doing wrong:

    xxTest <- matrix(c(x1,x2), nrow=1000, ncol=2, byrow=TRUE)
    

    this should be

    xxTest <- matrix(c(x1,x2), nrow=1000, ncol=2, byrow=F )
    

    or better

    xxTest <- cbind( x1, x2 )
    

    or simply

    p <- predict( classifier, cbind( x1, x2 ), type= "response" )
    

    Result (I have used grey for x2):

    enter image description here

    Explanation: by specyfying byrow=T, you were taking first the elements of x1 to fill up the first 500 rows (alternatively, column 1 and 2), and then x2 to fill up the remaining 500 rows of xxTest. Since the singularity was at around ~ 500 – 600 in x2, then it turned up in both columns of xxTest at around (500+500)/2 – (500+600)/2 which is 750-800 which is what you can see.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying implement the Data transformation using Reflection 1 example in my code.
Trying to implement the example from here. Facebook Share passes along the URL of
Trying to implement google C2DM service. registrationIntent.putExtra(app, PendingIntent.getBroadcast(context,0,new Intent(), 0)); registrationIntent.putExtra(sender,example@gmail.com); context.startService(registrationIntent); Almost every
Trying to implement a search similar to here .This searches properties based on city,locality,property
I trying to implement some relatively simple 2D sprite batching in OpenGL ES 2.0
I'm trying implement a bracket in my program (using C#/.NET MVC) and I am
Ok well I'm trying implement something similar to the 'undo' function in many image
Trying to implement AVAudioplayer and get some metering data of the played music, but
Trying to implement the excellent jQuery bidirectional infite scroll as explained here: http://www.bennadel.com/blog/1803-Creating-A-Bidirectional-Infinite-Scroll-Page-With-jQuery-And-ColdFusion.htm For
im trying to implement the recursive Ackermann-Peter-Function in x86 NASM-Assembly. The Function is defined

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.