
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Supervised learning is the machine learning task of inferring a function from labeled training data. A supervised learning algorithm analyzes the training data and produces an inferred function, which can be used for mapping new examples.
Credits for some of the algorithms used go to Andrew Ng at Stanford University.
One example is the prediction of house prices (output value) along two dimensions (features): the size of house in square meters and the number of bedrooms.
The training data could look something like this:
Size (m2) | # bedrooms | Price |
---|---|---|
2104 | 3 | 399900 |
1600 | 3 | 329900 |
3000 | 4 | 539900 |
1940 | 4 | 239999 |
Using linear regression, we can now predict the price of a house with 2200 square meters and 3 bedrooms.
Add this line to your application's Gemfile:
gem 'supervised_learning'
And then execute:
$ bundle
Or install it yourself as:
$ gem install supervised_learning
The output value (the type of value you want to predict) needs to be in the last column. The matrix has to have a) at least two columns (one feature and one output) and b) at least one row. The more data you feed it, the more accurate the prediction.
Consult the Ruby API for information on how to build matrices. You can use both arrays of rows or columns to create a matrix.
require 'matrix'
training_set = Matrix[ [2104, 3, 399900], [1600, 3, 329900], [3000, 4, 539900], [1940, 4, 239999] ]
require 'supervised_learning' # if not automatically loaded
program = SupervisedLearning::LinearRegression.new(training_set)
This matrix has one row and the columns follow the order of the training set. It has one column less than the training set since the output value (the last column of the training set) is the value we want to predict.
# Predict the price of a house of 2200 square meters with 3 bedrooms
prediction_set = Matrix[ [2200, 3] ]
program.predict(prediction_set)
=> 454115.66
The lower bound running time of the #predict
method is cubic / Ω(n3). Hence, on very large datasets (more than 1,000 columns / features), the #predict
method can be slow. If this happens, use the #predict_advanced
method, which uses gradient descent (approximation) instead of normalization (direct calculation). Gradient descent can be a bit less accurate and also requires some optional parameters.
The #predict_advanced
method takes 4 parameters in the following order:
#prediction
method discussed above# Predict the price of a house of 2200 square meters with 3 bedrooms
prediction_set = Matrix[ [2200, 3] ]
program.predict_advanced(prediction_set, 0.01, 600, false)
=> 443693.16
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)FAQs
Unknown package
We found that supervised_learning demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.